Mumbai Testnet

Contract

0x53BEA4469B91D391283c2e516ed69501921Fbd11

Overview

MATIC Balance

Polygon PoS Chain LogoPolygon PoS Chain LogoPolygon PoS Chain Logo0 MATIC

Multichain Info

N/A
Transaction Hash
Method
Block
From
To
Value

There are no matching entries

Please try again later

Latest 1 internal transaction

Parent Txn Hash Block From To Value
253221542022-02-28 20:25:16759 days ago1646079916  Contract Creation0 MATIC
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
ERC20TransferTier

Compiler Version
v0.8.10+commit.fc410830

Optimization Enabled:
Yes with 100000 runs

Other Settings:
default evmVersion, None license

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 13 : ERC20TransferTier.sol
// SPDX-License-Identifier: CAL
pragma solidity ^0.8.10;

import "@openzeppelin/contracts/proxy/utils/Initializable.sol";

import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
//solhint-disable-next-line max-line-length
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "../math/SaturatingMath.sol";
import {TierReport} from "./libraries/TierReport.sol";
import {ValueTier} from "./ValueTier.sol";
import "./ReadWriteTier.sol";

/// @param erc20_ The erc20 token contract to transfer balances
/// from/to during `setTier`.
/// @param tierValues_ 8 values corresponding to minimum erc20
/// balances for tiers ONE through EIGHT.
struct ERC20TransferTierConfig {
    IERC20 erc20;
    uint256[8] tierValues;
}

/// @title ERC20TransferTier
/// @notice `ERC20TransferTier` inherits from `ReadWriteTier`.
///
/// In addition to the standard accounting it requires that users transfer
/// erc20 tokens to achieve a tier.
///
/// Data is ignored, the only requirement is that the user has approved
/// sufficient balance to gain the next tier.
///
/// To avoid griefing attacks where accounts remove tiers from arbitrary third
/// parties, we `require(msg.sender == account_);` when a tier is removed.
/// When a tier is added the `msg.sender` is responsible for payment.
///
/// The 8 values for gainable tiers and erc20 contract must be set upon
/// construction and are immutable.
///
/// The `_afterSetTier` simply transfers the diff between the start/end tier
/// to/from the user as required.
///
/// If a user sends erc20 tokens directly to the contract without calling
/// `setTier` the FUNDS ARE LOST.
///
/// @dev The `ERC20TransferTier` takes ownership of an erc20 balance by
/// transferring erc20 token to itself. The `msg.sender` must pay the
/// difference on upgrade; the tiered address receives refunds on downgrade.
/// This allows users to "gift" tiers to each other.
/// As the transfer is a state changing event we can track historical block
/// times.
/// As the tiered address moves up/down tiers it sends/receives the value
/// difference between its current tier only.
///
/// The user is required to preapprove enough erc20 to cover the tier change or
/// they will fail and lose gas.
///
/// `ERC20TransferTier` is useful for:
/// - Claims that rely on historical holdings so the tiered address
///   cannot simply "flash claim"
/// - Token demand and lockup where liquidity (trading) is a secondary goal
/// - erc20 tokens without additonal restrictions on transfer
contract ERC20TransferTier is ReadWriteTier, ValueTier, Initializable {
    using SafeERC20 for IERC20;
    using SaturatingMath for uint256;

    /// Result of initialize.
    /// @param sender `msg.sender` of the initialize.
    /// @param erc20 erc20 to transfer.
    event Initialize(
        address sender,
        address erc20
    );

    /// The erc20 to transfer balances of.
    IERC20 internal erc20;

    /// @param config_ Constructor config.
    function initialize(ERC20TransferTierConfig memory config_)
        external
        initializer
    {
        initializeValueTier(config_.tierValues);
        erc20 = config_.erc20;
        emit Initialize(msg.sender, address(config_.erc20));
    }

    /// Transfers balances of erc20 from/to the tiered account according to the
    /// difference in values. Any failure to transfer in/out will rollback the
    /// tier change. The tiered account must ensure sufficient approvals before
    /// attempting to set a new tier.
    /// The `msg.sender` is responsible for paying the token cost of a tier
    /// increase.
    /// The tiered account is always the recipient of a refund on a tier
    /// decrease.
    /// @inheritdoc ReadWriteTier
    function _afterSetTier(
        address account_,
        uint256 startTier_,
        uint256 endTier_,
        bytes memory
    ) internal override {
        // As _anyone_ can call `setTier` we require that `msg.sender` and
        // `account_` are the same if the end tier is not an improvement.
        // Anyone can increase anyone else's tier as the `msg.sender` is
        // responsible to pay the difference.
        if (endTier_ <= startTier_) {
            require(msg.sender == account_, "DELEGATED_TIER_LOSS");
        }

        uint256[8] memory tierValues_ = tierValues();

        // Handle the erc20 transfer.
        // Convert the start tier to an erc20 amount.
        uint256 startValue_ = tierToValue(tierValues_, startTier_);
        // Convert the end tier to an erc20 amount.
        uint256 endValue_ = tierToValue(tierValues_, endTier_);

        // Short circuit if the values are the same for both tiers.
        if (endValue_ == startValue_) {
            return;
        }
        if (endValue_ > startValue_) {
            // Going up, take ownership of erc20 from the `msg.sender`.
            erc20.safeTransferFrom(
                msg.sender,
                address(this),
                endValue_.saturatingSub(startValue_)
            );
        } else {
            // Going down, process a refund for the tiered account.
            erc20.safeTransfer(account_, startValue_.saturatingSub(endValue_));
        }
    }
}

File 2 of 13 : SaturatingMath.sol
// SPDX-License-Identifier: CAL
pragma solidity ^0.8.10;

/// @title SaturatingMath
/// @notice Sometimes we neither want math operations to error nor wrap around
/// on an overflow or underflow. In the case of transferring assets an error
/// may cause assets to be locked in an irretrievable state within the erroring
/// contract, e.g. due to a tiny rounding/calculation error. We also can't have
/// assets underflowing and attempting to approve/transfer "infinity" when we
/// wanted "almost or exactly zero" but some calculation bug underflowed zero.
/// Ideally there are no calculation mistakes, but in guarding against bugs it
/// may be safer pragmatically to saturate arithmatic at the numeric bounds.
/// Note that saturating div is not supported because 0/0 is undefined.
library SaturatingMath {
    /// Saturating addition.
    /// @param a_ First term.
    /// @param b_ Second term.
    /// @return Minimum of a_ + b_ and max uint256.
    function saturatingAdd(uint256 a_, uint256 b_)
        internal
        pure
        returns (uint256)
    {
        unchecked {
            uint256 c_ = a_ + b_;
            return c_ < a_ ? type(uint256).max : c_;
        }
    }

    /// Saturating subtraction.
    /// @param a_ Minuend.
    /// @param b_ Subtrahend.
    /// @return a_ - b_ if a_ greater than b_, else 0.
    function saturatingSub(uint256 a_, uint256 b_)
        internal
        pure
        returns (uint256)
    {
        unchecked {
            return a_ > b_ ? a_ - b_ : 0;
        }
    }

    /// Saturating multiplication.
    /// @param a_ First term.
    /// @param b_ Second term.
    /// @return Minimum of a_ * b_ and max uint256.
    function saturatingMul(uint256 a_, uint256 b_)
        internal
        pure
        returns (uint256)
    {
        unchecked {
            // Gas optimization: this is cheaper than requiring 'a' not being
            // zero, but the benefit is lost if 'b' is also tested.
            // https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
            if (a_ == 0) return 0;
            uint256 c_ = a_ * b_;
            return c_ / a_ != b_ ? type(uint256).max : c_;
        }
    }
}

File 3 of 13 : TierReport.sol
// SPDX-License-Identifier: CAL
pragma solidity ^0.8.10;

import {ITier} from "../ITier.sol";
import "./TierConstants.sol";

/// @title TierReport
/// @notice `TierReport` implements several pure functions that can be
/// used to interface with reports.
/// - `tierAtBlockFromReport`: Returns the highest status achieved relative to
/// a block number and report. Statuses gained after that block are ignored.
/// - `tierBlock`: Returns the block that a given tier has been held
/// since according to a report.
/// - `truncateTiersAbove`: Resets all the tiers above the reference tier.
/// - `updateBlocksForTierRange`: Updates a report with a block
/// number for every tier in a range.
/// - `updateReportWithTierAtBlock`: Updates a report to a new tier.
/// @dev Utilities to consistently read, write and manipulate tiers in reports.
/// The low-level bit shifting can be difficult to get right so this
/// factors that out.
library TierReport {
    /// Enforce upper limit on tiers so we can do unchecked math.
    modifier maxTier(uint256 tier_) {
        require(tier_ <= TierConstants.MAX_TIER, "MAX_TIER");
        _;
    }

    /// Returns the highest tier achieved relative to a block number
    /// and report.
    ///
    /// Note that typically the report will be from the _current_ contract
    /// state, i.e. `block.number` but not always. Tiers gained after the
    /// reference block are ignored.
    ///
    /// When the `report` comes from a later block than the `blockNumber` this
    /// means the user must have held the tier continuously from `blockNumber`
    /// _through_ to the report block.
    /// I.e. NOT a snapshot.
    ///
    /// @param report_ A report as per `ITier`.
    /// @param blockNumber_ The block number to check the tiers against.
    /// @return The highest tier held since `blockNumber` as per `report`.
    function tierAtBlockFromReport(uint256 report_, uint256 blockNumber_)
        internal
        pure
        returns (uint256)
    {
        unchecked {
            for (uint256 i_ = 0; i_ < 8; i_++) {
                if (uint32(uint256(report_ >> (i_ * 32))) > blockNumber_) {
                    return i_;
                }
            }
            return TierConstants.MAX_TIER;
        }
    }

    /// Returns the block that a given tier has been held since from a report.
    ///
    /// The report MUST encode "never" as 0xFFFFFFFF. This ensures
    /// compatibility with `tierAtBlockFromReport`.
    ///
    /// @param report_ The report to read a block number from.
    /// @param tier_ The Tier to read the block number for.
    /// @return The block number this has been held since.
    function tierBlock(uint256 report_, uint256 tier_)
        internal
        pure
        maxTier(tier_)
        returns (uint256)
    {
        unchecked {
            // ZERO is a special case. Everyone has always been at least ZERO,
            // since block 0.
            if (tier_ == 0) {
                return 0;
            }

            uint256 offset_ = (tier_ - 1) * 32;
            return uint256(uint32(uint256(report_ >> offset_)));
        }
    }

    /// Resets all the tiers above the reference tier to 0xFFFFFFFF.
    ///
    /// @param report_ Report to truncate with high bit 1s.
    /// @param tier_ Tier to truncate above (exclusive).
    /// @return Truncated report.
    function truncateTiersAbove(uint256 report_, uint256 tier_)
        internal
        pure
        maxTier(tier_)
        returns (uint256)
    {
        unchecked {
            uint256 offset_ = tier_ * 32;
            uint256 mask_ = (TierConstants.NEVER_REPORT >> offset_) << offset_;
            return report_ | mask_;
        }
    }

    /// Updates a report with a block number for a given tier.
    /// More gas efficient than `updateBlocksForTierRange` if only a single
    /// tier is being modified.
    /// The tier at/above the given tier is updated. E.g. tier `0` will update
    /// the block for tier `1`.
    function updateBlockAtTier(
        uint256 report_,
        uint256 tier_,
        uint256 blockNumber_
    ) internal pure maxTier(tier_) returns (uint256) {
        unchecked {
            uint256 offset_ = tier_ * 32;
            return
                (report_ &
                    ~uint256(uint256(TierConstants.NEVER_TIER) << offset_)) |
                uint256(blockNumber_ << offset_);
        }
    }

    /// Updates a report with a block number for every tier in a range.
    ///
    /// Does nothing if the end status is equal or less than the start tier.
    /// @param report_ The report to update.
    /// @param startTier_ The tier at the start of the range (exclusive).
    /// @param endTier_ The tier at the end of the range (inclusive).
    /// @param blockNumber_ The block number to set for every tier in the
    /// range.
    /// @return The updated report.
    function updateBlocksForTierRange(
        uint256 report_,
        uint256 startTier_,
        uint256 endTier_,
        uint256 blockNumber_
    ) internal pure maxTier(startTier_) maxTier(endTier_) returns (uint256) {
        unchecked {
            uint256 offset_;
            for (uint256 i_ = startTier_; i_ < endTier_; i_++) {
                offset_ = i_ * 32;
                report_ =
                    (report_ &
                        ~uint256(
                            uint256(TierConstants.NEVER_TIER) << offset_
                        )) |
                    uint256(blockNumber_ << offset_);
            }
            return report_;
        }
    }

    /// Updates a report to a new status.
    ///
    /// Internally dispatches to `truncateTiersAbove` and
    /// `updateBlocksForTierRange`.
    /// The dispatch is based on whether the new tier is above or below the
    /// current tier.
    /// The `startTier_` MUST match the result of `tierAtBlockFromReport`.
    /// It is expected the caller will know the current tier when
    /// calling this function and need to do other things in the calling scope
    /// with it.
    ///
    /// @param report_ The report to update.
    /// @param startTier_ The tier to start updating relative to. Data above
    /// this tier WILL BE LOST so probably should be the current tier.
    /// @param endTier_ The new highest tier held, at the given block number.
    /// @param blockNumber_ The block number to update the highest tier to, and
    /// intermediate tiers from `startTier_`.
    /// @return The updated report.
    function updateReportWithTierAtBlock(
        uint256 report_,
        uint256 startTier_,
        uint256 endTier_,
        uint256 blockNumber_
    ) internal pure returns (uint256) {
        return
            endTier_ < startTier_
                ? truncateTiersAbove(report_, endTier_)
                : updateBlocksForTierRange(
                    report_,
                    startTier_,
                    endTier_,
                    blockNumber_
                );
    }
}

File 4 of 13 : ITier.sol
// SPDX-License-Identifier: CAL
pragma solidity ^0.8.10;

/// @title ITier
/// @notice `ITier` is a simple interface that contracts can
/// implement to provide membership lists for other contracts.
///
/// There are many use-cases for a time-preserving conditional membership list.
///
/// Some examples include:
///
/// - Self-serve whitelist to participate in fundraising
/// - Lists of users who can claim airdrops and perks
/// - Pooling resources with implied governance/reward tiers
/// - POAP style attendance proofs allowing access to future exclusive events
///
/// @dev Standard interface to a tiered membership.
///
/// A "membership" can represent many things:
/// - Exclusive access.
/// - Participation in some event or process.
/// - KYC completion.
/// - Combination of sub-memberships.
/// - Etc.
///
/// The high level requirements for a contract implementing `ITier`:
/// - MUST represent held tiers as a `uint`.
/// - MUST implement `report`.
///   - The report is a `uint256` that SHOULD represent the block each tier has
///     been continuously held since encoded as `uint32`.
///   - The encoded tiers start at `1`; Tier `0` is implied if no tier has ever
///     been held.
///   - Tier `0` is NOT encoded in the report, it is simply the fallback value.
///   - If a tier is lost the block data is erased for that tier and will be
///     set if/when the tier is regained to the new block.
///   - If the historical block information is not available the report MAY
///     return `0x00000000` for all held tiers.
///   - Tiers that are lost or have never been held MUST return `0xFFFFFFFF`.
/// - SHOULD implement `setTier`.
///   - Contracts SHOULD revert with `SET_TIER` error if they cannot
///     meaningfully set a tier directly.
///     For example a contract that can only derive a membership tier by
///     reading the state of an external contract cannot set tiers.
///   - Contracts implementing `setTier` SHOULD error with `SET_ZERO_TIER`
///     if tier 0 is being set.
/// - MUST emit `TierChange` when `setTier` successfully writes a new tier.
///   - Contracts that cannot meaningfully set a tier are exempt.
interface ITier {
    /// Every time a tier changes we log start and end tier against the
    /// account.
    /// This MAY NOT be emitted if reports are being read from the state of an
    /// external contract.
    /// The start tier MAY be lower than the current tier as at the block this
    /// event is emitted in.
    /// @param sender The `msg.sender` that authorized the tier change.
    /// @param account The account changing tier.
    /// @param startTier The previous tier the account held.
    /// @param endTier The newly acquired tier the account now holds.
    event TierChange(
        address sender,
        address account,
        uint256 startTier,
        uint256 endTier
    );

    /// @notice Users can set their own tier by calling `setTier`.
    ///
    /// The contract that implements `ITier` is responsible for checking
    /// eligibility and/or taking actions required to set the tier.
    ///
    /// For example, the contract must take/refund any tokens relevant to
    /// changing the tier.
    ///
    /// Obviously the user is responsible for any approvals for this action
    /// prior to calling `setTier`.
    ///
    /// When the tier is changed a `TierChange` event will be emmited as:
    /// ```
    /// event TierChange(address account, uint startTier, uint endTier);
    /// ```
    ///
    /// The `setTier` function includes arbitrary data as the third
    /// parameter. This can be used to disambiguate in the case that
    /// there may be many possible options for a user to achieve some tier.
    ///
    /// For example, consider the case where tier 3 can be achieved
    /// by EITHER locking 1x rare NFT or 3x uncommon NFTs. A user with both
    /// could use `data` to explicitly state their intent.
    ///
    /// NOTE however that _any_ address can call `setTier` for any other
    /// address.
    ///
    /// If you implement `data` or anything that changes state then be very
    /// careful to avoid griefing attacks.
    ///
    /// The `data` parameter can also be ignored by the contract implementing
    /// `ITier`. For example, ERC20 tokens are fungible so only the balance
    /// approved by the user is relevant to a tier change.
    ///
    /// The `setTier` function SHOULD prevent users from reassigning
    /// tier 0 to themselves.
    ///
    /// The tier 0 status represents never having any status.
    /// @dev Updates the tier of an account.
    ///
    /// The implementing contract is responsible for all checks and state
    /// changes required to set the tier. For example, taking/refunding
    /// funds/NFTs etc.
    ///
    /// Contracts may disallow directly setting tiers, preferring to derive
    /// reports from other onchain data.
    /// In this case they should `revert("SET_TIER");`.
    ///
    /// @param account Account to change the tier for.
    /// @param endTier Tier after the change.
    /// @param data Arbitrary input to disambiguate ownership
    /// (e.g. NFTs to lock).
    function setTier(
        address account,
        uint256 endTier,
        bytes memory data
    ) external;

    /// @notice A tier report is a `uint256` that contains each of the block
    /// numbers each tier has been held continously since as a `uint32`.
    /// There are 9 possible tier, starting with tier 0 for `0` offset or
    /// "never held any tier" then working up through 8x 4 byte offsets to the
    /// full 256 bits.
    ///
    /// Low bits = Lower tier.
    ///
    /// In hexadecimal every 8 characters = one tier, starting at tier 8
    /// from high bits and working down to tier 1.
    ///
    /// `uint32` should be plenty for any blockchain that measures block times
    /// in seconds, but reconsider if deploying to an environment with
    /// significantly sub-second block times.
    ///
    /// ~135 years of 1 second blocks fit into `uint32`.
    ///
    /// `2^8 / (365 * 24 * 60 * 60)`
    ///
    /// When a user INCREASES their tier they keep all the block numbers they
    /// already had, and get new block times for each increased tiers they have
    /// earned.
    ///
    /// When a user DECREASES their tier they return to `0xFFFFFFFF` (never)
    /// for every tier level they remove, but keep their block numbers for the
    /// remaining tiers.
    ///
    /// GUIs are encouraged to make this dynamic very clear for users as
    /// round-tripping to a lower status and back is a DESTRUCTIVE operation
    /// for block times.
    ///
    /// The intent is that downstream code can provide additional benefits for
    /// members who have maintained a certain tier for/since a long time.
    /// These benefits can be provided by inspecting the report, and by
    /// on-chain contracts directly,
    /// rather than needing to work with snapshots etc.
    /// @dev Returns the earliest block the account has held each tier for
    /// continuously.
    /// This is encoded as a uint256 with blocks represented as 8x
    /// concatenated uint32.
    /// I.e. Each 4 bytes of the uint256 represents a u32 tier start time.
    /// The low bits represent low tiers and high bits the high tiers.
    /// Implementing contracts should return 0xFFFFFFFF for lost and
    /// never-held tiers.
    ///
    /// @param account Account to get the report for.
    /// @return The report blocks encoded as a uint256.
    function report(address account) external view returns (uint256);
}

File 5 of 13 : TierConstants.sol
// SPDX-License-Identifier: CAL
pragma solidity ^0.8.10;

/// @title TierConstants
/// @notice Constants for use with tier logic.
library TierConstants {
    /// NEVER is 0xFF.. as it is infinitely in the future.
    /// NEVER for an entire report.
    uint256 internal constant NEVER_REPORT = type(uint256).max;
    /// NEVER for a single tier.
    uint32 internal constant NEVER_TIER = type(uint32).max;

    /// Always is 0 as it is the genesis block.
    /// Tiers can't predate the chain but they can predate an `ITier` contract.
    uint256 internal constant ALWAYS = 0;

    /// Account has never held a tier.
    uint256 internal constant TIER_ZERO = 0;

    /// Magic number for tier one.
    uint256 internal constant TIER_ONE = 1;
    /// Magic number for tier two.
    uint256 internal constant TIER_TWO = 2;
    /// Magic number for tier three.
    uint256 internal constant TIER_THREE = 3;
    /// Magic number for tier four.
    uint256 internal constant TIER_FOUR = 4;
    /// Magic number for tier five.
    uint256 internal constant TIER_FIVE = 5;
    /// Magic number for tier six.
    uint256 internal constant TIER_SIX = 6;
    /// Magic number for tier seven.
    uint256 internal constant TIER_SEVEN = 7;
    /// Magic number for tier eight.
    uint256 internal constant TIER_EIGHT = 8;
    /// Maximum tier is `TIER_EIGHT`.
    uint256 internal constant MAX_TIER = TIER_EIGHT;
}

File 6 of 13 : ValueTier.sol
// SPDX-License-Identifier: CAL
pragma solidity ^0.8.10;

import {ITier} from "./ITier.sol";
import "./libraries/TierConstants.sol";

import "../sstore2/SSTORE2.sol";

/// @title ValueTier
///
/// @dev A contract that is `ValueTier` expects to derive tiers from explicit
/// values. For example an address must send or hold an amount of something to
/// reach a given tier.
/// Anything with predefined values that map to tiers can be a `ValueTier`.
///
/// Note that `ValueTier` does NOT implement `ITier`.
/// `ValueTier` does include state however, to track the `tierValues` so is not
/// a library.
contract ValueTier {
    /// TODO: Typescript errors on uint256[8] so can't include tierValues here.
    /// @param sender The `msg.sender` initializing value tier.
    /// @param pointer Pointer to the uint256[8] values.
    event InitializeValueTier(
        address sender,
        address pointer
    );

    /// Pointer to the uint256[8] values.
    address private tierValuesPointer;

    /// Set the `tierValues` on construction to be referenced immutably.
    function initializeValueTier(uint256[8] memory tierValues_) internal {
        // Reinitialization is a bug.
        assert(tierValuesPointer == address(0));
        address tierValuesPointer_ = SSTORE2.write(abi.encode(tierValues_));
        emit InitializeValueTier(msg.sender, tierValuesPointer_);
        tierValuesPointer = tierValuesPointer_;
    }

    /// Complements the default solidity accessor for `tierValues`.
    /// Returns all the values in a list rather than requiring an index be
    /// specified.
    /// @return tierValues_ The immutable `tierValues`.
    function tierValues() public view returns (uint256[8] memory tierValues_) {
        return abi.decode(SSTORE2.read(tierValuesPointer), (uint256[8]));
    }

    /// Converts a Tier to the minimum value it requires.
    /// tier 0 is always value 0 as it is the fallback.
    /// @param tier_ The Tier to convert to a value.
    function tierToValue(uint256[8] memory tierValues_, uint256 tier_)
        internal
        pure
        returns (uint256)
    {
        return tier_ > TierConstants.TIER_ZERO ? tierValues_[tier_ - 1] : 0;
    }

    /// Converts a value to the maximum Tier it qualifies for.
    /// @param value_ The value to convert to a tier.
    function valueToTier(uint256[8] memory tierValues_, uint256 value_)
        internal
        pure
        returns (uint256)
    {
        for (uint256 i_ = 0; i_ < TierConstants.MAX_TIER; i_++) {
            if (value_ < tierValues_[i_]) {
                return i_;
            }
        }
        return TierConstants.MAX_TIER;
    }
}

File 7 of 13 : SSTORE2.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;

import "./utils/Bytecode.sol";

/**
  @title A key-value storage with auto-generated keys for storing chunks of
  data with a lower write & read cost.
  @author Agustin Aguilar <[email protected]>

  Readme: https://github.com/0xsequence/sstore2#readme
*/
library SSTORE2 {
    error WriteError();

    /**
    @notice Stores `_data` and returns `pointer` as key for later retrieval
    @dev The pointer is a contract address with `_data` as code
    @param _data to be written
    @return pointer Pointer to the written `_data`
  */
    function write(bytes memory _data) internal returns (address pointer) {
        // Append 00 to _data so contract can't be called
        // Build init code
        bytes memory code = Bytecode.creationCodeFor(
            abi.encodePacked(hex"00", _data)
        );

        // Deploy contract using create
        assembly {
            pointer := create(0, add(code, 32), mload(code))
        }

        // Address MUST be non-zero
        if (pointer == address(0)) revert WriteError();
    }

    /**
    @notice Reads the contents of the `_pointer` code as data, skips the first
    byte
    @dev The function is intended for reading pointers generated by `write`
    @param _pointer to be read
    @return data read from `_pointer` contract
  */
    function read(address _pointer) internal view returns (bytes memory) {
        return Bytecode.codeAt(_pointer, 1, type(uint256).max);
    }

    /**
    @notice Reads the contents of the `_pointer` code as data, skips the first
    byte
    @dev The function is intended for reading pointers generated by `write`
    @param _pointer to be read
    @param _start number of bytes to skip
    @return data read from `_pointer` contract
  */
    function read(address _pointer, uint256 _start)
        internal
        view
        returns (bytes memory)
    {
        return Bytecode.codeAt(_pointer, _start + 1, type(uint256).max);
    }

    /**
    @notice Reads the contents of the `_pointer` code as data, skips the first
    byte
    @dev The function is intended for reading pointers generated by `write`
    @param _pointer to be read
    @param _start number of bytes to skip
    @param _end index before which to end extraction
    @return data read from `_pointer` contract
  */
    function read(
        address _pointer,
        uint256 _start,
        uint256 _end
    ) internal view returns (bytes memory) {
        return Bytecode.codeAt(_pointer, _start + 1, _end + 1);
    }
}

File 8 of 13 : Bytecode.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.10;

library Bytecode {
    error InvalidCodeAtRange(uint256 _size, uint256 _start, uint256 _end);

    /**
    @notice Generate a creation code that results on a contract with `_code` as
    bytecode
    @param _code The returning value of the resulting `creationCode`
    @return creationCode (constructor) for new contract
  */
    function creationCodeFor(bytes memory _code)
        internal
        pure
        returns (bytes memory)
    {
        /*
      0x00    0x63         0x63XXXXXX  PUSH4 _code.length  size
      0x01    0x80         0x80        DUP1                size size
      0x02    0x60         0x600e      PUSH1 14            14 size size
      0x03    0x60         0x6000      PUSH1 00            0 14 size size
      0x04    0x39         0x39        CODECOPY            size
      0x05    0x60         0x6000      PUSH1 00            0 size
      0x06    0xf3         0xf3        RETURN
      <CODE>
    */

        return
            abi.encodePacked(
                hex"63",
                uint32(_code.length),
                hex"80_60_0E_60_00_39_60_00_F3",
                _code
            );
    }

    /**
    @notice Returns the size of the code on a given address
    @param _addr Address that may or may not contain code
    @return size of the code on the given `_addr`
  */
    function codeSize(address _addr) internal view returns (uint256 size) {
        assembly {
            size := extcodesize(_addr)
        }
    }

    /**
    @notice Returns the code of a given address
    @dev It will fail if `_end < _start`
    @param _addr Address that may or may not contain code
    @param _start number of bytes of code to skip on read
    @param _end index before which to end extraction
    @return oCode read from `_addr` deployed bytecode

    Forked: https://gist.github.com/KardanovIR/fe98661df9338c842b4a30306d507fbd
  */
    function codeAt(
        address _addr,
        uint256 _start,
        uint256 _end
    ) internal view returns (bytes memory oCode) {
        uint256 csize = codeSize(_addr);
        if (csize == 0) return bytes("");

        if (_start > csize) return bytes("");
        if (_end < _start) revert InvalidCodeAtRange(csize, _start, _end);

        unchecked {
            uint256 reqSize = _end - _start;
            uint256 maxSize = csize - _start;

            uint256 size = maxSize < reqSize ? maxSize : reqSize;

            assembly {
                // allocate output byte array - this could also be done without
                // assembly
                // by using o_code = new bytes(size)
                oCode := mload(0x40)
                // new "memory end" including padding
                mstore(
                    0x40,
                    add(oCode, and(add(add(size, 0x20), 0x1f), not(0x1f)))
                )
                // store length in memory
                mstore(oCode, size)
                // actually retrieve the code, this needs assembly
                extcodecopy(_addr, add(oCode, 0x20), _start, size)
            }
        }
    }
}

File 9 of 13 : ReadWriteTier.sol
// SPDX-License-Identifier: CAL
pragma solidity ^0.8.10;

import {ITier} from "./ITier.sol";
import "./libraries/TierConstants.sol";
import "./libraries/TierReport.sol";

/// @title ReadWriteTier
/// @notice `ReadWriteTier` is a base contract that other contracts are
/// expected to inherit.
///
/// It handles all the internal accounting and state changes for `report`
/// and `setTier`.
///
/// It calls an `_afterSetTier` hook that inheriting contracts can override to
/// enforce tier requirements.
///
/// @dev ReadWriteTier can `setTier` in addition to generating reports.
/// When `setTier` is called it automatically sets the current blocks in the
/// report for the new tiers. Lost tiers are scrubbed from the report as tiered
/// addresses move down the tiers.
contract ReadWriteTier is ITier {
    /// account => reports
    mapping(address => uint256) private reports;

    /// Either fetch the report from storage or return UNINITIALIZED.
    /// @inheritdoc ITier
    function report(address account_)
        public
        view
        virtual
        override
        returns (uint256)
    {
        // Inequality here to silence slither warnings.
        return
            reports[account_] > 0
                ? reports[account_]
                : TierConstants.NEVER_REPORT;
    }

    /// Errors if the user attempts to return to the ZERO tier.
    /// Updates the report from `report` using default `TierReport` logic.
    /// Calls `_afterSetTier` that inheriting contracts SHOULD
    /// override to enforce status requirements.
    /// Emits `TierChange` event.
    /// @inheritdoc ITier
    function setTier(
        address account_,
        uint256 endTier_,
        bytes memory data_
    ) external virtual override {
        // The user must move to at least tier 1.
        // The tier 0 status is reserved for users that have never
        // interacted with the contract.
        require(endTier_ > 0, "SET_ZERO_TIER");

        uint256 report_ = report(account_);

        uint256 startTier_ = TierReport.tierAtBlockFromReport(
            report_,
            block.number
        );

        reports[account_] = TierReport.updateReportWithTierAtBlock(
            report_,
            startTier_,
            endTier_,
            block.number
        );

        // Emit this event for ITier.
        emit TierChange(msg.sender, account_, startTier_, endTier_);

        // Call the `_afterSetTier` hook to allow inheriting contracts
        // to enforce requirements.
        // The inheriting contract MUST `require` or otherwise
        // enforce its needs to rollback a bad status change.
        _afterSetTier(account_, startTier_, endTier_, data_);
    }

    /// Inheriting contracts SHOULD override this to enforce requirements.
    ///
    /// All the internal accounting and state changes are complete at
    /// this point.
    /// Use `require` to enforce additional requirements for tier changes.
    ///
    /// @param account_ The account with the new tier.
    /// @param startTier_ The tier the account had before this update.
    /// @param endTier_ The tier the account will have after this update.
    /// @param data_ Additional arbitrary data to inform update requirements.
    function _afterSetTier(
        address account_,
        uint256 startTier_,
        uint256 endTier_,
        bytes memory data_
    ) internal virtual {} // solhint-disable-line no-empty-blocks
}

File 10 of 13 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.0;

import "../../utils/Address.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the
 * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() initializer {}
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the
        // contract may have been reentered.
        require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} modifier, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    function _isConstructor() private view returns (bool) {
        return !Address.isContract(address(this));
    }
}

File 11 of 13 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

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

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

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

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

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

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

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

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

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

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

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

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

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 12 of 13 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

File 13 of 13 : SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

Contract ABI

[{"inputs":[{"internalType":"uint256","name":"_size","type":"uint256"},{"internalType":"uint256","name":"_start","type":"uint256"},{"internalType":"uint256","name":"_end","type":"uint256"}],"name":"InvalidCodeAtRange","type":"error"},{"inputs":[],"name":"WriteError","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"address","name":"erc20","type":"address"}],"name":"Initialize","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"address","name":"pointer","type":"address"}],"name":"InitializeValueTier","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"sender","type":"address"},{"indexed":false,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"uint256","name":"startTier","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endTier","type":"uint256"}],"name":"TierChange","type":"event"},{"inputs":[{"components":[{"internalType":"contract IERC20","name":"erc20","type":"address"},{"internalType":"uint256[8]","name":"tierValues","type":"uint256[8]"}],"internalType":"struct ERC20TransferTierConfig","name":"config_","type":"tuple"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account_","type":"address"}],"name":"report","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account_","type":"address"},{"internalType":"uint256","name":"endTier_","type":"uint256"},{"internalType":"bytes","name":"data_","type":"bytes"}],"name":"setTier","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"tierValues","outputs":[{"internalType":"uint256[8]","name":"tierValues_","type":"uint256[8]"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b50611475806100206000396000f3fe608060405234801561001057600080fd5b506004361061004c5760003560e01c806370230b39146100515780638a200fff1461006f578063a61e331514610084578063e053ea3114610097575b600080fd5b6100596100b8565b6040516100669190610f41565b60405180910390f35b61008261007d366004611040565b6100fa565b005b61008261009236600461110f565b610213565b6100aa6100a53660046111ad565b610410565b604051908152602001610066565b6100c0610f22565b6001546100e29073ffffffffffffffffffffffffffffffffffffffff1661048d565b8060200190518101906100f591906111ca565b905090565b60008211610169576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600d60248201527f5345545f5a45524f5f544945520000000000000000000000000000000000000060448201526064015b60405180910390fd5b600061017484610410565b9050600061018282436104bb565b9050610190828286436104f5565b73ffffffffffffffffffffffffffffffffffffffff861660008181526020818152604091829020939093558051338152928301919091528101829052606081018590527f100c93640a44fd8835d3652fa703bca54387aca4142e2cab319fb66cd80e3c9c9060800160405180910390a161020c85828686610522565b5050505050565b6001547501000000000000000000000000000000000000000000900460ff1661025a5760015474010000000000000000000000000000000000000000900460ff161561025e565b303b155b6102ea576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610160565b6001547501000000000000000000000000000000000000000000900460ff1615801561035157600180547fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff1675010100000000000000000000000000000000000000001790555b61035e8260200151610655565b8151600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff90921691821790556040805133815260208101929092527fdc90fed0326ba91706deeac7eb34ac9f8b680734f9d782864dc29704d23bed6a910160405180910390a1801561040c57600180547fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff1690555b5050565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260208190526040812054610460577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610487565b73ffffffffffffffffffffffffffffffffffffffff82166000908152602081905260409020545b92915050565b60606104878260017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61073e565b6000805b60088110156104eb57828160200285901c63ffffffff1611156104e3579050610487565b6001016104bf565b5060089392505050565b600083831061050f5761050a85858585610827565b610519565b610519858461093a565b95945050505050565b8282116105a8573373ffffffffffffffffffffffffffffffffffffffff8516146105a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f44454c4547415445445f544945525f4c4f5353000000000000000000000000006044820152606401610160565b60006105b26100b8565b905060006105c082866109da565b905060006105ce83866109da565b9050818114156105e05750505061064f565b8181111561061d5761061833306105f78486610a12565b60025473ffffffffffffffffffffffffffffffffffffffff16929190610a28565b61064b565b61064b8761062b8484610a12565b60025473ffffffffffffffffffffffffffffffffffffffff169190610b04565b5050505b50505050565b60015473ffffffffffffffffffffffffffffffffffffffff161561067b5761067b61122b565b60006106a5826040516020016106919190610f41565b604051602081830303815290604052610b5f565b6040805133815273ffffffffffffffffffffffffffffffffffffffff831660208201529192507f18ebb958e85030233374c8eb79c1a72ee418770db7fb47a7de05d30c868ec958910160405180910390a1600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060833b8061075d575050604080516020810190915260008152610820565b8084111561077b575050604080516020810190915260008152610820565b838310156107c6576040517f2c4a89fa000000000000000000000000000000000000000000000000000000008152600481018290526024810185905260448101849052606401610160565b83830384820360008282106107db57826107dd565b815b60408051603f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168101909152818152955090508087602087018a3c505050505b9392505050565b6000836008811115610895576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600860248201527f4d41585f544945520000000000000000000000000000000000000000000000006044820152606401610160565b836008811115610901576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600860248201527f4d41585f544945520000000000000000000000000000000000000000000000006044820152606401610160565b6000865b8681101561092d5763ffffffff6020820290811b1999909916868a1b17989150600101610905565b5096979650505050505050565b60008160088111156109a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600860248201527f4d41585f544945520000000000000000000000000000000000000000000000006044820152606401610160565b50507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60209190910290811c901b1790565b60008082116109ea576000610820565b826109f660018461125a565b60088110610a0657610a06611298565b60200201519392505050565b6000818311610a22576000610820565b50900390565b60405173ffffffffffffffffffffffffffffffffffffffff8085166024830152831660448201526064810182905261064f9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152610bea565b60405173ffffffffffffffffffffffffffffffffffffffff8316602482015260448101829052610b5a9084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401610a82565b505050565b600080610b8a83604051602001610b7691906112f3565b604051602081830303815290604052610cf6565b90508051602082016000f0915073ffffffffffffffffffffffffffffffffffffffff8216610be4576040517f08d4abb600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50919050565b6000610c4c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16610d229092919063ffffffff16565b805190915015610b5a5780806020019051810190610c6a9190611319565b610b5a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610160565b6060815182604051602001610d0c92919061133b565b6040516020818303038152906040529050919050565b6060610d318484600085610d39565b949350505050565b606082471015610dcb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610160565b73ffffffffffffffffffffffffffffffffffffffff85163b610e49576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610160565b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051610e7291906113d2565b60006040518083038185875af1925050503d8060008114610eaf576040519150601f19603f3d011682016040523d82523d6000602084013e610eb4565b606091505b5091509150610ec4828286610ecf565b979650505050505050565b60608315610ede575081610820565b825115610eee5782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161016091906113ee565b6040518061010001604052806008906020820280368337509192915050565b6101008101818360005b6008811015610f6a578151835260209283019290910190600101610f4b565b50505092915050565b73ffffffffffffffffffffffffffffffffffffffff81168114610f9557600080fd5b50565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051610100810167ffffffffffffffff81118282101715610feb57610feb610f98565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff8111828210171561103857611038610f98565b604052919050565b60008060006060848603121561105557600080fd5b833561106081610f73565b92506020848101359250604085013567ffffffffffffffff8082111561108557600080fd5b818701915087601f83011261109957600080fd5b8135818111156110ab576110ab610f98565b6110db847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601610ff1565b915080825288848285010111156110f157600080fd5b80848401858401376000848284010152508093505050509250925092565b600061012080838503121561112357600080fd5b6040516040810181811067ffffffffffffffff8211171561114657611146610f98565b604052833561115481610f73565b81526020603f8501861361116757600080fd5b61116f610fc7565b92850192808785111561118157600080fd5b8287015b8581101561119c5780358352918301918301611185565b509183019190915250949350505050565b6000602082840312156111bf57600080fd5b813561082081610f73565b60006101008083850312156111de57600080fd5b83601f8401126111ed57600080fd5b6111f5610fc7565b90830190808583111561120757600080fd5b845b83811015611221578051835260209283019201611209565b5095945050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b600082821015611293577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b500390565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60005b838110156112e25781810151838201526020016112ca565b8381111561064f5750506000910152565b600081526000825161130c8160018501602087016112c7565b9190910160010192915050565b60006020828403121561132b57600080fd5b8151801515811461082057600080fd5b7f630000000000000000000000000000000000000000000000000000000000000081527fffffffff000000000000000000000000000000000000000000000000000000008360e01b1660018201527f80600e6000396000f300000000000000000000000000000000000000000000006005820152600082516113c481600e8501602087016112c7565b91909101600e019392505050565b600082516113e48184602087016112c7565b9190910192915050565b602081526000825180602084015261140d8160408501602087016112c7565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fea264697066735822122073be69a568d4b1e5068b5a1fe26b965763d072c618d04fe69469b56e13ca016364736f6c634300080a0033

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061004c5760003560e01c806370230b39146100515780638a200fff1461006f578063a61e331514610084578063e053ea3114610097575b600080fd5b6100596100b8565b6040516100669190610f41565b60405180910390f35b61008261007d366004611040565b6100fa565b005b61008261009236600461110f565b610213565b6100aa6100a53660046111ad565b610410565b604051908152602001610066565b6100c0610f22565b6001546100e29073ffffffffffffffffffffffffffffffffffffffff1661048d565b8060200190518101906100f591906111ca565b905090565b60008211610169576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600d60248201527f5345545f5a45524f5f544945520000000000000000000000000000000000000060448201526064015b60405180910390fd5b600061017484610410565b9050600061018282436104bb565b9050610190828286436104f5565b73ffffffffffffffffffffffffffffffffffffffff861660008181526020818152604091829020939093558051338152928301919091528101829052606081018590527f100c93640a44fd8835d3652fa703bca54387aca4142e2cab319fb66cd80e3c9c9060800160405180910390a161020c85828686610522565b5050505050565b6001547501000000000000000000000000000000000000000000900460ff1661025a5760015474010000000000000000000000000000000000000000900460ff161561025e565b303b155b6102ea576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610160565b6001547501000000000000000000000000000000000000000000900460ff1615801561035157600180547fffffffffffffffffffff0000ffffffffffffffffffffffffffffffffffffffff1675010100000000000000000000000000000000000000001790555b61035e8260200151610655565b8151600280547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff90921691821790556040805133815260208101929092527fdc90fed0326ba91706deeac7eb34ac9f8b680734f9d782864dc29704d23bed6a910160405180910390a1801561040c57600180547fffffffffffffffffffff00ffffffffffffffffffffffffffffffffffffffffff1690555b5050565b73ffffffffffffffffffffffffffffffffffffffff8116600090815260208190526040812054610460577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff610487565b73ffffffffffffffffffffffffffffffffffffffff82166000908152602081905260409020545b92915050565b60606104878260017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff61073e565b6000805b60088110156104eb57828160200285901c63ffffffff1611156104e3579050610487565b6001016104bf565b5060089392505050565b600083831061050f5761050a85858585610827565b610519565b610519858461093a565b95945050505050565b8282116105a8573373ffffffffffffffffffffffffffffffffffffffff8516146105a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601360248201527f44454c4547415445445f544945525f4c4f5353000000000000000000000000006044820152606401610160565b60006105b26100b8565b905060006105c082866109da565b905060006105ce83866109da565b9050818114156105e05750505061064f565b8181111561061d5761061833306105f78486610a12565b60025473ffffffffffffffffffffffffffffffffffffffff16929190610a28565b61064b565b61064b8761062b8484610a12565b60025473ffffffffffffffffffffffffffffffffffffffff169190610b04565b5050505b50505050565b60015473ffffffffffffffffffffffffffffffffffffffff161561067b5761067b61122b565b60006106a5826040516020016106919190610f41565b604051602081830303815290604052610b5f565b6040805133815273ffffffffffffffffffffffffffffffffffffffff831660208201529192507f18ebb958e85030233374c8eb79c1a72ee418770db7fb47a7de05d30c868ec958910160405180910390a1600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff9290921691909117905550565b6060833b8061075d575050604080516020810190915260008152610820565b8084111561077b575050604080516020810190915260008152610820565b838310156107c6576040517f2c4a89fa000000000000000000000000000000000000000000000000000000008152600481018290526024810185905260448101849052606401610160565b83830384820360008282106107db57826107dd565b815b60408051603f83017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0168101909152818152955090508087602087018a3c505050505b9392505050565b6000836008811115610895576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600860248201527f4d41585f544945520000000000000000000000000000000000000000000000006044820152606401610160565b836008811115610901576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600860248201527f4d41585f544945520000000000000000000000000000000000000000000000006044820152606401610160565b6000865b8681101561092d5763ffffffff6020820290811b1999909916868a1b17989150600101610905565b5096979650505050505050565b60008160088111156109a8576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600860248201527f4d41585f544945520000000000000000000000000000000000000000000000006044820152606401610160565b50507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60209190910290811c901b1790565b60008082116109ea576000610820565b826109f660018461125a565b60088110610a0657610a06611298565b60200201519392505050565b6000818311610a22576000610820565b50900390565b60405173ffffffffffffffffffffffffffffffffffffffff8085166024830152831660448201526064810182905261064f9085907f23b872dd00000000000000000000000000000000000000000000000000000000906084015b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08184030181529190526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167fffffffff0000000000000000000000000000000000000000000000000000000090931692909217909152610bea565b60405173ffffffffffffffffffffffffffffffffffffffff8316602482015260448101829052610b5a9084907fa9059cbb0000000000000000000000000000000000000000000000000000000090606401610a82565b505050565b600080610b8a83604051602001610b7691906112f3565b604051602081830303815290604052610cf6565b90508051602082016000f0915073ffffffffffffffffffffffffffffffffffffffff8216610be4576040517f08d4abb600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b50919050565b6000610c4c826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff16610d229092919063ffffffff16565b805190915015610b5a5780806020019051810190610c6a9190611319565b610b5a576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610160565b6060815182604051602001610d0c92919061133b565b6040516020818303038152906040529050919050565b6060610d318484600085610d39565b949350505050565b606082471015610dcb576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610160565b73ffffffffffffffffffffffffffffffffffffffff85163b610e49576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610160565b6000808673ffffffffffffffffffffffffffffffffffffffff168587604051610e7291906113d2565b60006040518083038185875af1925050503d8060008114610eaf576040519150601f19603f3d011682016040523d82523d6000602084013e610eb4565b606091505b5091509150610ec4828286610ecf565b979650505050505050565b60608315610ede575081610820565b825115610eee5782518084602001fd5b816040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161016091906113ee565b6040518061010001604052806008906020820280368337509192915050565b6101008101818360005b6008811015610f6a578151835260209283019290910190600101610f4b565b50505092915050565b73ffffffffffffffffffffffffffffffffffffffff81168114610f9557600080fd5b50565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051610100810167ffffffffffffffff81118282101715610feb57610feb610f98565b60405290565b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff8111828210171561103857611038610f98565b604052919050565b60008060006060848603121561105557600080fd5b833561106081610f73565b92506020848101359250604085013567ffffffffffffffff8082111561108557600080fd5b818701915087601f83011261109957600080fd5b8135818111156110ab576110ab610f98565b6110db847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f84011601610ff1565b915080825288848285010111156110f157600080fd5b80848401858401376000848284010152508093505050509250925092565b600061012080838503121561112357600080fd5b6040516040810181811067ffffffffffffffff8211171561114657611146610f98565b604052833561115481610f73565b81526020603f8501861361116757600080fd5b61116f610fc7565b92850192808785111561118157600080fd5b8287015b8581101561119c5780358352918301918301611185565b509183019190915250949350505050565b6000602082840312156111bf57600080fd5b813561082081610f73565b60006101008083850312156111de57600080fd5b83601f8401126111ed57600080fd5b6111f5610fc7565b90830190808583111561120757600080fd5b845b83811015611221578051835260209283019201611209565b5095945050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052600160045260246000fd5b600082821015611293577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b500390565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60005b838110156112e25781810151838201526020016112ca565b8381111561064f5750506000910152565b600081526000825161130c8160018501602087016112c7565b9190910160010192915050565b60006020828403121561132b57600080fd5b8151801515811461082057600080fd5b7f630000000000000000000000000000000000000000000000000000000000000081527fffffffff000000000000000000000000000000000000000000000000000000008360e01b1660018201527f80600e6000396000f300000000000000000000000000000000000000000000006005820152600082516113c481600e8501602087016112c7565b91909101600e019392505050565b600082516113e48184602087016112c7565b9190910192915050565b602081526000825180602084015261140d8160408501602087016112c7565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016919091016040019291505056fea264697066735822122073be69a568d4b1e5068b5a1fe26b965763d072c618d04fe69469b56e13ca016364736f6c634300080a0033

Deployed Bytecode Sourcemap

2546:2674:7:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1649:155:10;;;:::i;:::-;;;;;;;:::i;:::-;;;;;;;;1619:1083:9;;;;;;:::i;:::-;;:::i;:::-;;3007:249:7;;;;;;:::i;:::-;;:::i;983:319:9:-;;;;;;:::i;:::-;;:::i;:::-;;;3914:25:13;;;3902:2;3887:18;983:319:9;3768:177:13;1649:155:10;1692:29;;:::i;:::-;1764:17;;1751:31;;1764:17;;1751:12;:31::i;:::-;1740:57;;;;;;;;;;;;:::i;:::-;1733:64;;1649:155;:::o;1619:1083:9:-;1935:1;1924:8;:12;1916:38;;;;;;;4779:2:13;1916:38:9;;;4761:21:13;4818:2;4798:18;;;4791:30;4857:15;4837:18;;;4830:43;4890:18;;1916:38:9;;;;;;;;;1965:15;1983:16;1990:8;1983:6;:16::i;:::-;1965:34;;2010:18;2031:89;2077:7;2098:12;2031:32;:89::i;:::-;2010:110;;2151:141;2203:7;2224:10;2248:8;2270:12;2151:38;:141::i;:::-;2131:17;;;:7;:17;;;;;;;;;;;;:161;;;;2346:54;;2357:10;5211:34:13;;5261:18;;;5254:43;;;;5313:18;;5306:34;;;5371:2;5356:18;;5349:34;;;2346:54:9;;5137:3:13;5122:19;2346:54:9;;;;;;;2643:52;2657:8;2667:10;2679:8;2689:5;2643:13;:52::i;:::-;1748:954;;1619:1083;;;:::o;3007:249:7:-;2358:13:0;;;;;;;:48;;2394:12;;;;;;;2393:13;2358:48;;;3125:4;1465:19:3;:23;2374:16:0;2350:107;;;;;;;5596:2:13;2350:107:0;;;5578:21:13;5635:2;5615:18;;;5608:30;5674:34;5654:18;;;5647:62;5745:16;5725:18;;;5718:44;5779:19;;2350:107:0;5394:410:13;2350:107:0;2491:13;;;;;;;2490:14;2514:98;;;;2564:4;2548:20;;2582:19;;;;;;2514:98;3118:39:7::1;3138:7;:18;;;3118:19;:39::i;:::-;3175:13:::0;;3167:5:::1;:21:::0;;;::::1;;::::0;;::::1;::::0;;::::1;::::0;;3203:46:::1;::::0;;3214:10:::1;6044:34:13::0;;6109:2;6094:18;;6087:43;;;;3203:46:7::1;::::0;5956:18:13;3203:46:7::1;;;;;;;2638:14:0::0;2634:66;;;2668:13;:21;;;;;;2634:66;2069:637;3007:249:7;:::o;983:319:9:-;1193:17;;;1095:7;1193:17;;;;;;;;;;;:102;;294:17:11;1193:102:9;;;1233:17;;;:7;:17;;;;;;;;;;;1193:102;1174:121;983:319;-1:-1:-1;;983:319:9:o;1349:140:5:-;1404:12;1435:47;1451:8;1461:1;1464:17;1435:15;:47::i;1859:398:12:-;1976:7;;2023:175;2049:1;2044:2;:6;2023:175;;;2120:12;2107:2;2112;2107:7;2095;:20;;2080:52;;;2076:108;;;2163:2;-1:-1:-1;2156:9:12;;2076:108;2052:4;;2023:175;;;-1:-1:-1;1308:1:11;;1859:398:12;-1:-1:-1;;;1859:398:12:o;6471:483::-;6646:7;6695:10;6684:8;:21;:263;;6780:167;6826:7;6855:10;6887:8;6917:12;6780:24;:167::i;:::-;6684:263;;;6724:37;6743:7;6752:8;6724:18;:37::i;:::-;6665:282;6471:483;-1:-1:-1;;;;;6471:483:12:o;3758:1460:7:-;4201:10;4189:8;:22;4185:107;;4235:10;:22;;;;4227:54;;;;;;;6343:2:13;4227:54:7;;;6325:21:13;6382:2;6362:18;;;6355:30;6421:21;6401:18;;;6394:49;6460:18;;4227:54:7;6141:343:13;4227:54:7;4302:29;4334:12;:10;:12::i;:::-;4302:44;;4449:19;4471:36;4483:11;4496:10;4471:11;:36::i;:::-;4449:58;;4569:17;4589:34;4601:11;4614:8;4589:11;:34::i;:::-;4569:54;;4719:11;4706:9;:24;4702:61;;;4746:7;;;;;4702:61;4788:11;4776:9;:23;4772:440;;;4887:149;4927:10;4963:4;4986:36;:9;5010:11;4986:23;:36::i;:::-;4887:5;;;;;:149;;:22;:149::i;:::-;4772:440;;;5135:66;5154:8;5164:36;:11;5190:9;5164:25;:36::i;:::-;5135:5;;;;;:66;:18;:66::i;:::-;3907:1311;;;3758:1460;;;;;:::o;1071:354:10:-;1195:17;;:31;:17;:31;1188:39;;;;:::i;:::-;1237:26;1266:38;1291:11;1280:23;;;;;;;;:::i;:::-;;;;;;;;;;;;;1266:13;:38::i;:::-;1319:51;;;1339:10;6044:34:13;;5993:42;6114:15;;6109:2;6094:18;;6087:43;1237:67:10;;-1:-1:-1;1319:51:10;;5956:18:13;1319:51:10;;;;;;;1380:17;:38;;;;;;;;;;;;;;;-1:-1:-1;1071:354:10:o;1930:1180:6:-;2044:18;1484;;;2115:32;;-1:-1:-1;;2138:9:6;;;;;;;;;-1:-1:-1;2138:9:6;;2131:16;;2115:32;2171:5;2162:6;:14;2158:36;;;-1:-1:-1;;2185:9:6;;;;;;;;;-1:-1:-1;2185:9:6;;2178:16;;2158:36;2215:6;2208:4;:13;2204:65;;;2230:39;;;;;;;;6880:25:13;;;6921:18;;;6914:34;;;6964:18;;;6957:34;;;6853:18;;2230:39:6;6678:319:13;2204:65:6;2322:13;;;2367:14;;;2304:15;2411:17;;;:37;;2441:7;2411:37;;;2431:7;2411:37;2666:4;2660:11;;2811:26;;;2839:9;2807:42;2796:54;;2742:126;;;2927:19;;;2660:11;-1:-1:-1;2396:52:6;-1:-1:-1;2396:52:6;3067:6;2825:4;3049:16;;3042:5;3030:50;2472:622;;;2064:1046;1930:1180;;;;;;:::o;4871:674:12:-;5081:7;5042:10;1308:1:11;1070:5:12;:31;;1062:52;;;;;;;7204:2:13;1062:52:12;;;7186:21:13;7243:1;7223:18;;;7216:29;7281:10;7261:18;;;7254:38;7309:18;;1062:52:12;7002:331:13;1062:52:12;5062:8:::1;1308:1:11;1070:5:12;:31;;1062:52;;;::::0;::::1;::::0;;7204:2:13;1062:52:12::1;::::0;::::1;7186:21:13::0;7243:1;7223:18;;;7216:29;7281:10;7261:18;;;7254:38;7309:18;;1062:52:12::1;7002:331:13::0;1062:52:12::1;5124:15:::2;5171:10:::0;5153:348:::2;5188:8;5183:2;:13;5153:348;;;388:16:11;5237:2:12;5232:7:::0;::::2;5360:44:::0;;::::2;5322:108;5288:142:::0;;;::::2;5462:23:::0;;::::2;5287:199;::::0;5232:7;-1:-1:-1;5198:4:12::2;;5153:348;;;-1:-1:-1::0;5521:7:12;;4871:674;-1:-1:-1;;;;;;;4871:674:12:o;3357:338::-;3487:7;3463:5;1308:1:11;1070:5:12;:31;;1062:52;;;;;;;7204:2:13;1062:52:12;;;7186:21:13;7243:1;7223:18;;;7216:29;7281:10;7261:18;;;7254:38;7309:18;;1062:52:12;7002:331:13;1062:52:12;-1:-1:-1;;294:17:11::1;3560:2:12;3552:10:::0;;;::::1;3593:37:::0;;::::1;3592:50:::0;::::1;3663:15;::::0;3357:338::o;1977:211:10:-;2091:7;659:1:11;2121:5:10;:31;:60;;2180:1;2121:60;;;2155:11;2167:9;2175:1;2167:5;:9;:::i;:::-;2155:22;;;;;;;:::i;:::-;;;;;2114:67;1977:211;-1:-1:-1;;;1977:211:10:o;1337:186:4:-;1431:7;1490:2;1485;:7;:21;;1505:1;1485:21;;;-1:-1:-1;1495:7:4;;;1337:186::o;912:241:2:-;1077:68;;8023:42:13;8092:15;;;1077:68:2;;;8074:34:13;8144:15;;8124:18;;;8117:43;8176:18;;;8169:34;;;1050:96:2;;1070:5;;1100:27;;7986:18:13;;1077:68:2;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;1050:19;:96::i;701:205::-;840:58;;8418:42:13;8406:55;;840:58:2;;;8388:74:13;8478:18;;;8471:34;;;813:86:2;;833:5;;863:23;;8361:18:13;;840:58:2;8214:297:13;813:86:2;701:205;;;:::o;592:496:5:-;645:15;757:17;777:80;841:5;815:32;;;;;;;;:::i;:::-;;;;;;;;;;;;;777:24;:80::i;:::-;757:100;;973:4;967:11;962:2;956:4;952:13;949:1;942:37;931:48;-1:-1:-1;1039:21:5;;;1035:46;;1069:12;;;;;;;;;;;;;;1035:46;662:426;592:496;;;:::o;3207:706:2:-;3626:23;3652:69;3680:4;3652:69;;;;;;;;;;;;;;;;;3660:5;3652:27;;;;:69;;;;;:::i;:::-;3735:17;;3626:95;;-1:-1:-1;3735:21:2;3731:176;;3830:10;3819:30;;;;;;;;;;;;:::i;:::-;3811:85;;;;;;;9682:2:13;3811:85:2;;;9664:21:13;9721:2;9701:18;;;9694:30;9760:34;9740:18;;;9733:62;9831:12;9811:18;;;9804:40;9861:19;;3811:85:2;9480:406:13;388:798:6;480:12;1080:5;:12;1160:5;1014:165;;;;;;;;;:::i;:::-;;;;;;;;;;;;;995:184;;388:798;;;:::o;3861:223:3:-;3994:12;4025:52;4047:6;4055:4;4061:1;4064:12;4025:21;:52::i;:::-;4018:59;3861:223;-1:-1:-1;;;;3861:223:3:o;4948:499::-;5113:12;5170:5;5145:21;:30;;5137:81;;;;;;;10858:2:13;5137:81:3;;;10840:21:13;10897:2;10877:18;;;10870:30;10936:34;10916:18;;;10909:62;11007:8;10987:18;;;10980:36;11033:19;;5137:81:3;10656:402:13;5137:81:3;1465:19;;;;5228:60;;;;;;;11265:2:13;5228:60:3;;;11247:21:13;11304:2;11284:18;;;11277:30;11343:31;11323:18;;;11316:59;11392:18;;5228:60:3;11063:353:13;5228:60:3;5300:12;5314:23;5341:6;:11;;5360:5;5367:4;5341:31;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;5299:73;;;;5389:51;5406:7;5415:10;5427:12;5389:16;:51::i;:::-;5382:58;4948:499;-1:-1:-1;;;;;;;4948:499:3:o;7561:692::-;7707:12;7735:7;7731:516;;;-1:-1:-1;7765:10:3;7758:17;;7731:516;7876:17;;:21;7872:365;;8070:10;8064:17;8130:15;8117:10;8113:2;8109:19;8102:44;7872:365;8209:12;8202:20;;;;;;;;;;;:::i;-1:-1:-1:-;;;;;;;;;;;;;;;;;;;;;;;;:::o;14:495:13:-;194:3;179:19;;183:9;275:6;152:4;309:194;323:4;320:1;317:11;309:194;;;382:13;;370:26;;419:4;443:12;;;;478:15;;;;343:1;336:9;309:194;;;313:3;;;14:495;;;;:::o;514:154::-;600:42;593:5;589:54;582:5;579:65;569:93;;658:1;655;648:12;569:93;514:154;:::o;673:184::-;725:77;722:1;715:88;822:4;819:1;812:15;846:4;843:1;836:15;862:252;934:2;928:9;976:3;964:16;;1010:18;995:34;;1031:22;;;992:62;989:88;;;1057:18;;:::i;:::-;1093:2;1086:22;862:252;:::o;1119:334::-;1190:2;1184:9;1246:2;1236:13;;1251:66;1232:86;1220:99;;1349:18;1334:34;;1370:22;;;1331:62;1328:88;;;1396:18;;:::i;:::-;1432:2;1425:22;1119:334;;-1:-1:-1;1119:334:13:o;1458:1025::-;1544:6;1552;1560;1613:2;1601:9;1592:7;1588:23;1584:32;1581:52;;;1629:1;1626;1619:12;1581:52;1668:9;1655:23;1687:31;1712:5;1687:31;:::i;:::-;1737:5;-1:-1:-1;1761:2:13;1795:18;;;1782:32;;-1:-1:-1;1865:2:13;1850:18;;1837:32;1888:18;1918:14;;;1915:34;;;1945:1;1942;1935:12;1915:34;1983:6;1972:9;1968:22;1958:32;;2028:7;2021:4;2017:2;2013:13;2009:27;1999:55;;2050:1;2047;2040:12;1999:55;2086:2;2073:16;2108:2;2104;2101:10;2098:36;;;2114:18;;:::i;:::-;2156:112;2264:2;2195:66;2188:4;2184:2;2180:13;2176:86;2172:95;2156:112;:::i;:::-;2143:125;;2291:2;2284:5;2277:17;2331:7;2326:2;2321;2317;2313:11;2309:20;2306:33;2303:53;;;2352:1;2349;2342:12;2303:53;2407:2;2402;2398;2394:11;2389:2;2382:5;2378:14;2365:45;2451:1;2446:2;2441;2434:5;2430:14;2426:23;2419:34;;2472:5;2462:15;;;;;1458:1025;;;;;:::o;2488:1023::-;2588:6;2619:3;2663:2;2651:9;2642:7;2638:23;2634:32;2631:52;;;2679:1;2676;2669:12;2631:52;2712:4;2706:11;2756:4;2748:6;2744:17;2827:6;2815:10;2812:22;2791:18;2779:10;2776:34;2773:62;2770:88;;;2838:18;;:::i;:::-;2874:4;2867:24;2913:23;;2945:31;2913:23;2945:31;:::i;:::-;2985:21;;3025:2;3065;3050:18;;3046:32;-1:-1:-1;3036:60:13;;3092:1;3089;3082:12;3036:60;3116:22;;:::i;:::-;3186:18;;;;3160:3;3216:19;;;3213:39;;;3248:1;3245;3238:12;3213:39;3287:2;3276:9;3272:18;3299:142;3315:6;3310:3;3307:15;3299:142;;;3381:17;;3369:30;;3419:12;;;;3332;;3299:142;;;-1:-1:-1;3457:15:13;;;3450:30;;;;-1:-1:-1;3461:6:13;2488:1023;-1:-1:-1;;;;2488:1023:13:o;3516:247::-;3575:6;3628:2;3616:9;3607:7;3603:23;3599:32;3596:52;;;3644:1;3641;3634:12;3596:52;3683:9;3670:23;3702:31;3727:5;3702:31;:::i;3950:622::-;4043:6;4074:3;4118:2;4106:9;4097:7;4093:23;4089:32;4086:52;;;4134:1;4131;4124:12;4086:52;4183:7;4176:4;4165:9;4161:20;4157:34;4147:62;;4205:1;4202;4195:12;4147:62;4229:22;;:::i;:::-;4299:18;;;;4273:3;4329:19;;;4326:39;;;4361:1;4358;4351:12;4326:39;4385:9;4403:139;4419:6;4414:3;4411:15;4403:139;;;4487:10;;4475:23;;4527:4;4518:14;;;;4436;4403:139;;;-1:-1:-1;4561:5:13;3950:622;-1:-1:-1;;;;;3950:622:13:o;6489:184::-;6541:77;6538:1;6531:88;6638:4;6635:1;6628:15;6662:4;6659:1;6652:15;7338:279;7378:4;7406:1;7403;7400:8;7397:188;;;7441:77;7438:1;7431:88;7542:4;7539:1;7532:15;7570:4;7567:1;7560:15;7397:188;-1:-1:-1;7602:9:13;;7338:279::o;7622:184::-;7674:77;7671:1;7664:88;7771:4;7768:1;7761:15;7795:4;7792:1;7785:15;8516:258;8588:1;8598:113;8612:6;8609:1;8606:13;8598:113;;;8688:11;;;8682:18;8669:11;;;8662:39;8634:2;8627:10;8598:113;;;8729:6;8726:1;8723:13;8720:48;;;-1:-1:-1;;8764:1:13;8746:16;;8739:27;8516:258::o;8779:414::-;9039:1;9034:3;9027:14;9009:3;9070:6;9064:13;9086:61;9140:6;9136:1;9131:3;9127:11;9120:4;9112:6;9108:17;9086:61;:::i;:::-;9167:16;;;;9185:1;9163:24;;8779:414;-1:-1:-1;;8779:414:13:o;9198:277::-;9265:6;9318:2;9306:9;9297:7;9293:23;9289:32;9286:52;;;9334:1;9331;9324:12;9286:52;9366:9;9360:16;9419:5;9412:13;9405:21;9398:5;9395:32;9385:60;;9441:1;9438;9431:12;9891:760;10278:3;10273;10266:16;10333:66;10324:6;10319:3;10315:16;10311:89;10307:1;10302:3;10298:11;10291:110;10430:66;10426:1;10421:3;10417:11;10410:87;10248:3;10526:6;10520:13;10542:62;10597:6;10592:2;10587:3;10583:12;10576:4;10568:6;10564:17;10542:62;:::i;:::-;10624:16;;;;10642:2;10620:25;;9891:760;-1:-1:-1;;;9891:760:13:o;11421:274::-;11550:3;11588:6;11582:13;11604:53;11650:6;11645:3;11638:4;11630:6;11626:17;11604:53;:::i;:::-;11673:16;;;;;11421:274;-1:-1:-1;;11421:274:13:o;11700:442::-;11849:2;11838:9;11831:21;11812:4;11881:6;11875:13;11924:6;11919:2;11908:9;11904:18;11897:34;11940:66;11999:6;11994:2;11983:9;11979:18;11974:2;11966:6;11962:15;11940:66;:::i;:::-;12058:2;12046:15;12063:66;12042:88;12027:104;;;;12133:2;12023:113;;11700:442;-1:-1:-1;;11700:442:13:o

Swarm Source

ipfs://73be69a568d4b1e5068b5a1fe26b965763d072c618d04fe69469b56e13ca0163

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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