ETH Price: $1,950.74 (-2.54%)
 

More Info

Private Name Tags

Multichain Info

Transaction Hash
Method
Block
From
To
Batch Claim Rewa...244156402026-02-09 0:29:472 days ago1770596987IN
KyberSwap: Reward Distributor 2
0 ETH0.00001030.06
Batch Claim Rewa...244077472026-02-07 21:51:113 days ago1770501071IN
KyberSwap: Reward Distributor 2
0 ETH0.00001610.05643029
Batch Claim Rewa...244064632026-02-07 17:33:473 days ago1770485627IN
KyberSwap: Reward Distributor 2
0 ETH0.000424972.0974741
Batch Claim Rewa...244064612026-02-07 17:33:233 days ago1770485603IN
KyberSwap: Reward Distributor 2
0 ETH0.001069452.09233911
Batch Claim Rewa...244044832026-02-07 10:55:234 days ago1770461723IN
KyberSwap: Reward Distributor 2
0 ETH0.000035940.0938388
Batch Claim Rewa...244043222026-02-07 10:23:114 days ago1770459791IN
KyberSwap: Reward Distributor 2
0 ETH0.000027610.09812844
Batch Claim Rewa...244030932026-02-07 6:15:474 days ago1770444947IN
KyberSwap: Reward Distributor 2
0 ETH0.000084850.13813092
Batch Claim Rewa...244025722026-02-07 4:31:234 days ago1770438683IN
KyberSwap: Reward Distributor 2
0 ETH0.000050260.25157226
Batch Claim Rewa...243995812026-02-06 18:29:474 days ago1770402587IN
KyberSwap: Reward Distributor 2
0 ETH0.000118290.37885398
Batch Claim Rewa...243984442026-02-06 14:41:114 days ago1770388871IN
KyberSwap: Reward Distributor 2
0 ETH0.000502371.87311103
Batch Claim Rewa...243983302026-02-06 14:18:234 days ago1770387503IN
KyberSwap: Reward Distributor 2
0 ETH0.000341010.66937329
Batch Claim Rewa...243981492026-02-06 13:41:474 days ago1770385307IN
KyberSwap: Reward Distributor 2
0 ETH0.000217390.54242965
Batch Claim Rewa...243981352026-02-06 13:38:594 days ago1770385139IN
KyberSwap: Reward Distributor 2
0 ETH0.000171430.63901128
Batch Claim Rewa...243971962026-02-06 10:30:235 days ago1770373823IN
KyberSwap: Reward Distributor 2
0 ETH0.00016390.45
Batch Claim Rewa...243965952026-02-06 8:29:355 days ago1770366575IN
KyberSwap: Reward Distributor 2
0 ETH0.00043440.52674806
Submit Root243919442026-02-05 16:53:115 days ago1770310391IN
KyberSwap: Reward Distributor 2
0 ETH0.000222492.77228887
Submit Root243919392026-02-05 16:52:115 days ago1770310331IN
KyberSwap: Reward Distributor 2
0 ETH0.00022682.82601151
Batch Claim Rewa...243734452026-02-03 2:47:598 days ago1770086879IN
KyberSwap: Reward Distributor 2
0 ETH0.000036820.09878686
Batch Claim Rewa...243697682026-02-02 14:27:478 days ago1770042467IN
KyberSwap: Reward Distributor 2
0 ETH0.001961162.72208589
Batch Claim Rewa...243686612026-02-02 10:45:119 days ago1770029111IN
KyberSwap: Reward Distributor 2
0 ETH0.000796092.22681877
Batch Claim Rewa...243660042026-02-02 1:50:479 days ago1769997047IN
KyberSwap: Reward Distributor 2
0 ETH0.000045530.1029385
Batch Claim Rewa...243641222026-02-01 19:32:119 days ago1769974331IN
KyberSwap: Reward Distributor 2
0 ETH0.000029510.16637333
Batch Claim Rewa...243580322026-01-31 23:07:2310 days ago1769900843IN
KyberSwap: Reward Distributor 2
0 ETH0.00003440.09020128
Batch Claim Rewa...243545072026-01-31 11:18:1111 days ago1769858291IN
KyberSwap: Reward Distributor 2
0 ETH0.000015440.07322274
Batch Claim Rewa...243539952026-01-31 9:35:2311 days ago1769852123IN
KyberSwap: Reward Distributor 2
0 ETH0.000038040.10908157
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Method Block
From
To
Transfer243734452026-02-03 2:47:598 days ago1770086879
KyberSwap: Reward Distributor 2
0.00002093 ETH
Transfer243697682026-02-02 14:27:478 days ago1770042467
KyberSwap: Reward Distributor 2
0.00148345 ETH
Transfer243686612026-02-02 10:45:119 days ago1770029111
KyberSwap: Reward Distributor 2
0.00000136 ETH
Transfer242963552026-01-23 8:40:4719 days ago1769157647
KyberSwap: Reward Distributor 2
0.00101442 ETH
Transfer242784622026-01-20 20:44:4721 days ago1768941887
KyberSwap: Reward Distributor 2
0.00014469 ETH
Transfer242784562026-01-20 20:43:3521 days ago1768941815
KyberSwap: Reward Distributor 2
0.00905873 ETH
Transfer242465762026-01-16 10:05:2326 days ago1768557923
KyberSwap: Reward Distributor 2
0.00000023 ETH
Transfer242410052026-01-15 15:27:5926 days ago1768490879
KyberSwap: Reward Distributor 2
0.000295 ETH
Transfer242236562026-01-13 5:17:5929 days ago1768281479
KyberSwap: Reward Distributor 2
0.00016525 ETH
Transfer242067072026-01-10 20:32:1131 days ago1768077131
KyberSwap: Reward Distributor 2
0.00003504 ETH
Transfer241965182026-01-09 10:26:3533 days ago1767954395
KyberSwap: Reward Distributor 2
0.00001518 ETH
Transfer241891252026-01-08 9:40:3534 days ago1767865235
KyberSwap: Reward Distributor 2
0.000162 ETH
Transfer241599472026-01-04 7:57:1138 days ago1767513431
KyberSwap: Reward Distributor 2
0.00000013 ETH
Transfer241446742026-01-02 4:51:3540 days ago1767329495
KyberSwap: Reward Distributor 2
0.00001765 ETH
Transfer241441112026-01-02 2:58:4740 days ago1767322727
KyberSwap: Reward Distributor 2
0.00000023 ETH
Transfer241438992026-01-02 2:15:5940 days ago1767320159
KyberSwap: Reward Distributor 2
0.00000621 ETH
Transfer241385902026-01-01 8:29:4741 days ago1767256187
KyberSwap: Reward Distributor 2
0.000159 ETH
Transfer241340252025-12-31 17:12:5941 days ago1767201179
KyberSwap: Reward Distributor 2
0.00157775 ETH
Transfer241031332025-12-27 9:41:1146 days ago1766828471
KyberSwap: Reward Distributor 2
0.00034545 ETH
Transfer240836662025-12-24 16:26:4748 days ago1766593607
KyberSwap: Reward Distributor 2
0.001983 ETH
Transfer240805472025-12-24 6:00:3549 days ago1766556035
KyberSwap: Reward Distributor 2
0.00698232 ETH
Transfer240379742025-12-18 7:23:1155 days ago1766042591
KyberSwap: Reward Distributor 2
0.005879 ETH
Transfer240230422025-12-16 5:20:5957 days ago1765862459
KyberSwap: Reward Distributor 2
0.00002208 ETH
Transfer239880572025-12-11 7:49:5962 days ago1765439399
KyberSwap: Reward Distributor 2
0.004935 ETH
Transfer239872872025-12-11 5:15:2362 days ago1765430123
KyberSwap: Reward Distributor 2
0.00002779 ETH
View All Internal Transactions
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:
KSDistributor

Compiler Version
v0.8.28+commit.7893614a

Optimization Enabled:
Yes with 44444444 runs

Other Settings:
cancun EvmVersion
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity 0.8.28;

import {IKSDistributor} from './interfaces/IKSDistributor.sol';
import {ClaimDataDecoder} from './libraries/ClaimDataDecoder.sol';

import {ManagementBase} from 'ks-common-sc/src/base/ManagementBase.sol';
import {ManagementPausable} from 'ks-common-sc/src/base/ManagementPausable.sol';
import {ManagementRescuable} from 'ks-common-sc/src/base/ManagementRescuable.sol';

import {KSRoles} from 'ks-common-sc/src/libraries/KSRoles.sol';
import {TokenHelper} from 'ks-common-sc/src/libraries/token/TokenHelper.sol';

import {Address} from 'openzeppelin-contracts/contracts/utils/Address.sol';
import {ReentrancyGuardTransient} from
  'openzeppelin-contracts/contracts/utils/ReentrancyGuardTransient.sol';
import {SlotDerivation} from 'openzeppelin-contracts/contracts/utils/SlotDerivation.sol';
import {TransientSlot} from 'openzeppelin-contracts/contracts/utils/TransientSlot.sol';
import {MerkleProof} from 'openzeppelin-contracts/contracts/utils/cryptography/MerkleProof.sol';

import {IERC721} from 'openzeppelin-contracts/contracts/token/ERC721/IERC721.sol';

contract KSDistributor is
  IKSDistributor,
  ReentrancyGuardTransient,
  ManagementPausable,
  ManagementRescuable
{
  using TokenHelper for address;
  using Address for address;
  using SlotDerivation for bytes32;
  using TransientSlot for *;

  uint256 public constant MIN_CAMPAIGN_DURATION = 1 hours;

  // keccak256(abi.encode(uint256(keccak256('ks-distributor.storage.PendingRewards')) - 1)) & ~bytes32(uint256(0xff))
  bytes32 internal constant PENDING_REWARDS_STORAGE =
    0x667c036918e8dbe38a4ec9003830d89d321fbfffacba5bdecb14c1bbca99be00;

  /// @inheritdoc IKSDistributor
  uint256 public defaultTimeLock;

  /// @inheritdoc IKSDistributor
  mapping(bytes32 campaignId => Campaign) public campaigns;

  /// @inheritdoc IKSDistributor
  mapping(bytes32 campaignId => bytes32) public roots;

  /// @inheritdoc IKSDistributor
  mapping(bytes32 campaignId => PendingRoot) public pendingRoots;

  /// @notice Whether a hook and a selector is whitelisted
  mapping(address hook => mapping(bytes4 selector => bool)) public whitelistedHooks;

  /// @notice The claimed amount for each `infoHash` in each campaign
  mapping(bytes32 infoHash => mapping(address token => uint256)) internal claimed;

  /// @notice Restricts a function to be called before a certain timestamp
  modifier onlyBefore(uint256 timestamp) {
    require(block.timestamp < timestamp, TooLate());
    _;
  }

  /// @notice Restricts a function to be called between two timestamps
  modifier onlyBetween(uint256 startTimestamp, uint256 endTimestamp) {
    require(block.timestamp >= startTimestamp, TooEarly());
    require(block.timestamp < endTimestamp, TooLate());
    _;
  }

  modifier campaignExists(bytes32 campaignId) {
    require(campaigns[campaignId].startTimestamp != 0, CampaignDoesNotExist(campaignId));
    _;
  }

  constructor(
    address initialAdmin,
    address[] memory initialOperators,
    address[] memory initialGuardians,
    address[] memory initialRescuers,
    address[] memory initialWhitelistedHooks,
    bytes4[] memory initialWhitelistedSelectors,
    uint256 initDefaultTimeLock
  ) ManagementBase(0, initialAdmin) {
    _batchGrantRole(KSRoles.OPERATOR_ROLE, initialOperators);
    _batchGrantRole(KSRoles.GUARDIAN_ROLE, initialGuardians);
    _batchGrantRole(KSRoles.RESCUER_ROLE, initialRescuers);

    _updateWhitelistedHooks(initialWhitelistedHooks, initialWhitelistedSelectors, true);
    _updateDefaultTimeLock(initDefaultTimeLock);
  }

  receive() external payable {}

  /// @inheritdoc IKSDistributor
  function updateDefaultTimeLock(uint256 newDefaultTimeLock) public onlyRole(DEFAULT_ADMIN_ROLE) {
    _updateDefaultTimeLock(newDefaultTimeLock);
  }

  function _updateDefaultTimeLock(uint256 newDefaultTimeLock) internal {
    uint256 oldDefaultTimeLock = defaultTimeLock;
    defaultTimeLock = newDefaultTimeLock;

    emit DefaultTimeLockUpdated(oldDefaultTimeLock, newDefaultTimeLock);
  }

  /// @inheritdoc IKSDistributor
  function createCampaign(
    uint256 initStartTimestamp,
    uint256 initEndTimestamp,
    string calldata initMetadata,
    bytes32 salt
  )
    public
    onlyRole(KSRoles.OPERATOR_ROLE)
    onlyBefore(initEndTimestamp)
    returns (bytes32 campaignId)
  {
    require(initStartTimestamp + MIN_CAMPAIGN_DURATION <= initEndTimestamp, TooShortDuration());
    campaignId = keccak256(abi.encode(initStartTimestamp, initEndTimestamp, initMetadata, salt));
    require(campaigns[campaignId].startTimestamp == 0, CampaignAlreadyExists(campaignId));
    campaigns[campaignId] = Campaign(initStartTimestamp, initEndTimestamp, initMetadata);

    emit CampaignCreated(campaignId, initStartTimestamp, initEndTimestamp, initMetadata);
  }

  /// @inheritdoc IKSDistributor
  function submitRoot(bytes32 campaignId, bytes32 newRoot, uint256 effectiveTimestamp)
    public
    onlyRole(KSRoles.OPERATOR_ROLE)
    campaignExists(campaignId)
  {
    if (effectiveTimestamp == 0) {
      effectiveTimestamp = block.timestamp + defaultTimeLock;
    }
    require(
      effectiveTimestamp >= block.timestamp + defaultTimeLock
        && effectiveTimestamp < campaigns[campaignId].endTimestamp,
      InvalidEffectiveTimestamp()
    );
    _getLatestRoot(campaignId);
    pendingRoots[campaignId] = PendingRoot(newRoot, effectiveTimestamp);

    emit RootSubmitted(campaignId, newRoot, effectiveTimestamp);
  }

  /// @inheritdoc IKSDistributor
  function forceUpdateRoot(bytes32 campaignId, bytes32 newRoot)
    public
    onlyRole(DEFAULT_ADMIN_ROLE)
    campaignExists(campaignId)
  {
    _applyRoot(campaignId, newRoot);
  }

  /// @inheritdoc IKSDistributor
  function updateStartTimestamp(bytes32 campaignId, uint256 startTimestamp)
    public
    onlyRole(KSRoles.OPERATOR_ROLE)
    campaignExists(campaignId)
  {
    require(
      startTimestamp + MIN_CAMPAIGN_DURATION <= campaigns[campaignId].endTimestamp,
      TooShortDuration()
    );
    uint256 oldStartTimestamp = campaigns[campaignId].startTimestamp;
    campaigns[campaignId].startTimestamp = startTimestamp;

    emit StartTimestampUpdated(campaignId, oldStartTimestamp, startTimestamp);
  }

  /// @inheritdoc IKSDistributor
  function updateEndTimestamp(bytes32 campaignId, uint256 endTimestamp)
    public
    onlyRole(KSRoles.OPERATOR_ROLE)
    campaignExists(campaignId)
  {
    require(
      campaigns[campaignId].startTimestamp + MIN_CAMPAIGN_DURATION <= endTimestamp,
      TooShortDuration()
    );
    uint256 oldEndTimestamp = campaigns[campaignId].endTimestamp;
    campaigns[campaignId].endTimestamp = endTimestamp;

    emit EndTimestampUpdated(campaignId, oldEndTimestamp, endTimestamp);
  }

  /// @inheritdoc IKSDistributor
  function updateMetadata(bytes32 campaignId, string calldata metadata)
    public
    onlyRole(KSRoles.OPERATOR_ROLE)
    campaignExists(campaignId)
  {
    string memory oldMetadata = campaigns[campaignId].metadata;
    campaigns[campaignId].metadata = metadata;

    emit MetadataUpdated(campaignId, oldMetadata, metadata);
  }

  /// @inheritdoc IKSDistributor
  function updateWhitelistedHooks(
    address[] calldata hooks,
    bytes4[] calldata selectors,
    bool grantOrRevoke
  ) public onlyRole(DEFAULT_ADMIN_ROLE) {
    _updateWhitelistedHooks(hooks, selectors, grantOrRevoke);
  }

  function _updateWhitelistedHooks(
    address[] memory hooks,
    bytes4[] memory selectors,
    bool grantOrRevoke
  ) internal {
    require(hooks.length == selectors.length, InvalidLengths());
    for (uint256 i = 0; i < hooks.length; i++) {
      whitelistedHooks[hooks[i]][selectors[i]] = grantOrRevoke;

      emit WhitelistedHookUpdated(hooks[i], selectors[i], grantOrRevoke);
    }
  }

  /// @inheritdoc IKSDistributor
  function getClaimedAmountForAccount(bytes32 campaignId, address account, address token)
    public
    view
    returns (uint256)
  {
    bytes32 infoHash = keccak256(abi.encode(campaignId, account));
    return claimed[infoHash][token];
  }

  /// @inheritdoc IKSDistributor
  function getClaimedAmountForERC721(
    bytes32 campaignId,
    address erc721Addr,
    uint256 erc721Id,
    address token
  ) public view returns (uint256) {
    bytes32 infoHash = keccak256(abi.encode(campaignId, erc721Addr, erc721Id));
    return claimed[infoHash][token];
  }

  /// @inheritdoc IKSDistributor
  function claimRewardsForAccount(
    bytes32 campaignId,
    address[] calldata tokens,
    uint256[] calldata amounts,
    bytes32[] calldata proof,
    address recipient
  ) public nonReentrant whenNotPaused {
    _claimRewardsForAccount(campaignId, tokens, amounts, proof, recipient, true);
  }

  /// @inheritdoc IKSDistributor
  function claimRewardsForAccountWithHook(
    bytes32 campaignId,
    address[] calldata tokens,
    uint256[] calldata amounts,
    bytes32[] calldata proof,
    address recipient,
    address hook,
    bytes calldata hookData
  ) public nonReentrant whenNotPaused {
    _claimRewardsForAccount(campaignId, tokens, amounts, proof, recipient, true);
    _callHook(hook, hookData);
  }

  function _claimRewardsForAccount(
    bytes32 campaignId,
    address[] calldata tokens,
    uint256[] calldata amounts,
    bytes32[] calldata proof,
    address recipient,
    bool directTransfer
  ) internal onlyBetween(campaigns[campaignId].startTimestamp, campaigns[campaignId].endTimestamp) {
    require(tokens.length == amounts.length, InvalidLengths());

    bytes32 root = _getLatestRoot(campaignId);
    bytes32 infoHash = keccak256(abi.encode(campaignId, msg.sender));
    require(
      MerkleProof.verifyCalldata(
        proof, root, keccak256(bytes.concat(keccak256(abi.encode(infoHash, tokens, amounts))))
      ),
      InvalidProof()
    );

    uint256[] memory claimedAmounts = directTransfer
      ? _transferRewards(infoHash, tokens, amounts, recipient)
      : _creditRewards(infoHash, tokens, amounts, recipient);

    emit RewardsClaimedForAccount(campaignId, msg.sender, root, tokens, claimedAmounts, recipient);
  }

  /// @inheritdoc IKSDistributor
  function claimRewardsForERC721(
    bytes32 campaignId,
    address erc721Addr,
    uint256 erc721Id,
    address[] calldata tokens,
    uint256[] calldata amounts,
    bytes32[] calldata proof,
    address recipient
  ) public nonReentrant whenNotPaused {
    _claimRewardsForERC721(
      campaignId, erc721Addr, erc721Id, tokens, amounts, proof, recipient, true
    );
  }

  /// @inheritdoc IKSDistributor
  function claimRewardsForERC721WithHook(
    bytes32 campaignId,
    address erc721Addr,
    uint256 erc721Id,
    address[] calldata tokens,
    uint256[] calldata amounts,
    bytes32[] calldata proof,
    address recipient,
    address hook,
    bytes calldata hookData
  ) public nonReentrant whenNotPaused {
    _claimRewardsForERC721(
      campaignId, erc721Addr, erc721Id, tokens, amounts, proof, recipient, true
    );
    _callHook(hook, hookData);
  }

  function _claimRewardsForERC721(
    bytes32 campaignId,
    address erc721Addr,
    uint256 erc721Id,
    address[] calldata tokens,
    uint256[] calldata amounts,
    bytes32[] calldata proof,
    address recipient,
    bool directTransfer
  ) internal onlyBetween(campaigns[campaignId].startTimestamp, campaigns[campaignId].endTimestamp) {
    require(tokens.length == amounts.length, InvalidLengths());

    bytes32 root = _getLatestRoot(campaignId);
    require(msg.sender == IERC721(erc721Addr).ownerOf(erc721Id), UnauthorizedClaimant(msg.sender));

    bytes32 infoHash = keccak256(abi.encode(campaignId, erc721Addr, erc721Id));
    require(
      MerkleProof.verifyCalldata(
        proof, root, keccak256(bytes.concat(keccak256(abi.encode(infoHash, tokens, amounts))))
      ),
      InvalidProof()
    );

    uint256[] memory claimedAmounts = directTransfer
      ? _transferRewards(infoHash, tokens, amounts, recipient)
      : _creditRewards(infoHash, tokens, amounts, recipient);

    emit RewardsClaimedForERC721(
      campaignId, erc721Addr, erc721Id, msg.sender, root, tokens, claimedAmounts, recipient
    );
  }

  /// @inheritdoc IKSDistributor
  function batchClaimRewards(bytes[] calldata datas) public nonReentrant whenNotPaused {
    _batchClaimRewards(datas);
  }

  /// @inheritdoc IKSDistributor
  function batchClaimRewardsWithHook(bytes[] calldata datas, address hook, bytes calldata hookData)
    public
    nonReentrant
    whenNotPaused
  {
    _batchClaimRewards(datas);
    _callHook(hook, hookData);
  }

  function _getLatestRoot(bytes32 campaignId) internal returns (bytes32) {
    bytes32 pendingRoot = pendingRoots[campaignId].root;
    if (pendingRoot != bytes32(0)) {
      if (pendingRoots[campaignId].effectiveTimestamp <= block.timestamp) {
        _applyRoot(campaignId, pendingRoot);

        return pendingRoot;
      }
    }

    return roots[campaignId];
  }

  function _applyRoot(bytes32 campaignId, bytes32 newRoot) internal {
    bytes32 oldRoot = roots[campaignId];
    roots[campaignId] = newRoot;
    delete pendingRoots[campaignId];

    emit RootApplied(campaignId, oldRoot, newRoot);
  }

  function _batchClaimRewards(bytes[] calldata datas) internal {
    for (uint256 i = 0; i < datas.length; i++) {
      bytes4 selector = bytes4(datas[i][:4]);
      if (selector == this.claimRewardsForAccount.selector) {
        (
          bytes32 campaignId,
          address[] calldata tokens,
          uint256[] calldata amounts,
          bytes32[] calldata proof,
          address recipient
        ) = ClaimDataDecoder.decodeClaimRewardsForAccountData(datas[i][4:]);
        _claimRewardsForAccount(campaignId, tokens, amounts, proof, recipient, false);
      } else if (selector == this.claimRewardsForERC721.selector) {
        (
          bytes32 campaignId,
          address erc721Addr,
          uint256 erc721Id,
          address[] calldata tokens,
          uint256[] calldata amounts,
          bytes32[] calldata proof,
          address recipient
        ) = ClaimDataDecoder.decodeClaimRewardsForERC721Data(datas[i][4:]);
        _claimRewardsForERC721(
          campaignId, erc721Addr, erc721Id, tokens, amounts, proof, recipient, false
        );
      } else {
        revert InvalidSelector(selector);
      }
    }

    _transferPendingRewards();
  }

  function _callHook(address hook, bytes calldata hookData) internal {
    require(hookData.length >= 4, InvalidHookData(hookData));
    bytes4 selector = bytes4(hookData[:4]);
    require(whitelistedHooks[hook][selector], NotWhitelistedHook(hook, selector));
    hook.functionCall(hookData);
  }

  /// @notice Transfers the rewards to the recipient
  function _transferRewards(
    bytes32 infoHash,
    address[] calldata tokens,
    uint256[] calldata amounts,
    address recipient
  ) internal returns (uint256[] memory claimedAmounts) {
    claimedAmounts = new uint256[](tokens.length);
    for (uint256 i = 0; i < tokens.length; i++) {
      address token = tokens[i];

      uint256 claimable = amounts[i] - claimed[infoHash][token];
      if (claimable > 0) {
        claimed[infoHash][token] += claimable;
        claimedAmounts[i] = claimable;

        token.safeTransfer(recipient, claimable);
      }
    }
  }

  function _creditRewards(
    bytes32 infoHash,
    address[] calldata tokens,
    uint256[] calldata amounts,
    address recipient
  ) internal returns (uint256[] memory claimedAmounts) {
    claimedAmounts = new uint256[](tokens.length);
    for (uint256 i = 0; i < tokens.length; i++) {
      address token = tokens[i];

      uint256 claimable = amounts[i] - claimed[infoHash][token];
      if (claimable > 0) {
        claimed[infoHash][token] += claimable;
        claimedAmounts[i] = claimable;

        _addPendingReward(recipient, token, claimable);
      }
    }
  }

  function _addPendingReward(address recipient, address token, uint256 amount) internal {
    if (amount == 0) {
      return;
    }

    TransientSlot.Uint256Slot amountSlot =
      PENDING_REWARDS_STORAGE.deriveMapping(recipient).deriveMapping(token).asUint256();
    uint256 previousAmount = amountSlot.tload();
    amountSlot.tstore(previousAmount + amount);

    if (previousAmount == 0) {
      TransientSlot.Uint256Slot recipientsLengthSlot = PENDING_REWARDS_STORAGE.offset(1).asUint256();
      uint256 recipientsLength = recipientsLengthSlot.tload();
      recipientsLengthSlot.tstore(recipientsLength + 1);

      bytes32 recipientsSlot = PENDING_REWARDS_STORAGE.offset(1).deriveArray();
      recipientsSlot.offset(recipientsLength).asAddress().tstore(recipient);

      bytes32 tokensSlot = PENDING_REWARDS_STORAGE.offset(2).deriveArray();
      tokensSlot.offset(recipientsLength).asAddress().tstore(token);
    }
  }

  function _transferPendingRewards() internal {
    TransientSlot.Uint256Slot recipientsLengthSlot = PENDING_REWARDS_STORAGE.offset(1).asUint256();
    uint256 recipientsLength = recipientsLengthSlot.tload();
    recipientsLengthSlot.tstore(0);

    bytes32 recipientsSlot = PENDING_REWARDS_STORAGE.offset(1).deriveArray();
    bytes32 tokensSlot = PENDING_REWARDS_STORAGE.offset(2).deriveArray();

    for (uint256 i = 0; i < recipientsLength; i++) {
      address recipient = recipientsSlot.offset(i).asAddress().tload();
      address token = tokensSlot.offset(i).asAddress().tload();

      TransientSlot.Uint256Slot amountSlot =
        PENDING_REWARDS_STORAGE.deriveMapping(recipient).deriveMapping(token).asUint256();
      uint256 amount = amountSlot.tload();
      amountSlot.tstore(0);

      if (amount > 0) {
        token.safeTransfer(recipient, amount);
      }
    }
  }
}

// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

interface IKSDistributor {
  /// @notice Emitted when a new campaign is created
  event CampaignCreated(
    bytes32 indexed campaignId, uint256 startTimestamp, uint256 endTimestamp, string metadata
  );

  /// @notice Emitted when the Merkle root of a campaign is applied
  event RootApplied(bytes32 indexed campaignId, bytes32 oldRoot, bytes32 newRoot);

  /// @notice Emitted when a pending Merkle root of a campaign is submitted
  event RootSubmitted(bytes32 indexed campaignId, bytes32 pendingRoot, uint256 effectiveTimestamp);

  /// @notice Emitted when the default time lock is updated
  event DefaultTimeLockUpdated(uint256 oldTime, uint256 newTime);

  /// @notice Emitted when startTimestamp of a campaign is updated
  event StartTimestampUpdated(bytes32 indexed campaignId, uint256 oldTime, uint256 newTime);

  /// @notice Emitted when endTimestamp of a campaign is updated
  event EndTimestampUpdated(bytes32 indexed campaignId, uint256 oldTime, uint256 newTime);

  /// @notice Emitted when metadata of a campaign is updated
  event MetadataUpdated(bytes32 indexed campaignId, string oldMetadata, string newMetadata);

  /// @notice Emitted when a hook and its selector is whitelisted
  event WhitelistedHookUpdated(address indexed hook, bytes4 indexed selector, bool grantOrRevoke);

  /// @notice Emitted when rewards are claimed for an account
  event RewardsClaimedForAccount(
    bytes32 indexed campaignId,
    address indexed account,
    bytes32 root,
    address[] tokens,
    uint256[] amounts,
    address recipient
  );

  /// @notice Emitted when rewards are claimed for an ERC721 token
  event RewardsClaimedForERC721(
    bytes32 indexed campaignId,
    address indexed erc721Addr,
    uint256 indexed erc721Id,
    address claimant,
    bytes32 root,
    address[] tokens,
    uint256[] amounts,
    address recipient
  );

  /// @notice Thrown when the campaign has too short duration
  error TooShortDuration();

  /// @notice Thrown when the campaign does not exist
  error CampaignDoesNotExist(bytes32 campaignId);

  /// @notice Thrown when a campaign already exists
  error CampaignAlreadyExists(bytes32 campaignId);

  /// @notice Thrown when the pending root effective timestamp is invalid
  error InvalidEffectiveTimestamp();

  /// @notice Thrown when the campaign has not started yet
  error TooEarly();

  /// @notice Thrown when the campaign has ended
  error TooLate();

  /// @notice Thrown when the input lengths are invalid
  error InvalidLengths();

  /// @notice Thrown when the proof is invalid
  error InvalidProof();

  /// @notice Thrown when the claimant is not nft's owner
  error UnauthorizedClaimant(address claimant);

  /// @notice Thrown when the selector is invalid
  error InvalidSelector(bytes4 selector);

  /// @notice Throw when the hookData is invalid
  error InvalidHookData(bytes hookData);

  /// @notice Thrown when the hook and its selector is not whitelisted
  error NotWhitelistedHook(address hook, bytes4 selector);

  struct Campaign {
    uint256 startTimestamp;
    uint256 endTimestamp;
    string metadata;
  }

  struct PendingRoot {
    bytes32 root;
    uint256 effectiveTimestamp;
  }

  /**
   * @notice Returns the default time lock for the campaign
   */
  function defaultTimeLock() external view returns (uint256);

  /**
   * @notice Returns the information of a campaign
   * @param campaignId the unique id of the campaign
   * @return startTimestamp the timestamp when the campaign starts
   * @return endTimestamp the timestamp when the campaign ends
   * @return metadata the metadata of the campaign
   */
  function campaigns(bytes32 campaignId)
    external
    view
    returns (uint256 startTimestamp, uint256 endTimestamp, string memory metadata);

  /**
   * @notice Returns the Merkle root of a campaign
   * @param campaignId the unique id of the campaign
   */
  function roots(bytes32 campaignId) external view returns (bytes32);

  /**
   * @notice Returns the pending Merkle root of a campaign
   * @param campaignId the unique id of the campaign
   * @return root the pending Merkle root
   * @return effectiveTimestamp the timestamp when the pending root will be effective
   */
  function pendingRoots(bytes32 campaignId)
    external
    view
    returns (bytes32 root, uint256 effectiveTimestamp);

  /**
   * @notice Updates the default time lock for the campaign
   * @param newTimeLock the new default time lock in seconds
   */
  function updateDefaultTimeLock(uint256 newTimeLock) external;

  /**
   * @notice Creates a new campaign
   * @param startTimestamp the start timestamp of the campaign
   * @param endTimestamp the end timestamp of the campaign
   * @param metadata the metadata of the campaign
   * @param salt the salt for campaignId creation
   * @return campaignId the unique id of the campaign
   */
  function createCampaign(
    uint256 startTimestamp,
    uint256 endTimestamp,
    string calldata metadata,
    bytes32 salt
  ) external returns (bytes32 campaignId);

  /**
   * @notice Submit the Merkle root of a campaign
   * @param campaignId the unique id of the campaign
   * @param newRoot the new Merkle root
   * @param effectiveTimestamp the timestamp when the new root will be effective
   */
  function submitRoot(bytes32 campaignId, bytes32 newRoot, uint256 effectiveTimestamp) external;

  /**
   * @notice Force apply the Merkle root of a campaign
   * @param campaignId the unique id of the campaign
   * @param newRoot the new Merkle root
   */
  function forceUpdateRoot(bytes32 campaignId, bytes32 newRoot) external;

  /**
   * @notice Updates startTimestamp of a campaign
   * @param campaignId the unique id of the campaign
   * @param startTimestamp the new startTimestamp
   */
  function updateStartTimestamp(bytes32 campaignId, uint256 startTimestamp) external;

  /**
   * @notice Updates endTimestamp of a campaign
   * @param campaignId the unique id of the campaign
   * @param endTimestamp the new endTimestamp
   */
  function updateEndTimestamp(bytes32 campaignId, uint256 endTimestamp) external;

  /**
   * @notice Updates metadata of a campaign
   * @param campaignId the unique id of the campaign
   * @param metadata the new metadata
   */
  function updateMetadata(bytes32 campaignId, string calldata metadata) external;

  /**
   * @notice Returns whether a hook and its selector is whitelisted
   * @param hook the address of the hook
   * @param selector the selector of the hook
   */
  function whitelistedHooks(address hook, bytes4 selector) external view returns (bool);

  /**
   * @notice Grants or revokes a hook whitelisting
   * @param hooks the addresses of the hooks
   * @param selectors the selectors of the hooks
   * @param grantOrRevoke true to grant, false to revoke
   */
  function updateWhitelistedHooks(
    address[] calldata hooks,
    bytes4[] calldata selectors,
    bool grantOrRevoke
  ) external;

  /**
   * @notice Returns the claimed amount for an account in a campaign
   * @param campaignId the unique id of the campaign
   * @param account the address of the account
   * @param token the address of the reward token
   */
  function getClaimedAmountForAccount(bytes32 campaignId, address account, address token)
    external
    view
    returns (uint256);

  /**
   * @notice Returns the claimed amount for an ERC721 token in a campaign
   * @param campaignId the unique id of the campaign
   * @param erc721Addr the address of the ERC721 contract
   * @param erc721Id the campaignId of the ERC721 token
   * @param token the address of the reward token
   */
  function getClaimedAmountForERC721(
    bytes32 campaignId,
    address erc721Addr,
    uint256 erc721Id,
    address token
  ) external view returns (uint256);

  /**
   * @notice Claims rewards for an account in a campaign
   * @param campaignId the unique id of the campaign
   * @param tokens the addresses of the reward tokens
   * @param amounts the cumulative amounts of rewards
   * @param proof the Merkle proof
   * @param recipient the address of the recipient
   */
  function claimRewardsForAccount(
    bytes32 campaignId,
    address[] calldata tokens,
    uint256[] calldata amounts,
    bytes32[] calldata proof,
    address recipient
  ) external;

  /**
   * @notice Claims rewards for an account in a campaign with a hook
   * @param campaignId the unique id of the campaign
   * @param tokens the addresses of the reward tokens
   * @param amounts the cumulative amounts of rewards
   * @param proof the Merkle proof
   * @param recipient the address of the recipient
   * @param hook the address of the hook
   * @param hookData the data to pass to the hook
   */
  function claimRewardsForAccountWithHook(
    bytes32 campaignId,
    address[] calldata tokens,
    uint256[] calldata amounts,
    bytes32[] calldata proof,
    address recipient,
    address hook,
    bytes calldata hookData
  ) external;

  /**
   * @notice Claims rewards for an ERC721 token in a campaign
   * @param campaignId the unique id of the campaign
   * @param erc721Addr the address of the ERC721 contract
   * @param erc721Id the campaignId of the ERC721 token
   * @param tokens the addresses of the reward tokens
   * @param amounts the cumulative amounts of rewards
   * @param proof the Merkle proof
   * @param recipient the address of the recipient
   */
  function claimRewardsForERC721(
    bytes32 campaignId,
    address erc721Addr,
    uint256 erc721Id,
    address[] calldata tokens,
    uint256[] calldata amounts,
    bytes32[] calldata proof,
    address recipient
  ) external;

  /**
   * @notice Claims rewards for an ERC721 token in a campaign with a hook
   * @param campaignId the unique id of the campaign
   * @param erc721Addr the address of the ERC721 contract
   * @param erc721Id the campaignId of the ERC721 token
   * @param tokens the addresses of the reward tokens
   * @param amounts the cumulative amounts of rewards
   * @param proof the Merkle proof
   * @param recipient the address of the recipient
   * @param hook the address of the hook
   * @param hookData the data to pass to the hook
   */
  function claimRewardsForERC721WithHook(
    bytes32 campaignId,
    address erc721Addr,
    uint256 erc721Id,
    address[] calldata tokens,
    uint256[] calldata amounts,
    bytes32[] calldata proof,
    address recipient,
    address hook,
    bytes calldata hookData
  ) external;

  /**
   * @notice Claims rewards in a batch
   * @param datas the datas to call in order to claim rewards
   */
  function batchClaimRewards(bytes[] calldata datas) external;

  /**
   * @notice Claims rewards in a batch with a hook
   * @param datas the datas to call in order to claim rewards
   * @param hook the address of the hook
   * @param hookData the data to pass to the hook
   */
  function batchClaimRewardsWithHook(bytes[] calldata datas, address hook, bytes calldata hookData)
    external;
}

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

import 'ks-common-sc/src/libraries/calldata/CalldataDecoder.sol';

/// @title Library for decoding claim data
library ClaimDataDecoder {
  using CalldataDecoder for bytes;

  function decodeClaimRewardsForAccountData(bytes calldata _bytes)
    internal
    pure
    returns (
      bytes32 campaignId,
      address[] calldata tokens,
      uint256[] calldata amounts,
      bytes32[] calldata proof,
      address recipient
    )
  {
    assembly ("memory-safe") {
      campaignId := calldataload(_bytes.offset)
      recipient := calldataload(add(_bytes.offset, 0x80))
    }
    tokens = _bytes.decodeAddressArray(1);
    amounts = _bytes.decodeUint256Array(2);
    proof = _bytes.decodeBytes32Array(3);
  }

  function decodeClaimRewardsForERC721Data(bytes calldata _bytes)
    internal
    pure
    returns (
      bytes32 campaignId,
      address erc721Addr,
      uint256 erc721Id,
      address[] calldata tokens,
      uint256[] calldata amounts,
      bytes32[] calldata proof,
      address recipient
    )
  {
    assembly ("memory-safe") {
      campaignId := calldataload(_bytes.offset)
      erc721Addr := calldataload(add(_bytes.offset, 0x20))
      erc721Id := calldataload(add(_bytes.offset, 0x40))
      recipient := calldataload(add(_bytes.offset, 0xc0))
    }
    tokens = _bytes.decodeAddressArray(3);
    amounts = _bytes.decodeUint256Array(4);
    proof = _bytes.decodeBytes32Array(5);
  }
}

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

import {Common} from './Common.sol';

import {IManagementBase} from '../interfaces/IManagementBase.sol';

import {AccessControlDefaultAdminRules} from
  'openzeppelin-contracts/contracts/access/extensions/AccessControlDefaultAdminRules.sol';

contract ManagementBase is AccessControlDefaultAdminRules, Common, IManagementBase {
  modifier onlyRoleOrDefaultAdmin(bytes32 role) {
    if (!hasRole(role, _msgSender()) && !hasRole(DEFAULT_ADMIN_ROLE, _msgSender())) {
      revert AccessControlUnauthorizedAccount(_msgSender(), role);
    }
    _;
  }

  constructor(uint48 initialDelay, address initialAdmin)
    AccessControlDefaultAdminRules(initialDelay, initialAdmin)
  {}

  /// @inheritdoc IManagementBase
  function transferOwnership(address newOwner) external onlyRole(DEFAULT_ADMIN_ROLE) {
    _revokeRole(DEFAULT_ADMIN_ROLE, _msgSender());
    _grantRole(DEFAULT_ADMIN_ROLE, newOwner);
  }

  /// @inheritdoc IManagementBase
  function batchGrantRole(bytes32 role, address[] memory accounts)
    external
    onlyRole(getRoleAdmin(role))
  {
    _batchGrantRole(role, accounts);
  }

  /// @dev See {batchGrantRole}
  /// Internal function without access restriction.
  function _batchGrantRole(bytes32 role, address[] memory accounts) internal {
    for (uint256 i = 0; i < accounts.length; i++) {
      _grantRole(role, accounts[i]);
    }
  }

  /// @inheritdoc IManagementBase
  function batchRevokeRole(bytes32 role, address[] memory accounts)
    external
    onlyRole(getRoleAdmin(role))
  {
    _batchRevokeRole(role, accounts);
  }

  /// @dev See {batchRevokeRole}
  /// Internal function without access restriction.
  function _batchRevokeRole(bytes32 role, address[] memory accounts) internal {
    for (uint256 i = 0; i < accounts.length; i++) {
      _revokeRole(role, accounts[i]);
    }
  }
}

File 5 of 38 : ManagementPausable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IManagementPausable} from '../interfaces/IManagementPausable.sol';

import {KSRoles} from '../libraries/KSRoles.sol';
import {ManagementBase} from './ManagementBase.sol';

import {Pausable} from 'openzeppelin-contracts/contracts/utils/Pausable.sol';

abstract contract ManagementPausable is ManagementBase, IManagementPausable, Pausable {
  /// @inheritdoc IManagementPausable
  function pause() external onlyRoleOrDefaultAdmin(KSRoles.GUARDIAN_ROLE) {
    _pause();
  }

  /// @inheritdoc IManagementPausable
  function unpause() external onlyRole(DEFAULT_ADMIN_ROLE) {
    _unpause();
  }
}

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

import {IManagementRescuable} from '../interfaces/IManagementRescuable.sol';

import {KSRoles} from '../libraries/KSRoles.sol';
import {TokenHelper} from '../libraries/token/TokenHelper.sol';
import {ManagementBase} from './ManagementBase.sol';

import {IERC1155} from 'openzeppelin-contracts/contracts/token/ERC1155/IERC1155.sol';
import {IERC721} from 'openzeppelin-contracts/contracts/token/ERC721/IERC721.sol';

abstract contract ManagementRescuable is ManagementBase, IManagementRescuable {
  using TokenHelper for address;

  /// @inheritdoc IManagementRescuable
  function rescueERC20s(address[] calldata tokens, uint256[] memory amounts, address recipient)
    external
    onlyRoleOrDefaultAdmin(KSRoles.RESCUER_ROLE)
    checkAddress(recipient)
    checkLengths(tokens.length, amounts.length)
  {
    for (uint256 i = 0; i < tokens.length; i++) {
      amounts[i] = _transferERC20(tokens[i], amounts[i], recipient);
    }

    emit RescueERC20s(tokens, amounts, recipient);
  }

  /// @inheritdoc IManagementRescuable
  function rescueERC721s(IERC721[] calldata tokens, uint256[] calldata tokenIds, address recipient)
    external
    onlyRoleOrDefaultAdmin(KSRoles.RESCUER_ROLE)
    checkAddress(recipient)
    checkLengths(tokens.length, tokenIds.length)
  {
    for (uint256 i = 0; i < tokens.length; i++) {
      tokens[i].safeTransferFrom(address(this), recipient, tokenIds[i]);
    }

    emit RescueERC721s(tokens, tokenIds, recipient);
  }

  /// @inheritdoc IManagementRescuable
  function rescueERC1155s(
    IERC1155[] calldata tokens,
    uint256[] calldata tokenIds,
    uint256[] calldata amounts,
    bytes[] calldata datas,
    address recipient
  )
    external
    onlyRoleOrDefaultAdmin(KSRoles.RESCUER_ROLE)
    checkAddress(recipient)
    checkLengths(tokens.length, tokenIds.length)
    checkLengths(tokens.length, amounts.length)
    checkLengths(tokens.length, datas.length)
  {
    for (uint256 i = 0; i < tokens.length; i++) {
      _transferERC1155(tokens[i], tokenIds[i], amounts[i], datas[i], recipient);
    }

    emit RescueERC1155s(tokens, tokenIds, amounts, recipient);
  }

  function _transferERC20(address token, uint256 amount, address recipient)
    internal
    returns (uint256)
  {
    if (amount == 0) {
      amount = token.balanceOf(address(this));
    }
    token.safeTransfer(recipient, amount);

    return amount;
  }

  function _transferERC1155(
    IERC1155 token,
    uint256 tokenId,
    uint256 amount,
    bytes memory data,
    address recipient
  ) internal {
    if (amount == 0) {
      amount = token.balanceOf(address(this), tokenId);
    }
    token.safeTransferFrom(address(this), recipient, tokenId, amount, data);
  }
}

File 7 of 38 : KSRoles.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @title Library for managing roles for KyberSwap
library KSRoles {
  /// @notice Role for the operators
  bytes32 internal constant OPERATOR_ROLE = keccak256('OPERATOR_ROLE');

  /// @notice Role for the guardians
  bytes32 internal constant GUARDIAN_ROLE = keccak256('GUARDIAN_ROLE');

  /// @notice Role for the rescuers
  bytes32 internal constant RESCUER_ROLE = keccak256('RESCUER_ROLE');
}

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

import {CustomRevert} from '../CustomRevert.sol';

import {IERC20} from 'openzeppelin-contracts/contracts/interfaces/IERC20.sol';

/// @title Library for transferring, approving and holding native tokens and ERC20 tokens
/// @dev This library is based on CurrencyLibrary.sol from Uniswap/v4-core and SafeTransferLib.sol from transmissions11/solmate
library TokenHelper {
  /// @notice Additional context for ERC-7751 wrapped error when a native transfer fails
  error NativeTransferFailed();

  /// @notice Additional context for ERC-7751 wrapped error when an ERC20 transfer fails
  error ERC20TransferFailed();

  /// @notice Additional context for ERC-7751 wrapped error when an ERC20 approve fails
  error ERC20ApproveFailed();

  address constant NATIVE_ADDRESS = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;

  function isNative(address token) internal pure returns (bool) {
    return token == NATIVE_ADDRESS;
  }

  function safeTransferNative(address to, uint256 amount) internal {
    if (amount == 0) return;

    bool success;
    assembly ("memory-safe") {
      // Transfer the ETH and revert if it fails.
      success := call(gas(), to, amount, 0, 0, 0, 0)
    }
    // revert with NativeTransferFailed, containing the bubbled up error as an argument
    if (!success) {
      CustomRevert.bubbleUpAndRevertWith(to, bytes4(0), NativeTransferFailed.selector);
    }
  }

  function safeTransferERC20(address token, address to, uint256 amount) internal {
    if (amount == 0) return;

    bool success;
    assembly ("memory-safe") {
      // Get a pointer to some free memory.
      let fmp := mload(0x40)

      // Write the abi-encoded calldata into memory, beginning with the function selector.
      mstore(fmp, 0xa9059cbb00000000000000000000000000000000000000000000000000000000)
      mstore(add(fmp, 4), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument.
      mstore(add(fmp, 36), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type.

      success :=
        and(
          // Set success to whether the call reverted, if not we check it either
          // returned exactly 1 (can't just be non-zero data), or had no return data.
          or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
          // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
          // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
          // Counterintuitively, this call must be positioned second to the or() call in the
          // surrounding and() call or else returndatasize() will be zero during the computation.
          call(gas(), token, 0, fmp, 68, 0, 32)
        )

      // Now clean the memory we used
      mstore(fmp, 0) // 4 byte `selector` and 28 bytes of `to` were stored here
      mstore(add(fmp, 0x20), 0) // 4 bytes of `to` and 28 bytes of `amount` were stored here
      mstore(add(fmp, 0x40), 0) // 4 bytes of `amount` were stored here
    }
    // revert with ERC20TransferFailed, containing the bubbled up error as an argument
    if (!success) {
      CustomRevert.bubbleUpAndRevertWith(
        token, IERC20.transfer.selector, ERC20TransferFailed.selector
      );
    }
  }

  function safeTransfer(address token, address to, uint256 amount) internal {
    if (isNative(token)) {
      safeTransferNative(to, amount);
    } else {
      safeTransferERC20(token, to, amount);
    }
  }

  function safeTransferFrom(address token, address from, address to, uint256 amount) internal {
    bool success;
    assembly ("memory-safe") {
      // Get a pointer to some free memory.
      let fmp := mload(0x40)

      // Write the abi-encoded calldata into memory, beginning with the function selector.
      mstore(fmp, 0x23b872dd00000000000000000000000000000000000000000000000000000000)
      mstore(add(fmp, 4), and(from, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "from" argument.
      mstore(add(fmp, 36), and(to, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "to" argument.
      mstore(add(fmp, 68), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type.

      success :=
        and(
          // Set success to whether the call reverted, if not we check it either
          // returned exactly 1 (can't just be non-zero data), or had no return data.
          or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
          // We use 100 because the length of our calldata totals up like so: 4 + 32 * 3.
          // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
          // Counterintuitively, this call must be positioned second to the or() call in the
          // surrounding and() call or else returndatasize() will be zero during the computation.
          call(gas(), token, 0, fmp, 100, 0, 32)
        )

      // Now clean the memory we used
      mstore(fmp, 0) // 4 byte `selector` and 28 bytes of `from` were stored here
      mstore(add(fmp, 0x20), 0) // 4 bytes of `from` and 28 bytes of `to` were stored here
      mstore(add(fmp, 0x40), 0) // 4 bytes of `to` and 28 bytes of `amount` were stored here
      mstore(add(fmp, 0x60), 0) // 4 bytes of `amount` were stored here
    }
    // revert with ERC20TransferFailed, containing the bubbled up error as an argument
    if (!success) {
      CustomRevert.bubbleUpAndRevertWith(
        token, IERC20.transferFrom.selector, ERC20TransferFailed.selector
      );
    }
  }

  function trySafeApprove(address token, address spender, uint256 amount)
    internal
    returns (bool success)
  {
    assembly ("memory-safe") {
      // Get a pointer to some free memory.
      let fmp := mload(0x40)

      // Write the abi-encoded calldata into memory, beginning with the function selector.
      mstore(fmp, 0x095ea7b300000000000000000000000000000000000000000000000000000000)
      mstore(add(fmp, 4), and(spender, 0xffffffffffffffffffffffffffffffffffffffff)) // Append and mask the "spender" argument.
      mstore(add(fmp, 36), amount) // Append the "amount" argument. Masking not required as it's a full 32 byte type.

      success :=
        and(
          // Set success to whether the call reverted, if not we check it either
          // returned exactly 1 (can't just be non-zero data), or had no return data.
          or(and(eq(mload(0), 1), gt(returndatasize(), 31)), iszero(returndatasize())),
          // We use 68 because the length of our calldata totals up like so: 4 + 32 * 2.
          // We use 0 and 32 to copy up to 32 bytes of return data into the scratch space.
          // Counterintuitively, this call must be positioned second to the or() call in the
          // surrounding and() call or else returndatasize() will be zero during the computation.
          call(gas(), token, 0, fmp, 68, 0, 32)
        )

      // Now clean the memory we used
      mstore(fmp, 0) // 4 byte `selector` and 28 bytes of `to` were stored here
      mstore(add(fmp, 0x20), 0) // 4 bytes of `to` and 28 bytes of `amount` were stored here
      mstore(add(fmp, 0x40), 0) // 4 bytes of `amount` were stored here
    }
  }

  function safeApprove(address token, address spender, uint256 amount) internal {
    // revert with ERC20ApproveFailed, containing the bubbled up error as an argument
    if (!trySafeApprove(token, spender, amount)) {
      CustomRevert.bubbleUpAndRevertWith(
        token, IERC20.approve.selector, ERC20ApproveFailed.selector
      );
    }
  }

  function forceApprove(address token, address spender, uint256 amount) internal {
    // 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
    if (!trySafeApprove(token, spender, amount)) {
      safeApprove(token, spender, 0);
      safeApprove(token, spender, amount);
    }
  }

  function balanceOf(address token, address account) internal view returns (uint256) {
    if (isNative(token)) {
      return account.balance;
    } else {
      return IERC20(token).balanceOf(account);
    }
  }

  function selfBalance(address token) internal view returns (uint256) {
    if (isNative(token)) {
      return address(this).balance;
    } else {
      return IERC20(token).balanceOf(address(this));
    }
  }
}

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

pragma solidity ^0.8.20;

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

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev There's no code at `target` (it is not a contract).
     */
    error AddressEmptyCode(address target);

    /**
     * @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 Errors.InsufficientBalance(address(this).balance, amount);
        }

        (bool success, bytes memory returndata) = recipient.call{value: amount}("");
        if (!success) {
            _revert(returndata);
        }
    }

    /**
     * @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
     * {Errors.FailedCall} 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 Errors.InsufficientBalance(address(this).balance, value);
        }
        (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 {Errors.FailedCall}) 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 {Errors.FailedCall} 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 {Errors.FailedCall}.
     */
    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
            assembly ("memory-safe") {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert Errors.FailedCall();
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/ReentrancyGuardTransient.sol)

pragma solidity ^0.8.24;

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

/**
 * @dev Variant of {ReentrancyGuard} that uses transient storage.
 *
 * NOTE: This variant only works on networks where EIP-1153 is available.
 *
 * _Available since v5.1._
 */
abstract contract ReentrancyGuardTransient {
    using TransientSlot for *;

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.ReentrancyGuard")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant REENTRANCY_GUARD_STORAGE =
        0x9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f00;

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

    /**
     * @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, REENTRANCY_GUARD_STORAGE.asBoolean().tload() will be false
        if (_reentrancyGuardEntered()) {
            revert ReentrancyGuardReentrantCall();
        }

        // Any calls to nonReentrant after this point will fail
        REENTRANCY_GUARD_STORAGE.asBoolean().tstore(true);
    }

    function _nonReentrantAfter() private {
        REENTRANCY_GUARD_STORAGE.asBoolean().tstore(false);
    }

    /**
     * @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 REENTRANCY_GUARD_STORAGE.asBoolean().tload();
    }
}

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

pragma solidity ^0.8.20;

/**
 * @dev Library for computing storage (and transient storage) locations from namespaces and deriving slots
 * corresponding to standard patterns. The derivation method for array and mapping matches the storage layout used by
 * the solidity language / compiler.
 *
 * See https://docs.soliditylang.org/en/v0.8.20/internals/layout_in_storage.html#mappings-and-dynamic-arrays[Solidity docs for mappings and dynamic arrays.].
 *
 * Example usage:
 * ```solidity
 * contract Example {
 *     // Add the library methods
 *     using StorageSlot for bytes32;
 *     using SlotDerivation for bytes32;
 *
 *     // Declare a namespace
 *     string private constant _NAMESPACE = "<namespace>"; // eg. OpenZeppelin.Slot
 *
 *     function setValueInNamespace(uint256 key, address newValue) internal {
 *         _NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value = newValue;
 *     }
 *
 *     function getValueInNamespace(uint256 key) internal view returns (address) {
 *         return _NAMESPACE.erc7201Slot().deriveMapping(key).getAddressSlot().value;
 *     }
 * }
 * ```
 *
 * TIP: Consider using this library along with {StorageSlot}.
 *
 * NOTE: This library provides a way to manipulate storage locations in a non-standard way. Tooling for checking
 * upgrade safety will ignore the slots accessed through this library.
 *
 * _Available since v5.1._
 */
library SlotDerivation {
    /**
     * @dev Derive an ERC-7201 slot from a string (namespace).
     */
    function erc7201Slot(string memory namespace) internal pure returns (bytes32 slot) {
        assembly ("memory-safe") {
            mstore(0x00, sub(keccak256(add(namespace, 0x20), mload(namespace)), 1))
            slot := and(keccak256(0x00, 0x20), not(0xff))
        }
    }

    /**
     * @dev Add an offset to a slot to get the n-th element of a structure or an array.
     */
    function offset(bytes32 slot, uint256 pos) internal pure returns (bytes32 result) {
        unchecked {
            return bytes32(uint256(slot) + pos);
        }
    }

    /**
     * @dev Derive the location of the first element in an array from the slot where the length is stored.
     */
    function deriveArray(bytes32 slot) internal pure returns (bytes32 result) {
        assembly ("memory-safe") {
            mstore(0x00, slot)
            result := keccak256(0x00, 0x20)
        }
    }

    /**
     * @dev Derive the location of a mapping element from the key.
     */
    function deriveMapping(bytes32 slot, address key) internal pure returns (bytes32 result) {
        assembly ("memory-safe") {
            mstore(0x00, and(key, shr(96, not(0))))
            mstore(0x20, slot)
            result := keccak256(0x00, 0x40)
        }
    }

    /**
     * @dev Derive the location of a mapping element from the key.
     */
    function deriveMapping(bytes32 slot, bool key) internal pure returns (bytes32 result) {
        assembly ("memory-safe") {
            mstore(0x00, iszero(iszero(key)))
            mstore(0x20, slot)
            result := keccak256(0x00, 0x40)
        }
    }

    /**
     * @dev Derive the location of a mapping element from the key.
     */
    function deriveMapping(bytes32 slot, bytes32 key) internal pure returns (bytes32 result) {
        assembly ("memory-safe") {
            mstore(0x00, key)
            mstore(0x20, slot)
            result := keccak256(0x00, 0x40)
        }
    }

    /**
     * @dev Derive the location of a mapping element from the key.
     */
    function deriveMapping(bytes32 slot, uint256 key) internal pure returns (bytes32 result) {
        assembly ("memory-safe") {
            mstore(0x00, key)
            mstore(0x20, slot)
            result := keccak256(0x00, 0x40)
        }
    }

    /**
     * @dev Derive the location of a mapping element from the key.
     */
    function deriveMapping(bytes32 slot, int256 key) internal pure returns (bytes32 result) {
        assembly ("memory-safe") {
            mstore(0x00, key)
            mstore(0x20, slot)
            result := keccak256(0x00, 0x40)
        }
    }

    /**
     * @dev Derive the location of a mapping element from the key.
     */
    function deriveMapping(bytes32 slot, string memory key) internal pure returns (bytes32 result) {
        assembly ("memory-safe") {
            let length := mload(key)
            let begin := add(key, 0x20)
            let end := add(begin, length)
            let cache := mload(end)
            mstore(end, slot)
            result := keccak256(begin, add(length, 0x20))
            mstore(end, cache)
        }
    }

    /**
     * @dev Derive the location of a mapping element from the key.
     */
    function deriveMapping(bytes32 slot, bytes memory key) internal pure returns (bytes32 result) {
        assembly ("memory-safe") {
            let length := mload(key)
            let begin := add(key, 0x20)
            let end := add(begin, length)
            let cache := mload(end)
            mstore(end, slot)
            result := keccak256(begin, add(length, 0x20))
            mstore(end, cache)
        }
    }
}

// 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)
        }
    }
}

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

pragma solidity ^0.8.20;

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

/**
 * @dev These functions deal with verification of Merkle Tree proofs.
 *
 * The tree and the proofs can be generated using our
 * https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
 * You will find a quickstart guide in the readme.
 *
 * WARNING: You should avoid using leaf values that are 64 bytes long prior to
 * hashing, or use a hash function other than keccak256 for hashing leaves.
 * This is because the concatenation of a sorted pair of internal nodes in
 * the Merkle tree could be reinterpreted as a leaf value.
 * OpenZeppelin's JavaScript library generates Merkle trees that are safe
 * against this attack out of the box.
 *
 * IMPORTANT: Consider memory side-effects when using custom hashing functions
 * that access memory in an unsafe way.
 *
 * NOTE: This library supports proof verification for merkle trees built using
 * custom _commutative_ hashing functions (i.e. `H(a, b) == H(b, a)`). Proving
 * leaf inclusion in trees built using non-commutative hashing functions requires
 * additional logic that is not supported by this library.
 */
library MerkleProof {
    /**
     *@dev The multiproof provided is not valid.
     */
    error MerkleProofInvalidMultiproof();

    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     *
     * This version handles proofs in memory with the default hashing function.
     */
    function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
        return processProof(proof, leaf) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leaves & pre-images are assumed to be sorted.
     *
     * This version handles proofs in memory with the default hashing function.
     */
    function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = Hashes.commutativeKeccak256(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     *
     * This version handles proofs in memory with a custom hashing function.
     */
    function verify(
        bytes32[] memory proof,
        bytes32 root,
        bytes32 leaf,
        function(bytes32, bytes32) view returns (bytes32) hasher
    ) internal view returns (bool) {
        return processProof(proof, leaf, hasher) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leaves & pre-images are assumed to be sorted.
     *
     * This version handles proofs in memory with a custom hashing function.
     */
    function processProof(
        bytes32[] memory proof,
        bytes32 leaf,
        function(bytes32, bytes32) view returns (bytes32) hasher
    ) internal view returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = hasher(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     *
     * This version handles proofs in calldata with the default hashing function.
     */
    function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
        return processProofCalldata(proof, leaf) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leaves & pre-images are assumed to be sorted.
     *
     * This version handles proofs in calldata with the default hashing function.
     */
    function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = Hashes.commutativeKeccak256(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
     * defined by `root`. For this, a `proof` must be provided, containing
     * sibling hashes on the branch from the leaf to the root of the tree. Each
     * pair of leaves and each pair of pre-images are assumed to be sorted.
     *
     * This version handles proofs in calldata with a custom hashing function.
     */
    function verifyCalldata(
        bytes32[] calldata proof,
        bytes32 root,
        bytes32 leaf,
        function(bytes32, bytes32) view returns (bytes32) hasher
    ) internal view returns (bool) {
        return processProofCalldata(proof, leaf, hasher) == root;
    }

    /**
     * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up
     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
     * hash matches the root of the tree. When processing the proof, the pairs
     * of leaves & pre-images are assumed to be sorted.
     *
     * This version handles proofs in calldata with a custom hashing function.
     */
    function processProofCalldata(
        bytes32[] calldata proof,
        bytes32 leaf,
        function(bytes32, bytes32) view returns (bytes32) hasher
    ) internal view returns (bytes32) {
        bytes32 computedHash = leaf;
        for (uint256 i = 0; i < proof.length; i++) {
            computedHash = hasher(computedHash, proof[i]);
        }
        return computedHash;
    }

    /**
     * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
     *
     * This version handles multiproofs in memory with the default hashing function.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
     *
     * NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
     * The `leaves` must be validated independently. See {processMultiProof}.
     */
    function multiProofVerify(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProof(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
     * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
     * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
     * respectively.
     *
     * This version handles multiproofs in memory with the default hashing function.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
     * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
     * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
     *
     * NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
     * and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
     * validating the leaves elsewhere.
     */
    function processMultiProof(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the Merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 proofFlagsLen = proofFlags.length;

        // Check proof validity.
        if (leavesLen + proof.length != proofFlagsLen + 1) {
            revert MerkleProofInvalidMultiproof();
        }

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](proofFlagsLen);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < proofFlagsLen; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i]
                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
                : proof[proofPos++];
            hashes[i] = Hashes.commutativeKeccak256(a, b);
        }

        if (proofFlagsLen > 0) {
            if (proofPos != proof.length) {
                revert MerkleProofInvalidMultiproof();
            }
            unchecked {
                return hashes[proofFlagsLen - 1];
            }
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    /**
     * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
     *
     * This version handles multiproofs in memory with a custom hashing function.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
     *
     * NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
     * The `leaves` must be validated independently. See {processMultiProof}.
     */
    function multiProofVerify(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32 root,
        bytes32[] memory leaves,
        function(bytes32, bytes32) view returns (bytes32) hasher
    ) internal view returns (bool) {
        return processMultiProof(proof, proofFlags, leaves, hasher) == root;
    }

    /**
     * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
     * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
     * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
     * respectively.
     *
     * This version handles multiproofs in memory with a custom hashing function.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
     * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
     * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
     *
     * NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
     * and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
     * validating the leaves elsewhere.
     */
    function processMultiProof(
        bytes32[] memory proof,
        bool[] memory proofFlags,
        bytes32[] memory leaves,
        function(bytes32, bytes32) view returns (bytes32) hasher
    ) internal view returns (bytes32 merkleRoot) {
        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the Merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 proofFlagsLen = proofFlags.length;

        // Check proof validity.
        if (leavesLen + proof.length != proofFlagsLen + 1) {
            revert MerkleProofInvalidMultiproof();
        }

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](proofFlagsLen);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < proofFlagsLen; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i]
                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
                : proof[proofPos++];
            hashes[i] = hasher(a, b);
        }

        if (proofFlagsLen > 0) {
            if (proofPos != proof.length) {
                revert MerkleProofInvalidMultiproof();
            }
            unchecked {
                return hashes[proofFlagsLen - 1];
            }
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    /**
     * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
     *
     * This version handles multiproofs in calldata with the default hashing function.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
     *
     * NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
     * The `leaves` must be validated independently. See {processMultiProofCalldata}.
     */
    function multiProofVerifyCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32 root,
        bytes32[] memory leaves
    ) internal pure returns (bool) {
        return processMultiProofCalldata(proof, proofFlags, leaves) == root;
    }

    /**
     * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
     * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
     * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
     * respectively.
     *
     * This version handles multiproofs in calldata with the default hashing function.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
     * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
     * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
     *
     * NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
     * and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
     * validating the leaves elsewhere.
     */
    function processMultiProofCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32[] memory leaves
    ) internal pure returns (bytes32 merkleRoot) {
        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the Merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 proofFlagsLen = proofFlags.length;

        // Check proof validity.
        if (leavesLen + proof.length != proofFlagsLen + 1) {
            revert MerkleProofInvalidMultiproof();
        }

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](proofFlagsLen);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < proofFlagsLen; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i]
                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
                : proof[proofPos++];
            hashes[i] = Hashes.commutativeKeccak256(a, b);
        }

        if (proofFlagsLen > 0) {
            if (proofPos != proof.length) {
                revert MerkleProofInvalidMultiproof();
            }
            unchecked {
                return hashes[proofFlagsLen - 1];
            }
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }

    /**
     * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a Merkle tree defined by
     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.
     *
     * This version handles multiproofs in calldata with a custom hashing function.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. See {processMultiProof} for details.
     *
     * NOTE: Consider the case where `root == proof[0] && leaves.length == 0` as it will return `true`.
     * The `leaves` must be validated independently. See {processMultiProofCalldata}.
     */
    function multiProofVerifyCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32 root,
        bytes32[] memory leaves,
        function(bytes32, bytes32) view returns (bytes32) hasher
    ) internal view returns (bool) {
        return processMultiProofCalldata(proof, proofFlags, leaves, hasher) == root;
    }

    /**
     * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction
     * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another
     * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false
     * respectively.
     *
     * This version handles multiproofs in calldata with a custom hashing function.
     *
     * CAUTION: Not all Merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree
     * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the
     * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).
     *
     * NOTE: The _empty set_ (i.e. the case where `proof.length == 1 && leaves.length == 0`) is considered a no-op,
     * and therefore a valid multiproof (i.e. it returns `proof[0]`). Consider disallowing this case if you're not
     * validating the leaves elsewhere.
     */
    function processMultiProofCalldata(
        bytes32[] calldata proof,
        bool[] calldata proofFlags,
        bytes32[] memory leaves,
        function(bytes32, bytes32) view returns (bytes32) hasher
    ) internal view returns (bytes32 merkleRoot) {
        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by
        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the
        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of
        // the Merkle tree.
        uint256 leavesLen = leaves.length;
        uint256 proofFlagsLen = proofFlags.length;

        // Check proof validity.
        if (leavesLen + proof.length != proofFlagsLen + 1) {
            revert MerkleProofInvalidMultiproof();
        }

        // The xxxPos values are "pointers" to the next value to consume in each array. All accesses are done using
        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's "pop".
        bytes32[] memory hashes = new bytes32[](proofFlagsLen);
        uint256 leafPos = 0;
        uint256 hashPos = 0;
        uint256 proofPos = 0;
        // At each step, we compute the next hash using two values:
        // - a value from the "main queue". If not all leaves have been consumed, we get the next leaf, otherwise we
        //   get the next hash.
        // - depending on the flag, either another value from the "main queue" (merging branches) or an element from the
        //   `proof` array.
        for (uint256 i = 0; i < proofFlagsLen; i++) {
            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];
            bytes32 b = proofFlags[i]
                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])
                : proof[proofPos++];
            hashes[i] = hasher(a, b);
        }

        if (proofFlagsLen > 0) {
            if (proofPos != proof.length) {
                revert MerkleProofInvalidMultiproof();
            }
            unchecked {
                return hashes[proofFlagsLen - 1];
            }
        } else if (leavesLen > 0) {
            return leaves[0];
        } else {
            return proof[0];
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC-721 compliant contract.
 */
interface IERC721 is IERC165 {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
     *   a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC-721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or
     *   {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
     *   a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC-721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(address from, address to, uint256 tokenId) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the address zero.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}

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

/// @title Library for abi decoding in calldata
library CalldataDecoder {
  error SliceOutOfBounds();

  /// @notice mask used for offsets and lengths to ensure no overflow
  /// @dev no sane abi encoding will pass in an offset or length greater than type(uint32).max
  ///      (note that this does deviate from standard solidity behavior and offsets/lengths will
  ///      be interpreted as mod type(uint32).max which will only impact malicious/buggy callers)
  uint256 constant OFFSET_OR_LENGTH_MASK = 0xffffffff;
  uint256 constant OFFSET_OR_LENGTH_MASK_AND_WORD_ALIGN = 0xffffffe0;

  /// @notice equivalent to SliceOutOfBounds.selector, stored in least-significant bits
  uint256 constant SLICE_ERROR_SELECTOR = 0x3b99b53d;

  function decodeAddress(bytes calldata data) internal pure returns (address value) {
    assembly ("memory-safe") {
      value := calldataload(data.offset)
    }
  }

  function decodeUint256(bytes calldata data) internal pure returns (uint256 value) {
    assembly ("memory-safe") {
      value := calldataload(data.offset)
    }
  }

  function decodeBool(bytes calldata data) internal pure returns (bool value) {
    assembly ("memory-safe") {
      value := calldataload(data.offset)
    }
  }

  function decodeBytes32(bytes calldata data) internal pure returns (bytes32 value) {
    assembly ("memory-safe") {
      value := calldataload(data.offset)
    }
  }

  /// @notice Decode the `_arg`-th element in `_bytes` as a dynamic array
  /// @dev The decoding of `length` and `offset` is universal,
  /// whereas the type declaration of `res` instructs the compiler how to read it.
  /// @param _bytes The input bytes string to slice
  /// @param _arg The index of the argument to extract
  /// @return length Length of the array
  /// @return offset Pointer to the data part of the array
  function decodeLengthOffset(bytes calldata _bytes, uint256 _arg)
    internal
    pure
    returns (uint256 length, uint256 offset)
  {
    assembly ("memory-safe") {
      // The offset of the `_arg`-th element is `32 * arg`, which stores the offset of the length pointer.
      // shl(5, x) is equivalent to mul(32, x)
      let lengthPtr := add(_bytes.offset, calldataload(add(_bytes.offset, shl(5, _arg))))
      length := calldataload(lengthPtr)
      offset := add(lengthPtr, 0x20)

      // if the provided bytes string isnt as long as the encoding says, revert
      if lt(add(_bytes.length, _bytes.offset), add(length, offset)) {
        mstore(0, SLICE_ERROR_SELECTOR)
        revert(0x1c, 4)
      }
    }
  }

  /// @notice Decode the `_arg`-th element in `_bytes` as `bytes`
  /// @param _bytes The input bytes string to extract a bytes string from
  /// @param _arg The index of the argument to extract
  function decodeBytes(bytes calldata _bytes, uint256 _arg)
    internal
    pure
    returns (bytes calldata res)
  {
    (uint256 length, uint256 offset) = decodeLengthOffset(_bytes, _arg);
    assembly ("memory-safe") {
      res.length := length
      res.offset := offset
    }
  }

  /// @notice Decode the `_arg`-th element in `_bytes` as `uint256[]`
  /// @param _bytes The input bytes string to extract a uint256 array from
  /// @param _arg The index of the argument to extract
  function decodeUint256Array(bytes calldata _bytes, uint256 _arg)
    internal
    pure
    returns (uint256[] calldata res)
  {
    (uint256 length, uint256 offset) = decodeLengthOffset(_bytes, _arg);
    assembly ("memory-safe") {
      res.length := length
      res.offset := offset
    }
  }

  /// @notice Decode the `_arg`-th element in `_bytes` as `address[]`
  /// @param _bytes The input bytes string to extract an address array from
  /// @param _arg The index of the argument to extract
  function decodeAddressArray(bytes calldata _bytes, uint256 _arg)
    internal
    pure
    returns (address[] calldata res)
  {
    (uint256 length, uint256 offset) = decodeLengthOffset(_bytes, _arg);
    assembly ("memory-safe") {
      res.length := length
      res.offset := offset
    }
  }

  /// @notice Decode the `_arg`-th element in `_bytes` as `bytes32[]`
  /// @param _bytes The input bytes string to extract a bytes32 array from
  /// @param _arg The index of the argument to extract
  function decodeBytes32Array(bytes calldata _bytes, uint256 _arg)
    internal
    pure
    returns (bytes32[] calldata res)
  {
    (uint256 length, uint256 offset) = decodeLengthOffset(_bytes, _arg);
    assembly ("memory-safe") {
      res.length := length
      res.offset := offset
    }
  }
}

File 16 of 38 : Common.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {ICommon} from '../interfaces/ICommon.sol';

contract Common is ICommon {
  modifier checkAddress(address addr) {
    require(addr != address(0), InvalidAddress());
    _;
  }

  modifier checkLengths(uint256 length1, uint256 length2) {
    require(length1 == length2, MismatchedArrayLengths());
    _;
  }
}

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

import {IERC1155} from 'openzeppelin-contracts/contracts/token/ERC1155/IERC1155.sol';
import {IERC721} from 'openzeppelin-contracts/contracts/token/ERC721/IERC721.sol';

interface IManagementBase {
  /// @notice Transfer {defaultAdmin} to a new account
  /// @dev Mimics the {Ownable-transferOwnership} function
  /// @param newOwner The new {defaultAdmin}
  function transferOwnership(address newOwner) external;

  /// @notice Batch grant roles to multiple accounts
  /// @param role The role to grant
  /// @param accounts The accounts to grant the role to
  function batchGrantRole(bytes32 role, address[] memory accounts) external;

  /// @notice Batch revoke roles from multiple accounts
  /// @param role The role to revoke
  /// @param accounts The accounts to revoke the role from
  function batchRevokeRole(bytes32 role, address[] memory accounts) external;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/extensions/AccessControlDefaultAdminRules.sol)

pragma solidity ^0.8.20;

import {IAccessControlDefaultAdminRules} from "./IAccessControlDefaultAdminRules.sol";
import {AccessControl, IAccessControl} from "../AccessControl.sol";
import {SafeCast} from "../../utils/math/SafeCast.sol";
import {Math} from "../../utils/math/Math.sol";
import {IERC5313} from "../../interfaces/IERC5313.sol";

/**
 * @dev Extension of {AccessControl} that allows specifying special rules to manage
 * the `DEFAULT_ADMIN_ROLE` holder, which is a sensitive role with special permissions
 * over other roles that may potentially have privileged rights in the system.
 *
 * If a specific role doesn't have an admin role assigned, the holder of the
 * `DEFAULT_ADMIN_ROLE` will have the ability to grant it and revoke it.
 *
 * This contract implements the following risk mitigations on top of {AccessControl}:
 *
 * * Only one account holds the `DEFAULT_ADMIN_ROLE` since deployment until it's potentially renounced.
 * * Enforces a 2-step process to transfer the `DEFAULT_ADMIN_ROLE` to another account.
 * * Enforces a configurable delay between the two steps, with the ability to cancel before the transfer is accepted.
 * * The delay can be changed by scheduling, see {changeDefaultAdminDelay}.
 * * It is not possible to use another role to manage the `DEFAULT_ADMIN_ROLE`.
 *
 * Example usage:
 *
 * ```solidity
 * contract MyToken is AccessControlDefaultAdminRules {
 *   constructor() AccessControlDefaultAdminRules(
 *     3 days,
 *     msg.sender // Explicit initial `DEFAULT_ADMIN_ROLE` holder
 *    ) {}
 * }
 * ```
 */
abstract contract AccessControlDefaultAdminRules is IAccessControlDefaultAdminRules, IERC5313, AccessControl {
    // pending admin pair read/written together frequently
    address private _pendingDefaultAdmin;
    uint48 private _pendingDefaultAdminSchedule; // 0 == unset

    uint48 private _currentDelay;
    address private _currentDefaultAdmin;

    // pending delay pair read/written together frequently
    uint48 private _pendingDelay;
    uint48 private _pendingDelaySchedule; // 0 == unset

    /**
     * @dev Sets the initial values for {defaultAdminDelay} and {defaultAdmin} address.
     */
    constructor(uint48 initialDelay, address initialDefaultAdmin) {
        if (initialDefaultAdmin == address(0)) {
            revert AccessControlInvalidDefaultAdmin(address(0));
        }
        _currentDelay = initialDelay;
        _grantRole(DEFAULT_ADMIN_ROLE, initialDefaultAdmin);
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControlDefaultAdminRules).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev See {IERC5313-owner}.
     */
    function owner() public view virtual returns (address) {
        return defaultAdmin();
    }

    ///
    /// Override AccessControl role management
    ///

    /**
     * @dev See {AccessControl-grantRole}. Reverts for `DEFAULT_ADMIN_ROLE`.
     */
    function grantRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {
        if (role == DEFAULT_ADMIN_ROLE) {
            revert AccessControlEnforcedDefaultAdminRules();
        }
        super.grantRole(role, account);
    }

    /**
     * @dev See {AccessControl-revokeRole}. Reverts for `DEFAULT_ADMIN_ROLE`.
     */
    function revokeRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {
        if (role == DEFAULT_ADMIN_ROLE) {
            revert AccessControlEnforcedDefaultAdminRules();
        }
        super.revokeRole(role, account);
    }

    /**
     * @dev See {AccessControl-renounceRole}.
     *
     * For the `DEFAULT_ADMIN_ROLE`, it only allows renouncing in two steps by first calling
     * {beginDefaultAdminTransfer} to the `address(0)`, so it's required that the {pendingDefaultAdmin} schedule
     * has also passed when calling this function.
     *
     * After its execution, it will not be possible to call `onlyRole(DEFAULT_ADMIN_ROLE)` functions.
     *
     * NOTE: Renouncing `DEFAULT_ADMIN_ROLE` will leave the contract without a {defaultAdmin},
     * thereby disabling any functionality that is only available for it, and the possibility of reassigning a
     * non-administrated role.
     */
    function renounceRole(bytes32 role, address account) public virtual override(AccessControl, IAccessControl) {
        if (role == DEFAULT_ADMIN_ROLE && account == defaultAdmin()) {
            (address newDefaultAdmin, uint48 schedule) = pendingDefaultAdmin();
            if (newDefaultAdmin != address(0) || !_isScheduleSet(schedule) || !_hasSchedulePassed(schedule)) {
                revert AccessControlEnforcedDefaultAdminDelay(schedule);
            }
            delete _pendingDefaultAdminSchedule;
        }
        super.renounceRole(role, account);
    }

    /**
     * @dev See {AccessControl-_grantRole}.
     *
     * For `DEFAULT_ADMIN_ROLE`, it only allows granting if there isn't already a {defaultAdmin} or if the
     * role has been previously renounced.
     *
     * NOTE: Exposing this function through another mechanism may make the `DEFAULT_ADMIN_ROLE`
     * assignable again. Make sure to guarantee this is the expected behavior in your implementation.
     */
    function _grantRole(bytes32 role, address account) internal virtual override returns (bool) {
        if (role == DEFAULT_ADMIN_ROLE) {
            if (defaultAdmin() != address(0)) {
                revert AccessControlEnforcedDefaultAdminRules();
            }
            _currentDefaultAdmin = account;
        }
        return super._grantRole(role, account);
    }

    /**
     * @dev See {AccessControl-_revokeRole}.
     */
    function _revokeRole(bytes32 role, address account) internal virtual override returns (bool) {
        if (role == DEFAULT_ADMIN_ROLE && account == defaultAdmin()) {
            delete _currentDefaultAdmin;
        }
        return super._revokeRole(role, account);
    }

    /**
     * @dev See {AccessControl-_setRoleAdmin}. Reverts for `DEFAULT_ADMIN_ROLE`.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual override {
        if (role == DEFAULT_ADMIN_ROLE) {
            revert AccessControlEnforcedDefaultAdminRules();
        }
        super._setRoleAdmin(role, adminRole);
    }

    ///
    /// AccessControlDefaultAdminRules accessors
    ///

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function defaultAdmin() public view virtual returns (address) {
        return _currentDefaultAdmin;
    }

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function pendingDefaultAdmin() public view virtual returns (address newAdmin, uint48 schedule) {
        return (_pendingDefaultAdmin, _pendingDefaultAdminSchedule);
    }

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function defaultAdminDelay() public view virtual returns (uint48) {
        uint48 schedule = _pendingDelaySchedule;
        return (_isScheduleSet(schedule) && _hasSchedulePassed(schedule)) ? _pendingDelay : _currentDelay;
    }

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function pendingDefaultAdminDelay() public view virtual returns (uint48 newDelay, uint48 schedule) {
        schedule = _pendingDelaySchedule;
        return (_isScheduleSet(schedule) && !_hasSchedulePassed(schedule)) ? (_pendingDelay, schedule) : (0, 0);
    }

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function defaultAdminDelayIncreaseWait() public view virtual returns (uint48) {
        return 5 days;
    }

    ///
    /// AccessControlDefaultAdminRules public and internal setters for defaultAdmin/pendingDefaultAdmin
    ///

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function beginDefaultAdminTransfer(address newAdmin) public virtual onlyRole(DEFAULT_ADMIN_ROLE) {
        _beginDefaultAdminTransfer(newAdmin);
    }

    /**
     * @dev See {beginDefaultAdminTransfer}.
     *
     * Internal function without access restriction.
     */
    function _beginDefaultAdminTransfer(address newAdmin) internal virtual {
        uint48 newSchedule = SafeCast.toUint48(block.timestamp) + defaultAdminDelay();
        _setPendingDefaultAdmin(newAdmin, newSchedule);
        emit DefaultAdminTransferScheduled(newAdmin, newSchedule);
    }

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function cancelDefaultAdminTransfer() public virtual onlyRole(DEFAULT_ADMIN_ROLE) {
        _cancelDefaultAdminTransfer();
    }

    /**
     * @dev See {cancelDefaultAdminTransfer}.
     *
     * Internal function without access restriction.
     */
    function _cancelDefaultAdminTransfer() internal virtual {
        _setPendingDefaultAdmin(address(0), 0);
    }

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function acceptDefaultAdminTransfer() public virtual {
        (address newDefaultAdmin, ) = pendingDefaultAdmin();
        if (_msgSender() != newDefaultAdmin) {
            // Enforce newDefaultAdmin explicit acceptance.
            revert AccessControlInvalidDefaultAdmin(_msgSender());
        }
        _acceptDefaultAdminTransfer();
    }

    /**
     * @dev See {acceptDefaultAdminTransfer}.
     *
     * Internal function without access restriction.
     */
    function _acceptDefaultAdminTransfer() internal virtual {
        (address newAdmin, uint48 schedule) = pendingDefaultAdmin();
        if (!_isScheduleSet(schedule) || !_hasSchedulePassed(schedule)) {
            revert AccessControlEnforcedDefaultAdminDelay(schedule);
        }
        _revokeRole(DEFAULT_ADMIN_ROLE, defaultAdmin());
        _grantRole(DEFAULT_ADMIN_ROLE, newAdmin);
        delete _pendingDefaultAdmin;
        delete _pendingDefaultAdminSchedule;
    }

    ///
    /// AccessControlDefaultAdminRules public and internal setters for defaultAdminDelay/pendingDefaultAdminDelay
    ///

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function changeDefaultAdminDelay(uint48 newDelay) public virtual onlyRole(DEFAULT_ADMIN_ROLE) {
        _changeDefaultAdminDelay(newDelay);
    }

    /**
     * @dev See {changeDefaultAdminDelay}.
     *
     * Internal function without access restriction.
     */
    function _changeDefaultAdminDelay(uint48 newDelay) internal virtual {
        uint48 newSchedule = SafeCast.toUint48(block.timestamp) + _delayChangeWait(newDelay);
        _setPendingDelay(newDelay, newSchedule);
        emit DefaultAdminDelayChangeScheduled(newDelay, newSchedule);
    }

    /**
     * @inheritdoc IAccessControlDefaultAdminRules
     */
    function rollbackDefaultAdminDelay() public virtual onlyRole(DEFAULT_ADMIN_ROLE) {
        _rollbackDefaultAdminDelay();
    }

    /**
     * @dev See {rollbackDefaultAdminDelay}.
     *
     * Internal function without access restriction.
     */
    function _rollbackDefaultAdminDelay() internal virtual {
        _setPendingDelay(0, 0);
    }

    /**
     * @dev Returns the amount of seconds to wait after the `newDelay` will
     * become the new {defaultAdminDelay}.
     *
     * The value returned guarantees that if the delay is reduced, it will go into effect
     * after a wait that honors the previously set delay.
     *
     * See {defaultAdminDelayIncreaseWait}.
     */
    function _delayChangeWait(uint48 newDelay) internal view virtual returns (uint48) {
        uint48 currentDelay = defaultAdminDelay();

        // When increasing the delay, we schedule the delay change to occur after a period of "new delay" has passed, up
        // to a maximum given by defaultAdminDelayIncreaseWait, by default 5 days. For example, if increasing from 1 day
        // to 3 days, the new delay will come into effect after 3 days. If increasing from 1 day to 10 days, the new
        // delay will come into effect after 5 days. The 5 day wait period is intended to be able to fix an error like
        // using milliseconds instead of seconds.
        //
        // When decreasing the delay, we wait the difference between "current delay" and "new delay". This guarantees
        // that an admin transfer cannot be made faster than "current delay" at the time the delay change is scheduled.
        // For example, if decreasing from 10 days to 3 days, the new delay will come into effect after 7 days.
        return
            newDelay > currentDelay
                ? uint48(Math.min(newDelay, defaultAdminDelayIncreaseWait())) // no need to safecast, both inputs are uint48
                : currentDelay - newDelay;
    }

    ///
    /// Private setters
    ///

    /**
     * @dev Setter of the tuple for pending admin and its schedule.
     *
     * May emit a DefaultAdminTransferCanceled event.
     */
    function _setPendingDefaultAdmin(address newAdmin, uint48 newSchedule) private {
        (, uint48 oldSchedule) = pendingDefaultAdmin();

        _pendingDefaultAdmin = newAdmin;
        _pendingDefaultAdminSchedule = newSchedule;

        // An `oldSchedule` from `pendingDefaultAdmin()` is only set if it hasn't been accepted.
        if (_isScheduleSet(oldSchedule)) {
            // Emit for implicit cancellations when another default admin was scheduled.
            emit DefaultAdminTransferCanceled();
        }
    }

    /**
     * @dev Setter of the tuple for pending delay and its schedule.
     *
     * May emit a DefaultAdminDelayChangeCanceled event.
     */
    function _setPendingDelay(uint48 newDelay, uint48 newSchedule) private {
        uint48 oldSchedule = _pendingDelaySchedule;

        if (_isScheduleSet(oldSchedule)) {
            if (_hasSchedulePassed(oldSchedule)) {
                // Materialize a virtual delay
                _currentDelay = _pendingDelay;
            } else {
                // Emit for implicit cancellations when another delay was scheduled.
                emit DefaultAdminDelayChangeCanceled();
            }
        }

        _pendingDelay = newDelay;
        _pendingDelaySchedule = newSchedule;
    }

    ///
    /// Private helpers
    ///

    /**
     * @dev Defines if an `schedule` is considered set. For consistency purposes.
     */
    function _isScheduleSet(uint48 schedule) private pure returns (bool) {
        return schedule != 0;
    }

    /**
     * @dev Defines if an `schedule` is considered passed. For consistency purposes.
     */
    function _hasSchedulePassed(uint48 schedule) private view returns (bool) {
        return schedule < block.timestamp;
    }
}

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

interface IManagementPausable {
  /// @notice Pause the contract
  function pause() external;

  /// @notice Unpause the contract
  function unpause() external;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/Pausable.sol)

pragma solidity ^0.8.20;

import {Context} from "../utils/Context.sol";

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract Pausable is Context {
    bool private _paused;

    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    /**
     * @dev The operation failed because the contract is paused.
     */
    error EnforcedPause();

    /**
     * @dev The operation failed because the contract is not paused.
     */
    error ExpectedPause();

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        _requireNotPaused();
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        _requirePaused();
        _;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        if (paused()) {
            revert EnforcedPause();
        }
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        if (!paused()) {
            revert ExpectedPause();
        }
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
}

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

import {IERC1155} from 'openzeppelin-contracts/contracts/token/ERC1155/IERC1155.sol';
import {IERC721} from 'openzeppelin-contracts/contracts/token/ERC721/IERC721.sol';

interface IManagementRescuable {
  /// @notice Emitted when some of ERC20 tokens are rescued
  event RescueERC20s(address[] tokens, uint256[] amounts, address recipient);

  /// @notice Emitted when some of ERC721 tokens are rescued
  event RescueERC721s(IERC721[] tokens, uint256[] tokenIds, address recipient);

  /// @notice Emitted when some of ERC1155 tokens are rescued
  event RescueERC1155s(IERC1155[] tokens, uint256[] tokenIds, uint256[] amounts, address recipient);

  /**
   * @notice Rescue some of ERC20 tokens stuck in the contract
   * @notice Can only be called by the current owner
   * @param tokens the addresses of the tokens to rescue
   * @param amounts the amounts of the tokens to rescue, set to 0 to rescue all
   * @param recipient the address to send the tokens to
   */
  function rescueERC20s(address[] calldata tokens, uint256[] memory amounts, address recipient)
    external;

  /**
   * @notice Rescue some of ERC721 tokens stuck in the contract
   * @notice Can only be called by the current owner
   * @param tokens the addresses of the tokens to rescue
   * @param tokenIds the IDs of the tokens to rescue
   * @param recipient the address to send the tokens to
   */
  function rescueERC721s(IERC721[] calldata tokens, uint256[] calldata tokenIds, address recipient)
    external;

  /**
   * @notice Rescue some of ERC1155 tokens stuck in the contract
   * @notice Can only be called by the current owner
   * @param tokens the addresses of the tokens to rescue
   * @param tokenIds the IDs of the tokens to rescue
   * @param amounts the amounts of the tokens to rescue, set to 0 to rescue all
   * @param datas additional data to `safeTransferFrom`
   * @param recipient the address to send the tokens to
   */
  function rescueERC1155s(
    IERC1155[] calldata tokens,
    uint256[] calldata tokenIds,
    uint256[] calldata amounts,
    bytes[] calldata datas,
    address recipient
  ) external;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.20;

import {IERC165} from "../../utils/introspection/IERC165.sol";

/**
 * @dev Required interface of an ERC-1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[ERC].
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` amount of tokens of type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

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

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(
        address[] calldata accounts,
        uint256[] calldata ids
    ) external view returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the zero address.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`.
     *
     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens
     * to an untrusted contract, when invoking {IERC1155Receiver-onERC1155Received} on the receiver.
     * Ensure to follow the checks-effects-interactions pattern and consider employing
     * reentrancy guards when interacting with untrusted contracts.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `value` amount.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens
     * to an untrusted contract, when invoking {IERC1155Receiver-onERC1155BatchReceived} on the receiver.
     * Ensure to follow the checks-effects-interactions pattern and consider employing
     * reentrancy guards when interacting with untrusted contracts.
     *
     * Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments.
     *
     * Requirements:
     *
     * - `ids` and `values` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external;
}

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

/// @title Library for reverting with custom errors efficiently
/// @notice Contains functions for reverting with custom errors with different argument types efficiently
/// @dev To use this library, declare `using CustomRevert for bytes4;` and replace `revert CustomError()` with
/// `CustomError.selector.revertWith()`
/// @dev The functions may tamper with the free memory pointer but it is fine since the call context is exited immediately
library CustomRevert {
  /// @dev ERC-7751 error for wrapping bubbled up reverts
  error WrappedError(address target, bytes4 selector, bytes reason, bytes details);

  /// @dev Reverts with the selector of a custom error in the scratch space
  function revertWith(bytes4 selector) internal pure {
    assembly ("memory-safe") {
      mstore(0, selector)
      revert(0, 0x04)
    }
  }

  /// @dev Reverts with a custom error with an address argument in the scratch space
  function revertWith(bytes4 selector, address addr) internal pure {
    assembly ("memory-safe") {
      mstore(0, selector)
      mstore(0x04, and(addr, 0xffffffffffffffffffffffffffffffffffffffff))
      revert(0, 0x24)
    }
  }

  /// @dev Reverts with a custom error with an int24 argument in the scratch space
  function revertWith(bytes4 selector, int24 value) internal pure {
    assembly ("memory-safe") {
      mstore(0, selector)
      mstore(0x04, signextend(2, value))
      revert(0, 0x24)
    }
  }

  /// @dev Reverts with a custom error with a uint160 argument in the scratch space
  function revertWith(bytes4 selector, uint160 value) internal pure {
    assembly ("memory-safe") {
      mstore(0, selector)
      mstore(0x04, and(value, 0xffffffffffffffffffffffffffffffffffffffff))
      revert(0, 0x24)
    }
  }

  /// @dev Reverts with a custom error with two int24 arguments
  function revertWith(bytes4 selector, int24 value1, int24 value2) internal pure {
    assembly ("memory-safe") {
      let fmp := mload(0x40)
      mstore(fmp, selector)
      mstore(add(fmp, 0x04), signextend(2, value1))
      mstore(add(fmp, 0x24), signextend(2, value2))
      revert(fmp, 0x44)
    }
  }

  /// @dev Reverts with a custom error with two uint160 arguments
  function revertWith(bytes4 selector, uint160 value1, uint160 value2) internal pure {
    assembly ("memory-safe") {
      let fmp := mload(0x40)
      mstore(fmp, selector)
      mstore(add(fmp, 0x04), and(value1, 0xffffffffffffffffffffffffffffffffffffffff))
      mstore(add(fmp, 0x24), and(value2, 0xffffffffffffffffffffffffffffffffffffffff))
      revert(fmp, 0x44)
    }
  }

  /// @dev Reverts with a custom error with two address arguments
  function revertWith(bytes4 selector, address value1, address value2) internal pure {
    assembly ("memory-safe") {
      let fmp := mload(0x40)
      mstore(fmp, selector)
      mstore(add(fmp, 0x04), and(value1, 0xffffffffffffffffffffffffffffffffffffffff))
      mstore(add(fmp, 0x24), and(value2, 0xffffffffffffffffffffffffffffffffffffffff))
      revert(fmp, 0x44)
    }
  }

  /// @notice bubble up the revert message returned by a call and revert with a wrapped ERC-7751 error
  /// @dev this method can be vulnerable to revert data bombs
  function bubbleUpAndRevertWith(
    address revertingContract,
    bytes4 revertingFunctionSelector,
    bytes4 additionalContext
  ) internal pure {
    bytes4 wrappedErrorSelector = WrappedError.selector;
    assembly ("memory-safe") {
      // Ensure the size of the revert data is a multiple of 32 bytes
      let encodedDataSize := mul(div(add(returndatasize(), 31), 32), 32)

      let fmp := mload(0x40)

      // Encode wrapped error selector, address, function selector, offset, additional context, size, revert reason
      mstore(fmp, wrappedErrorSelector)
      mstore(add(fmp, 0x04), and(revertingContract, 0xffffffffffffffffffffffffffffffffffffffff))
      mstore(
        add(fmp, 0x24),
        and(
          revertingFunctionSelector,
          0xffffffff00000000000000000000000000000000000000000000000000000000
        )
      )
      // offset revert reason
      mstore(add(fmp, 0x44), 0x80)
      // offset additional context
      mstore(add(fmp, 0x64), add(0xa0, encodedDataSize))
      // size revert reason
      mstore(add(fmp, 0x84), returndatasize())
      // revert reason
      returndatacopy(add(fmp, 0xa4), 0, returndatasize())
      // size additional context
      mstore(add(fmp, add(0xa4, encodedDataSize)), 0x04)
      // additional context
      mstore(
        add(fmp, add(0xc4, encodedDataSize)),
        and(additionalContext, 0xffffffff00000000000000000000000000000000000000000000000000000000)
      )
      revert(fmp, add(0xe4, encodedDataSize))
    }
  }
}

File 24 of 38 : IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)

pragma solidity ^0.8.20;

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

File 25 of 38 : Errors.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of common custom errors used in multiple contracts
 *
 * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
 * It is recommended to avoid relying on the error API for critical functionality.
 *
 * _Available since v5.1._
 */
library Errors {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error InsufficientBalance(uint256 balance, uint256 needed);

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

    /**
     * @dev The deployment failed.
     */
    error FailedDeployment();

    /**
     * @dev A necessary precompile is missing.
     */
    error MissingPrecompile(address);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/cryptography/Hashes.sol)

pragma solidity ^0.8.20;

/**
 * @dev Library of standard hash functions.
 *
 * _Available since v5.1._
 */
library Hashes {
    /**
     * @dev Commutative Keccak256 hash of a sorted pair of bytes32. Frequently used when working with merkle proofs.
     *
     * NOTE: Equivalent to the `standardNodeHash` in our https://github.com/OpenZeppelin/merkle-tree[JavaScript library].
     */
    function commutativeKeccak256(bytes32 a, bytes32 b) internal pure returns (bytes32) {
        return a < b ? efficientKeccak256(a, b) : efficientKeccak256(b, a);
    }

    /**
     * @dev Implementation of keccak256(abi.encode(a, b)) that doesn't allocate or expand memory.
     */
    function efficientKeccak256(bytes32 a, bytes32 b) internal pure returns (bytes32 value) {
        assembly ("memory-safe") {
            mstore(0x00, a)
            mstore(0x20, b)
            value := keccak256(0x00, 0x40)
        }
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[ERC].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165 {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 28 of 38 : ICommon.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

/// @title ICommon
/// @notice Common interface for all contracts
interface ICommon {
  /// @notice Thrown when trying to update with zero address
  error InvalidAddress();

  /// @notice Thrown when the lengths of the arrays are mismatched
  error MismatchedArrayLengths();
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/extensions/IAccessControlDefaultAdminRules.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev External interface of AccessControlDefaultAdminRules declared to support ERC-165 detection.
 */
interface IAccessControlDefaultAdminRules is IAccessControl {
    /**
     * @dev The new default admin is not a valid default admin.
     */
    error AccessControlInvalidDefaultAdmin(address defaultAdmin);

    /**
     * @dev At least one of the following rules was violated:
     *
     * - The `DEFAULT_ADMIN_ROLE` must only be managed by itself.
     * - The `DEFAULT_ADMIN_ROLE` must only be held by one account at the time.
     * - Any `DEFAULT_ADMIN_ROLE` transfer must be in two delayed steps.
     */
    error AccessControlEnforcedDefaultAdminRules();

    /**
     * @dev The delay for transferring the default admin delay is enforced and
     * the operation must wait until `schedule`.
     *
     * NOTE: `schedule` can be 0 indicating there's no transfer scheduled.
     */
    error AccessControlEnforcedDefaultAdminDelay(uint48 schedule);

    /**
     * @dev Emitted when a {defaultAdmin} transfer is started, setting `newAdmin` as the next
     * address to become the {defaultAdmin} by calling {acceptDefaultAdminTransfer} only after `acceptSchedule`
     * passes.
     */
    event DefaultAdminTransferScheduled(address indexed newAdmin, uint48 acceptSchedule);

    /**
     * @dev Emitted when a {pendingDefaultAdmin} is reset if it was never accepted, regardless of its schedule.
     */
    event DefaultAdminTransferCanceled();

    /**
     * @dev Emitted when a {defaultAdminDelay} change is started, setting `newDelay` as the next
     * delay to be applied between default admin transfer after `effectSchedule` has passed.
     */
    event DefaultAdminDelayChangeScheduled(uint48 newDelay, uint48 effectSchedule);

    /**
     * @dev Emitted when a {pendingDefaultAdminDelay} is reset if its schedule didn't pass.
     */
    event DefaultAdminDelayChangeCanceled();

    /**
     * @dev Returns the address of the current `DEFAULT_ADMIN_ROLE` holder.
     */
    function defaultAdmin() external view returns (address);

    /**
     * @dev Returns a tuple of a `newAdmin` and an accept schedule.
     *
     * After the `schedule` passes, the `newAdmin` will be able to accept the {defaultAdmin} role
     * by calling {acceptDefaultAdminTransfer}, completing the role transfer.
     *
     * A zero value only in `acceptSchedule` indicates no pending admin transfer.
     *
     * NOTE: A zero address `newAdmin` means that {defaultAdmin} is being renounced.
     */
    function pendingDefaultAdmin() external view returns (address newAdmin, uint48 acceptSchedule);

    /**
     * @dev Returns the delay required to schedule the acceptance of a {defaultAdmin} transfer started.
     *
     * This delay will be added to the current timestamp when calling {beginDefaultAdminTransfer} to set
     * the acceptance schedule.
     *
     * NOTE: If a delay change has been scheduled, it will take effect as soon as the schedule passes, making this
     * function returns the new delay. See {changeDefaultAdminDelay}.
     */
    function defaultAdminDelay() external view returns (uint48);

    /**
     * @dev Returns a tuple of `newDelay` and an effect schedule.
     *
     * After the `schedule` passes, the `newDelay` will get into effect immediately for every
     * new {defaultAdmin} transfer started with {beginDefaultAdminTransfer}.
     *
     * A zero value only in `effectSchedule` indicates no pending delay change.
     *
     * NOTE: A zero value only for `newDelay` means that the next {defaultAdminDelay}
     * will be zero after the effect schedule.
     */
    function pendingDefaultAdminDelay() external view returns (uint48 newDelay, uint48 effectSchedule);

    /**
     * @dev Starts a {defaultAdmin} transfer by setting a {pendingDefaultAdmin} scheduled for acceptance
     * after the current timestamp plus a {defaultAdminDelay}.
     *
     * Requirements:
     *
     * - Only can be called by the current {defaultAdmin}.
     *
     * Emits a DefaultAdminRoleChangeStarted event.
     */
    function beginDefaultAdminTransfer(address newAdmin) external;

    /**
     * @dev Cancels a {defaultAdmin} transfer previously started with {beginDefaultAdminTransfer}.
     *
     * A {pendingDefaultAdmin} not yet accepted can also be cancelled with this function.
     *
     * Requirements:
     *
     * - Only can be called by the current {defaultAdmin}.
     *
     * May emit a DefaultAdminTransferCanceled event.
     */
    function cancelDefaultAdminTransfer() external;

    /**
     * @dev Completes a {defaultAdmin} transfer previously started with {beginDefaultAdminTransfer}.
     *
     * After calling the function:
     *
     * - `DEFAULT_ADMIN_ROLE` should be granted to the caller.
     * - `DEFAULT_ADMIN_ROLE` should be revoked from the previous holder.
     * - {pendingDefaultAdmin} should be reset to zero values.
     *
     * Requirements:
     *
     * - Only can be called by the {pendingDefaultAdmin}'s `newAdmin`.
     * - The {pendingDefaultAdmin}'s `acceptSchedule` should've passed.
     */
    function acceptDefaultAdminTransfer() external;

    /**
     * @dev Initiates a {defaultAdminDelay} update by setting a {pendingDefaultAdminDelay} scheduled for getting
     * into effect after the current timestamp plus a {defaultAdminDelay}.
     *
     * This function guarantees that any call to {beginDefaultAdminTransfer} done between the timestamp this
     * method is called and the {pendingDefaultAdminDelay} effect schedule will use the current {defaultAdminDelay}
     * set before calling.
     *
     * The {pendingDefaultAdminDelay}'s effect schedule is defined in a way that waiting until the schedule and then
     * calling {beginDefaultAdminTransfer} with the new delay will take at least the same as another {defaultAdmin}
     * complete transfer (including acceptance).
     *
     * The schedule is designed for two scenarios:
     *
     * - When the delay is changed for a larger one the schedule is `block.timestamp + newDelay` capped by
     * {defaultAdminDelayIncreaseWait}.
     * - When the delay is changed for a shorter one, the schedule is `block.timestamp + (current delay - new delay)`.
     *
     * A {pendingDefaultAdminDelay} that never got into effect will be canceled in favor of a new scheduled change.
     *
     * Requirements:
     *
     * - Only can be called by the current {defaultAdmin}.
     *
     * Emits a DefaultAdminDelayChangeScheduled event and may emit a DefaultAdminDelayChangeCanceled event.
     */
    function changeDefaultAdminDelay(uint48 newDelay) external;

    /**
     * @dev Cancels a scheduled {defaultAdminDelay} change.
     *
     * Requirements:
     *
     * - Only can be called by the current {defaultAdmin}.
     *
     * May emit a DefaultAdminDelayChangeCanceled event.
     */
    function rollbackDefaultAdminDelay() external;

    /**
     * @dev Maximum time in seconds for an increase to {defaultAdminDelay} (that is scheduled using {changeDefaultAdminDelay})
     * to take effect. Default to 5 days.
     *
     * When the {defaultAdminDelay} is scheduled to be increased, it goes into effect after the new delay has passed with
     * the purpose of giving enough time for reverting any accidental change (i.e. using milliseconds instead of seconds)
     * that may lock the contract. However, to avoid excessive schedules, the wait is capped by this function and it can
     * be overrode for a custom {defaultAdminDelay} increase scheduling.
     *
     * IMPORTANT: Make sure to add a reasonable amount of time while overriding this value, otherwise,
     * there's a risk of setting a high new delay that goes into effect almost immediately without the
     * possibility of human intervention in the case of an input error (eg. set milliseconds instead of seconds).
     */
    function defaultAdminDelayIncreaseWait() external view returns (uint48);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (access/AccessControl.sol)

pragma solidity ^0.8.20;

import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {ERC165} from "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```solidity
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```solidity
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
 * to enforce additional security measures for this role.
 */
abstract contract AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address account => bool) hasRole;
        bytes32 adminRole;
    }

    mapping(bytes32 role => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with an {AccessControlUnauthorizedAccount} error including the required role.
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual returns (bool) {
        return _roles[role].hasRole[account];
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
     * is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
     * is missing `role`.
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert AccessControlUnauthorizedAccount(account, role);
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address callerConfirmation) public virtual {
        if (callerConfirmation != _msgSender()) {
            revert AccessControlBadConfirmation();
        }

        _revokeRole(role, callerConfirmation);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
        if (!hasRole(role, account)) {
            _roles[role].hasRole[account] = true;
            emit RoleGranted(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Attempts to revoke `role` from `account` and returns a boolean indicating if `role` was revoked.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
        if (hasRole(role, account)) {
            _roles[role].hasRole[account] = false;
            emit RoleRevoked(role, account, _msgSender());
            return true;
        } else {
            return false;
        }
    }
}

File 31 of 38 : SafeCast.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/math/SafeCast.sol)
// This file was procedurally generated from scripts/generate/templates/SafeCast.js.

pragma solidity ^0.8.20;

/**
 * @dev Wrappers over Solidity's uintXX/intXX/bool casting operators with added overflow
 * checks.
 *
 * Downcasting from uint256/int256 in Solidity does not revert on overflow. This can
 * easily result in undesired exploitation or bugs, since developers usually
 * assume that overflows raise errors. `SafeCast` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 */
library SafeCast {
    /**
     * @dev Value doesn't fit in an uint of `bits` size.
     */
    error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value);

    /**
     * @dev An int value doesn't fit in an uint of `bits` size.
     */
    error SafeCastOverflowedIntToUint(int256 value);

    /**
     * @dev Value doesn't fit in an int of `bits` size.
     */
    error SafeCastOverflowedIntDowncast(uint8 bits, int256 value);

    /**
     * @dev An uint value doesn't fit in an int of `bits` size.
     */
    error SafeCastOverflowedUintToInt(uint256 value);

    /**
     * @dev Returns the downcasted uint248 from uint256, reverting on
     * overflow (when the input is greater than largest uint248).
     *
     * Counterpart to Solidity's `uint248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     */
    function toUint248(uint256 value) internal pure returns (uint248) {
        if (value > type(uint248).max) {
            revert SafeCastOverflowedUintDowncast(248, value);
        }
        return uint248(value);
    }

    /**
     * @dev Returns the downcasted uint240 from uint256, reverting on
     * overflow (when the input is greater than largest uint240).
     *
     * Counterpart to Solidity's `uint240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     */
    function toUint240(uint256 value) internal pure returns (uint240) {
        if (value > type(uint240).max) {
            revert SafeCastOverflowedUintDowncast(240, value);
        }
        return uint240(value);
    }

    /**
     * @dev Returns the downcasted uint232 from uint256, reverting on
     * overflow (when the input is greater than largest uint232).
     *
     * Counterpart to Solidity's `uint232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     */
    function toUint232(uint256 value) internal pure returns (uint232) {
        if (value > type(uint232).max) {
            revert SafeCastOverflowedUintDowncast(232, value);
        }
        return uint232(value);
    }

    /**
     * @dev Returns the downcasted uint224 from uint256, reverting on
     * overflow (when the input is greater than largest uint224).
     *
     * Counterpart to Solidity's `uint224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toUint224(uint256 value) internal pure returns (uint224) {
        if (value > type(uint224).max) {
            revert SafeCastOverflowedUintDowncast(224, value);
        }
        return uint224(value);
    }

    /**
     * @dev Returns the downcasted uint216 from uint256, reverting on
     * overflow (when the input is greater than largest uint216).
     *
     * Counterpart to Solidity's `uint216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     */
    function toUint216(uint256 value) internal pure returns (uint216) {
        if (value > type(uint216).max) {
            revert SafeCastOverflowedUintDowncast(216, value);
        }
        return uint216(value);
    }

    /**
     * @dev Returns the downcasted uint208 from uint256, reverting on
     * overflow (when the input is greater than largest uint208).
     *
     * Counterpart to Solidity's `uint208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     */
    function toUint208(uint256 value) internal pure returns (uint208) {
        if (value > type(uint208).max) {
            revert SafeCastOverflowedUintDowncast(208, value);
        }
        return uint208(value);
    }

    /**
     * @dev Returns the downcasted uint200 from uint256, reverting on
     * overflow (when the input is greater than largest uint200).
     *
     * Counterpart to Solidity's `uint200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     */
    function toUint200(uint256 value) internal pure returns (uint200) {
        if (value > type(uint200).max) {
            revert SafeCastOverflowedUintDowncast(200, value);
        }
        return uint200(value);
    }

    /**
     * @dev Returns the downcasted uint192 from uint256, reverting on
     * overflow (when the input is greater than largest uint192).
     *
     * Counterpart to Solidity's `uint192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     */
    function toUint192(uint256 value) internal pure returns (uint192) {
        if (value > type(uint192).max) {
            revert SafeCastOverflowedUintDowncast(192, value);
        }
        return uint192(value);
    }

    /**
     * @dev Returns the downcasted uint184 from uint256, reverting on
     * overflow (when the input is greater than largest uint184).
     *
     * Counterpart to Solidity's `uint184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     */
    function toUint184(uint256 value) internal pure returns (uint184) {
        if (value > type(uint184).max) {
            revert SafeCastOverflowedUintDowncast(184, value);
        }
        return uint184(value);
    }

    /**
     * @dev Returns the downcasted uint176 from uint256, reverting on
     * overflow (when the input is greater than largest uint176).
     *
     * Counterpart to Solidity's `uint176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     */
    function toUint176(uint256 value) internal pure returns (uint176) {
        if (value > type(uint176).max) {
            revert SafeCastOverflowedUintDowncast(176, value);
        }
        return uint176(value);
    }

    /**
     * @dev Returns the downcasted uint168 from uint256, reverting on
     * overflow (when the input is greater than largest uint168).
     *
     * Counterpart to Solidity's `uint168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     */
    function toUint168(uint256 value) internal pure returns (uint168) {
        if (value > type(uint168).max) {
            revert SafeCastOverflowedUintDowncast(168, value);
        }
        return uint168(value);
    }

    /**
     * @dev Returns the downcasted uint160 from uint256, reverting on
     * overflow (when the input is greater than largest uint160).
     *
     * Counterpart to Solidity's `uint160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     */
    function toUint160(uint256 value) internal pure returns (uint160) {
        if (value > type(uint160).max) {
            revert SafeCastOverflowedUintDowncast(160, value);
        }
        return uint160(value);
    }

    /**
     * @dev Returns the downcasted uint152 from uint256, reverting on
     * overflow (when the input is greater than largest uint152).
     *
     * Counterpart to Solidity's `uint152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     */
    function toUint152(uint256 value) internal pure returns (uint152) {
        if (value > type(uint152).max) {
            revert SafeCastOverflowedUintDowncast(152, value);
        }
        return uint152(value);
    }

    /**
     * @dev Returns the downcasted uint144 from uint256, reverting on
     * overflow (when the input is greater than largest uint144).
     *
     * Counterpart to Solidity's `uint144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     */
    function toUint144(uint256 value) internal pure returns (uint144) {
        if (value > type(uint144).max) {
            revert SafeCastOverflowedUintDowncast(144, value);
        }
        return uint144(value);
    }

    /**
     * @dev Returns the downcasted uint136 from uint256, reverting on
     * overflow (when the input is greater than largest uint136).
     *
     * Counterpart to Solidity's `uint136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     */
    function toUint136(uint256 value) internal pure returns (uint136) {
        if (value > type(uint136).max) {
            revert SafeCastOverflowedUintDowncast(136, value);
        }
        return uint136(value);
    }

    /**
     * @dev Returns the downcasted uint128 from uint256, reverting on
     * overflow (when the input is greater than largest uint128).
     *
     * Counterpart to Solidity's `uint128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toUint128(uint256 value) internal pure returns (uint128) {
        if (value > type(uint128).max) {
            revert SafeCastOverflowedUintDowncast(128, value);
        }
        return uint128(value);
    }

    /**
     * @dev Returns the downcasted uint120 from uint256, reverting on
     * overflow (when the input is greater than largest uint120).
     *
     * Counterpart to Solidity's `uint120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     */
    function toUint120(uint256 value) internal pure returns (uint120) {
        if (value > type(uint120).max) {
            revert SafeCastOverflowedUintDowncast(120, value);
        }
        return uint120(value);
    }

    /**
     * @dev Returns the downcasted uint112 from uint256, reverting on
     * overflow (when the input is greater than largest uint112).
     *
     * Counterpart to Solidity's `uint112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     */
    function toUint112(uint256 value) internal pure returns (uint112) {
        if (value > type(uint112).max) {
            revert SafeCastOverflowedUintDowncast(112, value);
        }
        return uint112(value);
    }

    /**
     * @dev Returns the downcasted uint104 from uint256, reverting on
     * overflow (when the input is greater than largest uint104).
     *
     * Counterpart to Solidity's `uint104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     */
    function toUint104(uint256 value) internal pure returns (uint104) {
        if (value > type(uint104).max) {
            revert SafeCastOverflowedUintDowncast(104, value);
        }
        return uint104(value);
    }

    /**
     * @dev Returns the downcasted uint96 from uint256, reverting on
     * overflow (when the input is greater than largest uint96).
     *
     * Counterpart to Solidity's `uint96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toUint96(uint256 value) internal pure returns (uint96) {
        if (value > type(uint96).max) {
            revert SafeCastOverflowedUintDowncast(96, value);
        }
        return uint96(value);
    }

    /**
     * @dev Returns the downcasted uint88 from uint256, reverting on
     * overflow (when the input is greater than largest uint88).
     *
     * Counterpart to Solidity's `uint88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     */
    function toUint88(uint256 value) internal pure returns (uint88) {
        if (value > type(uint88).max) {
            revert SafeCastOverflowedUintDowncast(88, value);
        }
        return uint88(value);
    }

    /**
     * @dev Returns the downcasted uint80 from uint256, reverting on
     * overflow (when the input is greater than largest uint80).
     *
     * Counterpart to Solidity's `uint80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     */
    function toUint80(uint256 value) internal pure returns (uint80) {
        if (value > type(uint80).max) {
            revert SafeCastOverflowedUintDowncast(80, value);
        }
        return uint80(value);
    }

    /**
     * @dev Returns the downcasted uint72 from uint256, reverting on
     * overflow (when the input is greater than largest uint72).
     *
     * Counterpart to Solidity's `uint72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     */
    function toUint72(uint256 value) internal pure returns (uint72) {
        if (value > type(uint72).max) {
            revert SafeCastOverflowedUintDowncast(72, value);
        }
        return uint72(value);
    }

    /**
     * @dev Returns the downcasted uint64 from uint256, reverting on
     * overflow (when the input is greater than largest uint64).
     *
     * Counterpart to Solidity's `uint64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toUint64(uint256 value) internal pure returns (uint64) {
        if (value > type(uint64).max) {
            revert SafeCastOverflowedUintDowncast(64, value);
        }
        return uint64(value);
    }

    /**
     * @dev Returns the downcasted uint56 from uint256, reverting on
     * overflow (when the input is greater than largest uint56).
     *
     * Counterpart to Solidity's `uint56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     */
    function toUint56(uint256 value) internal pure returns (uint56) {
        if (value > type(uint56).max) {
            revert SafeCastOverflowedUintDowncast(56, value);
        }
        return uint56(value);
    }

    /**
     * @dev Returns the downcasted uint48 from uint256, reverting on
     * overflow (when the input is greater than largest uint48).
     *
     * Counterpart to Solidity's `uint48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     */
    function toUint48(uint256 value) internal pure returns (uint48) {
        if (value > type(uint48).max) {
            revert SafeCastOverflowedUintDowncast(48, value);
        }
        return uint48(value);
    }

    /**
     * @dev Returns the downcasted uint40 from uint256, reverting on
     * overflow (when the input is greater than largest uint40).
     *
     * Counterpart to Solidity's `uint40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     */
    function toUint40(uint256 value) internal pure returns (uint40) {
        if (value > type(uint40).max) {
            revert SafeCastOverflowedUintDowncast(40, value);
        }
        return uint40(value);
    }

    /**
     * @dev Returns the downcasted uint32 from uint256, reverting on
     * overflow (when the input is greater than largest uint32).
     *
     * Counterpart to Solidity's `uint32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toUint32(uint256 value) internal pure returns (uint32) {
        if (value > type(uint32).max) {
            revert SafeCastOverflowedUintDowncast(32, value);
        }
        return uint32(value);
    }

    /**
     * @dev Returns the downcasted uint24 from uint256, reverting on
     * overflow (when the input is greater than largest uint24).
     *
     * Counterpart to Solidity's `uint24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     */
    function toUint24(uint256 value) internal pure returns (uint24) {
        if (value > type(uint24).max) {
            revert SafeCastOverflowedUintDowncast(24, value);
        }
        return uint24(value);
    }

    /**
     * @dev Returns the downcasted uint16 from uint256, reverting on
     * overflow (when the input is greater than largest uint16).
     *
     * Counterpart to Solidity's `uint16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toUint16(uint256 value) internal pure returns (uint16) {
        if (value > type(uint16).max) {
            revert SafeCastOverflowedUintDowncast(16, value);
        }
        return uint16(value);
    }

    /**
     * @dev Returns the downcasted uint8 from uint256, reverting on
     * overflow (when the input is greater than largest uint8).
     *
     * Counterpart to Solidity's `uint8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     */
    function toUint8(uint256 value) internal pure returns (uint8) {
        if (value > type(uint8).max) {
            revert SafeCastOverflowedUintDowncast(8, value);
        }
        return uint8(value);
    }

    /**
     * @dev Converts a signed int256 into an unsigned uint256.
     *
     * Requirements:
     *
     * - input must be greater than or equal to 0.
     */
    function toUint256(int256 value) internal pure returns (uint256) {
        if (value < 0) {
            revert SafeCastOverflowedIntToUint(value);
        }
        return uint256(value);
    }

    /**
     * @dev Returns the downcasted int248 from int256, reverting on
     * overflow (when the input is less than smallest int248 or
     * greater than largest int248).
     *
     * Counterpart to Solidity's `int248` operator.
     *
     * Requirements:
     *
     * - input must fit into 248 bits
     */
    function toInt248(int256 value) internal pure returns (int248 downcasted) {
        downcasted = int248(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(248, value);
        }
    }

    /**
     * @dev Returns the downcasted int240 from int256, reverting on
     * overflow (when the input is less than smallest int240 or
     * greater than largest int240).
     *
     * Counterpart to Solidity's `int240` operator.
     *
     * Requirements:
     *
     * - input must fit into 240 bits
     */
    function toInt240(int256 value) internal pure returns (int240 downcasted) {
        downcasted = int240(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(240, value);
        }
    }

    /**
     * @dev Returns the downcasted int232 from int256, reverting on
     * overflow (when the input is less than smallest int232 or
     * greater than largest int232).
     *
     * Counterpart to Solidity's `int232` operator.
     *
     * Requirements:
     *
     * - input must fit into 232 bits
     */
    function toInt232(int256 value) internal pure returns (int232 downcasted) {
        downcasted = int232(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(232, value);
        }
    }

    /**
     * @dev Returns the downcasted int224 from int256, reverting on
     * overflow (when the input is less than smallest int224 or
     * greater than largest int224).
     *
     * Counterpart to Solidity's `int224` operator.
     *
     * Requirements:
     *
     * - input must fit into 224 bits
     */
    function toInt224(int256 value) internal pure returns (int224 downcasted) {
        downcasted = int224(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(224, value);
        }
    }

    /**
     * @dev Returns the downcasted int216 from int256, reverting on
     * overflow (when the input is less than smallest int216 or
     * greater than largest int216).
     *
     * Counterpart to Solidity's `int216` operator.
     *
     * Requirements:
     *
     * - input must fit into 216 bits
     */
    function toInt216(int256 value) internal pure returns (int216 downcasted) {
        downcasted = int216(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(216, value);
        }
    }

    /**
     * @dev Returns the downcasted int208 from int256, reverting on
     * overflow (when the input is less than smallest int208 or
     * greater than largest int208).
     *
     * Counterpart to Solidity's `int208` operator.
     *
     * Requirements:
     *
     * - input must fit into 208 bits
     */
    function toInt208(int256 value) internal pure returns (int208 downcasted) {
        downcasted = int208(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(208, value);
        }
    }

    /**
     * @dev Returns the downcasted int200 from int256, reverting on
     * overflow (when the input is less than smallest int200 or
     * greater than largest int200).
     *
     * Counterpart to Solidity's `int200` operator.
     *
     * Requirements:
     *
     * - input must fit into 200 bits
     */
    function toInt200(int256 value) internal pure returns (int200 downcasted) {
        downcasted = int200(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(200, value);
        }
    }

    /**
     * @dev Returns the downcasted int192 from int256, reverting on
     * overflow (when the input is less than smallest int192 or
     * greater than largest int192).
     *
     * Counterpart to Solidity's `int192` operator.
     *
     * Requirements:
     *
     * - input must fit into 192 bits
     */
    function toInt192(int256 value) internal pure returns (int192 downcasted) {
        downcasted = int192(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(192, value);
        }
    }

    /**
     * @dev Returns the downcasted int184 from int256, reverting on
     * overflow (when the input is less than smallest int184 or
     * greater than largest int184).
     *
     * Counterpart to Solidity's `int184` operator.
     *
     * Requirements:
     *
     * - input must fit into 184 bits
     */
    function toInt184(int256 value) internal pure returns (int184 downcasted) {
        downcasted = int184(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(184, value);
        }
    }

    /**
     * @dev Returns the downcasted int176 from int256, reverting on
     * overflow (when the input is less than smallest int176 or
     * greater than largest int176).
     *
     * Counterpart to Solidity's `int176` operator.
     *
     * Requirements:
     *
     * - input must fit into 176 bits
     */
    function toInt176(int256 value) internal pure returns (int176 downcasted) {
        downcasted = int176(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(176, value);
        }
    }

    /**
     * @dev Returns the downcasted int168 from int256, reverting on
     * overflow (when the input is less than smallest int168 or
     * greater than largest int168).
     *
     * Counterpart to Solidity's `int168` operator.
     *
     * Requirements:
     *
     * - input must fit into 168 bits
     */
    function toInt168(int256 value) internal pure returns (int168 downcasted) {
        downcasted = int168(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(168, value);
        }
    }

    /**
     * @dev Returns the downcasted int160 from int256, reverting on
     * overflow (when the input is less than smallest int160 or
     * greater than largest int160).
     *
     * Counterpart to Solidity's `int160` operator.
     *
     * Requirements:
     *
     * - input must fit into 160 bits
     */
    function toInt160(int256 value) internal pure returns (int160 downcasted) {
        downcasted = int160(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(160, value);
        }
    }

    /**
     * @dev Returns the downcasted int152 from int256, reverting on
     * overflow (when the input is less than smallest int152 or
     * greater than largest int152).
     *
     * Counterpart to Solidity's `int152` operator.
     *
     * Requirements:
     *
     * - input must fit into 152 bits
     */
    function toInt152(int256 value) internal pure returns (int152 downcasted) {
        downcasted = int152(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(152, value);
        }
    }

    /**
     * @dev Returns the downcasted int144 from int256, reverting on
     * overflow (when the input is less than smallest int144 or
     * greater than largest int144).
     *
     * Counterpart to Solidity's `int144` operator.
     *
     * Requirements:
     *
     * - input must fit into 144 bits
     */
    function toInt144(int256 value) internal pure returns (int144 downcasted) {
        downcasted = int144(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(144, value);
        }
    }

    /**
     * @dev Returns the downcasted int136 from int256, reverting on
     * overflow (when the input is less than smallest int136 or
     * greater than largest int136).
     *
     * Counterpart to Solidity's `int136` operator.
     *
     * Requirements:
     *
     * - input must fit into 136 bits
     */
    function toInt136(int256 value) internal pure returns (int136 downcasted) {
        downcasted = int136(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(136, value);
        }
    }

    /**
     * @dev Returns the downcasted int128 from int256, reverting on
     * overflow (when the input is less than smallest int128 or
     * greater than largest int128).
     *
     * Counterpart to Solidity's `int128` operator.
     *
     * Requirements:
     *
     * - input must fit into 128 bits
     */
    function toInt128(int256 value) internal pure returns (int128 downcasted) {
        downcasted = int128(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(128, value);
        }
    }

    /**
     * @dev Returns the downcasted int120 from int256, reverting on
     * overflow (when the input is less than smallest int120 or
     * greater than largest int120).
     *
     * Counterpart to Solidity's `int120` operator.
     *
     * Requirements:
     *
     * - input must fit into 120 bits
     */
    function toInt120(int256 value) internal pure returns (int120 downcasted) {
        downcasted = int120(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(120, value);
        }
    }

    /**
     * @dev Returns the downcasted int112 from int256, reverting on
     * overflow (when the input is less than smallest int112 or
     * greater than largest int112).
     *
     * Counterpart to Solidity's `int112` operator.
     *
     * Requirements:
     *
     * - input must fit into 112 bits
     */
    function toInt112(int256 value) internal pure returns (int112 downcasted) {
        downcasted = int112(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(112, value);
        }
    }

    /**
     * @dev Returns the downcasted int104 from int256, reverting on
     * overflow (when the input is less than smallest int104 or
     * greater than largest int104).
     *
     * Counterpart to Solidity's `int104` operator.
     *
     * Requirements:
     *
     * - input must fit into 104 bits
     */
    function toInt104(int256 value) internal pure returns (int104 downcasted) {
        downcasted = int104(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(104, value);
        }
    }

    /**
     * @dev Returns the downcasted int96 from int256, reverting on
     * overflow (when the input is less than smallest int96 or
     * greater than largest int96).
     *
     * Counterpart to Solidity's `int96` operator.
     *
     * Requirements:
     *
     * - input must fit into 96 bits
     */
    function toInt96(int256 value) internal pure returns (int96 downcasted) {
        downcasted = int96(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(96, value);
        }
    }

    /**
     * @dev Returns the downcasted int88 from int256, reverting on
     * overflow (when the input is less than smallest int88 or
     * greater than largest int88).
     *
     * Counterpart to Solidity's `int88` operator.
     *
     * Requirements:
     *
     * - input must fit into 88 bits
     */
    function toInt88(int256 value) internal pure returns (int88 downcasted) {
        downcasted = int88(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(88, value);
        }
    }

    /**
     * @dev Returns the downcasted int80 from int256, reverting on
     * overflow (when the input is less than smallest int80 or
     * greater than largest int80).
     *
     * Counterpart to Solidity's `int80` operator.
     *
     * Requirements:
     *
     * - input must fit into 80 bits
     */
    function toInt80(int256 value) internal pure returns (int80 downcasted) {
        downcasted = int80(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(80, value);
        }
    }

    /**
     * @dev Returns the downcasted int72 from int256, reverting on
     * overflow (when the input is less than smallest int72 or
     * greater than largest int72).
     *
     * Counterpart to Solidity's `int72` operator.
     *
     * Requirements:
     *
     * - input must fit into 72 bits
     */
    function toInt72(int256 value) internal pure returns (int72 downcasted) {
        downcasted = int72(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(72, value);
        }
    }

    /**
     * @dev Returns the downcasted int64 from int256, reverting on
     * overflow (when the input is less than smallest int64 or
     * greater than largest int64).
     *
     * Counterpart to Solidity's `int64` operator.
     *
     * Requirements:
     *
     * - input must fit into 64 bits
     */
    function toInt64(int256 value) internal pure returns (int64 downcasted) {
        downcasted = int64(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(64, value);
        }
    }

    /**
     * @dev Returns the downcasted int56 from int256, reverting on
     * overflow (when the input is less than smallest int56 or
     * greater than largest int56).
     *
     * Counterpart to Solidity's `int56` operator.
     *
     * Requirements:
     *
     * - input must fit into 56 bits
     */
    function toInt56(int256 value) internal pure returns (int56 downcasted) {
        downcasted = int56(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(56, value);
        }
    }

    /**
     * @dev Returns the downcasted int48 from int256, reverting on
     * overflow (when the input is less than smallest int48 or
     * greater than largest int48).
     *
     * Counterpart to Solidity's `int48` operator.
     *
     * Requirements:
     *
     * - input must fit into 48 bits
     */
    function toInt48(int256 value) internal pure returns (int48 downcasted) {
        downcasted = int48(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(48, value);
        }
    }

    /**
     * @dev Returns the downcasted int40 from int256, reverting on
     * overflow (when the input is less than smallest int40 or
     * greater than largest int40).
     *
     * Counterpart to Solidity's `int40` operator.
     *
     * Requirements:
     *
     * - input must fit into 40 bits
     */
    function toInt40(int256 value) internal pure returns (int40 downcasted) {
        downcasted = int40(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(40, value);
        }
    }

    /**
     * @dev Returns the downcasted int32 from int256, reverting on
     * overflow (when the input is less than smallest int32 or
     * greater than largest int32).
     *
     * Counterpart to Solidity's `int32` operator.
     *
     * Requirements:
     *
     * - input must fit into 32 bits
     */
    function toInt32(int256 value) internal pure returns (int32 downcasted) {
        downcasted = int32(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(32, value);
        }
    }

    /**
     * @dev Returns the downcasted int24 from int256, reverting on
     * overflow (when the input is less than smallest int24 or
     * greater than largest int24).
     *
     * Counterpart to Solidity's `int24` operator.
     *
     * Requirements:
     *
     * - input must fit into 24 bits
     */
    function toInt24(int256 value) internal pure returns (int24 downcasted) {
        downcasted = int24(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(24, value);
        }
    }

    /**
     * @dev Returns the downcasted int16 from int256, reverting on
     * overflow (when the input is less than smallest int16 or
     * greater than largest int16).
     *
     * Counterpart to Solidity's `int16` operator.
     *
     * Requirements:
     *
     * - input must fit into 16 bits
     */
    function toInt16(int256 value) internal pure returns (int16 downcasted) {
        downcasted = int16(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(16, value);
        }
    }

    /**
     * @dev Returns the downcasted int8 from int256, reverting on
     * overflow (when the input is less than smallest int8 or
     * greater than largest int8).
     *
     * Counterpart to Solidity's `int8` operator.
     *
     * Requirements:
     *
     * - input must fit into 8 bits
     */
    function toInt8(int256 value) internal pure returns (int8 downcasted) {
        downcasted = int8(value);
        if (downcasted != value) {
            revert SafeCastOverflowedIntDowncast(8, value);
        }
    }

    /**
     * @dev Converts an unsigned uint256 into a signed int256.
     *
     * Requirements:
     *
     * - input must be less than or equal to maxInt256.
     */
    function toInt256(uint256 value) internal pure returns (int256) {
        // Note: Unsafe cast below is okay because `type(int256).max` is guaranteed to be positive
        if (value > uint256(type(int256).max)) {
            revert SafeCastOverflowedUintToInt(value);
        }
        return int256(value);
    }

    /**
     * @dev Cast a boolean (false or true) to a uint256 (0 or 1) with no jump.
     */
    function toUint(bool b) internal pure returns (uint256 u) {
        assembly ("memory-safe") {
            u := iszero(iszero(b))
        }
    }
}

File 32 of 38 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (utils/math/Math.sol)

pragma solidity ^0.8.20;

import {Panic} from "../Panic.sol";
import {SafeCast} from "./SafeCast.sol";

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Floor, // Toward negative infinity
        Ceil, // Toward positive infinity
        Trunc, // Toward zero
        Expand // Away from zero
    }

    /**
     * @dev Return the 512-bit addition of two uint256.
     *
     * The result is stored in two 256 variables such that sum = high * 2²⁵⁶ + low.
     */
    function add512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
        assembly ("memory-safe") {
            low := add(a, b)
            high := lt(low, a)
        }
    }

    /**
     * @dev Return the 512-bit multiplication of two uint256.
     *
     * The result is stored in two 256 variables such that product = high * 2²⁵⁶ + low.
     */
    function mul512(uint256 a, uint256 b) internal pure returns (uint256 high, uint256 low) {
        // 512-bit multiply [high low] = x * y. Compute the product mod 2²⁵⁶ and mod 2²⁵⁶ - 1, then use
        // the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
        // variables such that product = high * 2²⁵⁶ + low.
        assembly ("memory-safe") {
            let mm := mulmod(a, b, not(0))
            low := mul(a, b)
            high := sub(sub(mm, low), lt(mm, low))
        }
    }

    /**
     * @dev Returns the addition of two unsigned integers, with a success flag (no overflow).
     */
    function tryAdd(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            uint256 c = a + b;
            success = c >= a;
            result = c * SafeCast.toUint(success);
        }
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, with a success flag (no overflow).
     */
    function trySub(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            uint256 c = a - b;
            success = c <= a;
            result = c * SafeCast.toUint(success);
        }
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, with a success flag (no overflow).
     */
    function tryMul(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            uint256 c = a * b;
            assembly ("memory-safe") {
                // Only true when the multiplication doesn't overflow
                // (c / a == b) || (a == 0)
                success := or(eq(div(c, a), b), iszero(a))
            }
            // equivalent to: success ? c : 0
            result = c * SafeCast.toUint(success);
        }
    }

    /**
     * @dev Returns the division of two unsigned integers, with a success flag (no division by zero).
     */
    function tryDiv(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            success = b > 0;
            assembly ("memory-safe") {
                // The `DIV` opcode returns zero when the denominator is 0.
                result := div(a, b)
            }
        }
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers, with a success flag (no division by zero).
     */
    function tryMod(uint256 a, uint256 b) internal pure returns (bool success, uint256 result) {
        unchecked {
            success = b > 0;
            assembly ("memory-safe") {
                // The `MOD` opcode returns zero when the denominator is 0.
                result := mod(a, b)
            }
        }
    }

    /**
     * @dev Unsigned saturating addition, bounds to `2²⁵⁶ - 1` instead of overflowing.
     */
    function saturatingAdd(uint256 a, uint256 b) internal pure returns (uint256) {
        (bool success, uint256 result) = tryAdd(a, b);
        return ternary(success, result, type(uint256).max);
    }

    /**
     * @dev Unsigned saturating subtraction, bounds to zero instead of overflowing.
     */
    function saturatingSub(uint256 a, uint256 b) internal pure returns (uint256) {
        (, uint256 result) = trySub(a, b);
        return result;
    }

    /**
     * @dev Unsigned saturating multiplication, bounds to `2²⁵⁶ - 1` instead of overflowing.
     */
    function saturatingMul(uint256 a, uint256 b) internal pure returns (uint256) {
        (bool success, uint256 result) = tryMul(a, b);
        return ternary(success, result, type(uint256).max);
    }

    /**
     * @dev Branchless ternary evaluation for `a ? b : c`. Gas costs are constant.
     *
     * IMPORTANT: This function may reduce bytecode size and consume less gas when used standalone.
     * However, the compiler may optimize Solidity ternary operations (i.e. `a ? b : c`) to only compute
     * one branch when needed, making this function more expensive.
     */
    function ternary(bool condition, uint256 a, uint256 b) internal pure returns (uint256) {
        unchecked {
            // branchless ternary works because:
            // b ^ (a ^ b) == a
            // b ^ 0 == b
            return b ^ ((a ^ b) * SafeCast.toUint(condition));
        }
    }

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

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

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

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds towards infinity instead
     * of rounding towards zero.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        if (b == 0) {
            // Guarantee the same behavior as in a regular Solidity division.
            Panic.panic(Panic.DIVISION_BY_ZERO);
        }

        // The following calculation ensures accurate ceiling division without overflow.
        // Since a is non-zero, (a - 1) / b will not overflow.
        // The largest possible result occurs when (a - 1) / b is type(uint256).max,
        // but the largest value we can obtain is type(uint256).max - 1, which happens
        // when a = type(uint256).max and b = 1.
        unchecked {
            return SafeCast.toUint(a > 0) * ((a - 1) / b + 1);
        }
    }

    /**
     * @dev Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or
     * denominator == 0.
     *
     * Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) with further edits by
     * Uniswap Labs also under MIT license.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {
        unchecked {
            (uint256 high, uint256 low) = mul512(x, y);

            // Handle non-overflow cases, 256 by 256 division.
            if (high == 0) {
                // Solidity will revert if denominator == 0, unlike the div opcode on its own.
                // The surrounding unchecked block does not change this fact.
                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.
                return low / denominator;
            }

            // Make sure the result is less than 2²⁵⁶. Also prevents denominator == 0.
            if (denominator <= high) {
                Panic.panic(ternary(denominator == 0, Panic.DIVISION_BY_ZERO, Panic.UNDER_OVERFLOW));
            }

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

            // Make division exact by subtracting the remainder from [high low].
            uint256 remainder;
            assembly ("memory-safe") {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

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

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

            uint256 twos = denominator & (0 - denominator);
            assembly ("memory-safe") {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [high low] by twos.
                low := div(low, twos)

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

            // Shift in bits from high into low.
            low |= high * twos;

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

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also
            // works in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2⁸
            inverse *= 2 - denominator * inverse; // inverse mod 2¹⁶
            inverse *= 2 - denominator * inverse; // inverse mod 2³²
            inverse *= 2 - denominator * inverse; // inverse mod 2⁶⁴
            inverse *= 2 - denominator * inverse; // inverse mod 2¹²⁸
            inverse *= 2 - denominator * inverse; // inverse mod 2²⁵⁶

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

    /**
     * @dev Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {
        return mulDiv(x, y, denominator) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, denominator) > 0);
    }

    /**
     * @dev Calculates floor(x * y >> n) with full precision. Throws if result overflows a uint256.
     */
    function mulShr(uint256 x, uint256 y, uint8 n) internal pure returns (uint256 result) {
        unchecked {
            (uint256 high, uint256 low) = mul512(x, y);
            if (high >= 1 << n) {
                Panic.panic(Panic.UNDER_OVERFLOW);
            }
            return (high << (256 - n)) | (low >> n);
        }
    }

    /**
     * @dev Calculates x * y >> n with full precision, following the selected rounding direction.
     */
    function mulShr(uint256 x, uint256 y, uint8 n, Rounding rounding) internal pure returns (uint256) {
        return mulShr(x, y, n) + SafeCast.toUint(unsignedRoundsUp(rounding) && mulmod(x, y, 1 << n) > 0);
    }

    /**
     * @dev Calculate the modular multiplicative inverse of a number in Z/nZ.
     *
     * If n is a prime, then Z/nZ is a field. In that case all elements are inversible, except 0.
     * If n is not a prime, then Z/nZ is not a field, and some elements might not be inversible.
     *
     * If the input value is not inversible, 0 is returned.
     *
     * NOTE: If you know for sure that n is (big) a prime, it may be cheaper to use Fermat's little theorem and get the
     * inverse using `Math.modExp(a, n - 2, n)`. See {invModPrime}.
     */
    function invMod(uint256 a, uint256 n) internal pure returns (uint256) {
        unchecked {
            if (n == 0) return 0;

            // The inverse modulo is calculated using the Extended Euclidean Algorithm (iterative version)
            // Used to compute integers x and y such that: ax + ny = gcd(a, n).
            // When the gcd is 1, then the inverse of a modulo n exists and it's x.
            // ax + ny = 1
            // ax = 1 + (-y)n
            // ax ≡ 1 (mod n) # x is the inverse of a modulo n

            // If the remainder is 0 the gcd is n right away.
            uint256 remainder = a % n;
            uint256 gcd = n;

            // Therefore the initial coefficients are:
            // ax + ny = gcd(a, n) = n
            // 0a + 1n = n
            int256 x = 0;
            int256 y = 1;

            while (remainder != 0) {
                uint256 quotient = gcd / remainder;

                (gcd, remainder) = (
                    // The old remainder is the next gcd to try.
                    remainder,
                    // Compute the next remainder.
                    // Can't overflow given that (a % gcd) * (gcd // (a % gcd)) <= gcd
                    // where gcd is at most n (capped to type(uint256).max)
                    gcd - remainder * quotient
                );

                (x, y) = (
                    // Increment the coefficient of a.
                    y,
                    // Decrement the coefficient of n.
                    // Can overflow, but the result is casted to uint256 so that the
                    // next value of y is "wrapped around" to a value between 0 and n - 1.
                    x - y * int256(quotient)
                );
            }

            if (gcd != 1) return 0; // No inverse exists.
            return ternary(x < 0, n - uint256(-x), uint256(x)); // Wrap the result if it's negative.
        }
    }

    /**
     * @dev Variant of {invMod}. More efficient, but only works if `p` is known to be a prime greater than `2`.
     *
     * From https://en.wikipedia.org/wiki/Fermat%27s_little_theorem[Fermat's little theorem], we know that if p is
     * prime, then `a**(p-1) ≡ 1 mod p`. As a consequence, we have `a * a**(p-2) ≡ 1 mod p`, which means that
     * `a**(p-2)` is the modular multiplicative inverse of a in Fp.
     *
     * NOTE: this function does NOT check that `p` is a prime greater than `2`.
     */
    function invModPrime(uint256 a, uint256 p) internal view returns (uint256) {
        unchecked {
            return Math.modExp(a, p - 2, p);
        }
    }

    /**
     * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m)
     *
     * Requirements:
     * - modulus can't be zero
     * - underlying staticcall to precompile must succeed
     *
     * IMPORTANT: The result is only valid if the underlying call succeeds. When using this function, make
     * sure the chain you're using it on supports the precompiled contract for modular exponentiation
     * at address 0x05 as specified in https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise,
     * the underlying function will succeed given the lack of a revert, but the result may be incorrectly
     * interpreted as 0.
     */
    function modExp(uint256 b, uint256 e, uint256 m) internal view returns (uint256) {
        (bool success, uint256 result) = tryModExp(b, e, m);
        if (!success) {
            Panic.panic(Panic.DIVISION_BY_ZERO);
        }
        return result;
    }

    /**
     * @dev Returns the modular exponentiation of the specified base, exponent and modulus (b ** e % m).
     * It includes a success flag indicating if the operation succeeded. Operation will be marked as failed if trying
     * to operate modulo 0 or if the underlying precompile reverted.
     *
     * IMPORTANT: The result is only valid if the success flag is true. When using this function, make sure the chain
     * you're using it on supports the precompiled contract for modular exponentiation at address 0x05 as specified in
     * https://eips.ethereum.org/EIPS/eip-198[EIP-198]. Otherwise, the underlying function will succeed given the lack
     * of a revert, but the result may be incorrectly interpreted as 0.
     */
    function tryModExp(uint256 b, uint256 e, uint256 m) internal view returns (bool success, uint256 result) {
        if (m == 0) return (false, 0);
        assembly ("memory-safe") {
            let ptr := mload(0x40)
            // | Offset    | Content    | Content (Hex)                                                      |
            // |-----------|------------|--------------------------------------------------------------------|
            // | 0x00:0x1f | size of b  | 0x0000000000000000000000000000000000000000000000000000000000000020 |
            // | 0x20:0x3f | size of e  | 0x0000000000000000000000000000000000000000000000000000000000000020 |
            // | 0x40:0x5f | size of m  | 0x0000000000000000000000000000000000000000000000000000000000000020 |
            // | 0x60:0x7f | value of b | 0x<.............................................................b> |
            // | 0x80:0x9f | value of e | 0x<.............................................................e> |
            // | 0xa0:0xbf | value of m | 0x<.............................................................m> |
            mstore(ptr, 0x20)
            mstore(add(ptr, 0x20), 0x20)
            mstore(add(ptr, 0x40), 0x20)
            mstore(add(ptr, 0x60), b)
            mstore(add(ptr, 0x80), e)
            mstore(add(ptr, 0xa0), m)

            // Given the result < m, it's guaranteed to fit in 32 bytes,
            // so we can use the memory scratch space located at offset 0.
            success := staticcall(gas(), 0x05, ptr, 0xc0, 0x00, 0x20)
            result := mload(0x00)
        }
    }

    /**
     * @dev Variant of {modExp} that supports inputs of arbitrary length.
     */
    function modExp(bytes memory b, bytes memory e, bytes memory m) internal view returns (bytes memory) {
        (bool success, bytes memory result) = tryModExp(b, e, m);
        if (!success) {
            Panic.panic(Panic.DIVISION_BY_ZERO);
        }
        return result;
    }

    /**
     * @dev Variant of {tryModExp} that supports inputs of arbitrary length.
     */
    function tryModExp(
        bytes memory b,
        bytes memory e,
        bytes memory m
    ) internal view returns (bool success, bytes memory result) {
        if (_zeroBytes(m)) return (false, new bytes(0));

        uint256 mLen = m.length;

        // Encode call args in result and move the free memory pointer
        result = abi.encodePacked(b.length, e.length, mLen, b, e, m);

        assembly ("memory-safe") {
            let dataPtr := add(result, 0x20)
            // Write result on top of args to avoid allocating extra memory.
            success := staticcall(gas(), 0x05, dataPtr, mload(result), dataPtr, mLen)
            // Overwrite the length.
            // result.length > returndatasize() is guaranteed because returndatasize() == m.length
            mstore(result, mLen)
            // Set the memory pointer after the returned data.
            mstore(0x40, add(dataPtr, mLen))
        }
    }

    /**
     * @dev Returns whether the provided byte array is zero.
     */
    function _zeroBytes(bytes memory byteArray) private pure returns (bool) {
        for (uint256 i = 0; i < byteArray.length; ++i) {
            if (byteArray[i] != 0) {
                return false;
            }
        }
        return true;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded
     * towards zero.
     *
     * This method is based on Newton's method for computing square roots; the algorithm is restricted to only
     * using integer operations.
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        unchecked {
            // Take care of easy edge cases when a == 0 or a == 1
            if (a <= 1) {
                return a;
            }

            // In this function, we use Newton's method to get a root of `f(x) := x² - a`. It involves building a
            // sequence x_n that converges toward sqrt(a). For each iteration x_n, we also define the error between
            // the current value as `ε_n = | x_n - sqrt(a) |`.
            //
            // For our first estimation, we consider `e` the smallest power of 2 which is bigger than the square root
            // of the target. (i.e. `2**(e-1) ≤ sqrt(a) < 2**e`). We know that `e ≤ 128` because `(2¹²⁸)² = 2²⁵⁶` is
            // bigger than any uint256.
            //
            // By noticing that
            // `2**(e-1) ≤ sqrt(a) < 2**e → (2**(e-1))² ≤ a < (2**e)² → 2**(2*e-2) ≤ a < 2**(2*e)`
            // we can deduce that `e - 1` is `log2(a) / 2`. We can thus compute `x_n = 2**(e-1)` using a method similar
            // to the msb function.
            uint256 aa = a;
            uint256 xn = 1;

            if (aa >= (1 << 128)) {
                aa >>= 128;
                xn <<= 64;
            }
            if (aa >= (1 << 64)) {
                aa >>= 64;
                xn <<= 32;
            }
            if (aa >= (1 << 32)) {
                aa >>= 32;
                xn <<= 16;
            }
            if (aa >= (1 << 16)) {
                aa >>= 16;
                xn <<= 8;
            }
            if (aa >= (1 << 8)) {
                aa >>= 8;
                xn <<= 4;
            }
            if (aa >= (1 << 4)) {
                aa >>= 4;
                xn <<= 2;
            }
            if (aa >= (1 << 2)) {
                xn <<= 1;
            }

            // We now have x_n such that `x_n = 2**(e-1) ≤ sqrt(a) < 2**e = 2 * x_n`. This implies ε_n ≤ 2**(e-1).
            //
            // We can refine our estimation by noticing that the middle of that interval minimizes the error.
            // If we move x_n to equal 2**(e-1) + 2**(e-2), then we reduce the error to ε_n ≤ 2**(e-2).
            // This is going to be our x_0 (and ε_0)
            xn = (3 * xn) >> 1; // ε_0 := | x_0 - sqrt(a) | ≤ 2**(e-2)

            // From here, Newton's method give us:
            // x_{n+1} = (x_n + a / x_n) / 2
            //
            // One should note that:
            // x_{n+1}² - a = ((x_n + a / x_n) / 2)² - a
            //              = ((x_n² + a) / (2 * x_n))² - a
            //              = (x_n⁴ + 2 * a * x_n² + a²) / (4 * x_n²) - a
            //              = (x_n⁴ + 2 * a * x_n² + a² - 4 * a * x_n²) / (4 * x_n²)
            //              = (x_n⁴ - 2 * a * x_n² + a²) / (4 * x_n²)
            //              = (x_n² - a)² / (2 * x_n)²
            //              = ((x_n² - a) / (2 * x_n))²
            //              ≥ 0
            // Which proves that for all n ≥ 1, sqrt(a) ≤ x_n
            //
            // This gives us the proof of quadratic convergence of the sequence:
            // ε_{n+1} = | x_{n+1} - sqrt(a) |
            //         = | (x_n + a / x_n) / 2 - sqrt(a) |
            //         = | (x_n² + a - 2*x_n*sqrt(a)) / (2 * x_n) |
            //         = | (x_n - sqrt(a))² / (2 * x_n) |
            //         = | ε_n² / (2 * x_n) |
            //         = ε_n² / | (2 * x_n) |
            //
            // For the first iteration, we have a special case where x_0 is known:
            // ε_1 = ε_0² / | (2 * x_0) |
            //     ≤ (2**(e-2))² / (2 * (2**(e-1) + 2**(e-2)))
            //     ≤ 2**(2*e-4) / (3 * 2**(e-1))
            //     ≤ 2**(e-3) / 3
            //     ≤ 2**(e-3-log2(3))
            //     ≤ 2**(e-4.5)
            //
            // For the following iterations, we use the fact that, 2**(e-1) ≤ sqrt(a) ≤ x_n:
            // ε_{n+1} = ε_n² / | (2 * x_n) |
            //         ≤ (2**(e-k))² / (2 * 2**(e-1))
            //         ≤ 2**(2*e-2*k) / 2**e
            //         ≤ 2**(e-2*k)
            xn = (xn + a / xn) >> 1; // ε_1 := | x_1 - sqrt(a) | ≤ 2**(e-4.5)  -- special case, see above
            xn = (xn + a / xn) >> 1; // ε_2 := | x_2 - sqrt(a) | ≤ 2**(e-9)    -- general case with k = 4.5
            xn = (xn + a / xn) >> 1; // ε_3 := | x_3 - sqrt(a) | ≤ 2**(e-18)   -- general case with k = 9
            xn = (xn + a / xn) >> 1; // ε_4 := | x_4 - sqrt(a) | ≤ 2**(e-36)   -- general case with k = 18
            xn = (xn + a / xn) >> 1; // ε_5 := | x_5 - sqrt(a) | ≤ 2**(e-72)   -- general case with k = 36
            xn = (xn + a / xn) >> 1; // ε_6 := | x_6 - sqrt(a) | ≤ 2**(e-144)  -- general case with k = 72

            // Because e ≤ 128 (as discussed during the first estimation phase), we know have reached a precision
            // ε_6 ≤ 2**(e-144) < 1. Given we're operating on integers, then we can ensure that xn is now either
            // sqrt(a) or sqrt(a) + 1.
            return xn - SafeCast.toUint(xn > a / xn);
        }
    }

    /**
     * @dev Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + SafeCast.toUint(unsignedRoundsUp(rounding) && result * result < a);
        }
    }

    /**
     * @dev Return the log in base 2 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     */
    function log2(uint256 x) internal pure returns (uint256 r) {
        // If value has upper 128 bits set, log2 result is at least 128
        r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
        // If upper 64 bits of 128-bit half set, add 64 to result
        r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
        // If upper 32 bits of 64-bit half set, add 32 to result
        r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
        // If upper 16 bits of 32-bit half set, add 16 to result
        r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
        // If upper 8 bits of 16-bit half set, add 8 to result
        r |= SafeCast.toUint((x >> r) > 0xff) << 3;
        // If upper 4 bits of 8-bit half set, add 4 to result
        r |= SafeCast.toUint((x >> r) > 0xf) << 2;

        // Shifts value right by the current result and use it as an index into this lookup table:
        //
        // | x (4 bits) |  index  | table[index] = MSB position |
        // |------------|---------|-----------------------------|
        // |    0000    |    0    |        table[0] = 0         |
        // |    0001    |    1    |        table[1] = 0         |
        // |    0010    |    2    |        table[2] = 1         |
        // |    0011    |    3    |        table[3] = 1         |
        // |    0100    |    4    |        table[4] = 2         |
        // |    0101    |    5    |        table[5] = 2         |
        // |    0110    |    6    |        table[6] = 2         |
        // |    0111    |    7    |        table[7] = 2         |
        // |    1000    |    8    |        table[8] = 3         |
        // |    1001    |    9    |        table[9] = 3         |
        // |    1010    |   10    |        table[10] = 3        |
        // |    1011    |   11    |        table[11] = 3        |
        // |    1100    |   12    |        table[12] = 3        |
        // |    1101    |   13    |        table[13] = 3        |
        // |    1110    |   14    |        table[14] = 3        |
        // |    1111    |   15    |        table[15] = 3        |
        //
        // The lookup table is represented as a 32-byte value with the MSB positions for 0-15 in the last 16 bytes.
        assembly ("memory-safe") {
            r := or(r, byte(shr(r, x), 0x0000010102020202030303030303030300000000000000000000000000000000))
        }
    }

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

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

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

    /**
     * @dev Return the log in base 256 of a positive value rounded towards zero.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 x) internal pure returns (uint256 r) {
        // If value has upper 128 bits set, log2 result is at least 128
        r = SafeCast.toUint(x > 0xffffffffffffffffffffffffffffffff) << 7;
        // If upper 64 bits of 128-bit half set, add 64 to result
        r |= SafeCast.toUint((x >> r) > 0xffffffffffffffff) << 6;
        // If upper 32 bits of 64-bit half set, add 32 to result
        r |= SafeCast.toUint((x >> r) > 0xffffffff) << 5;
        // If upper 16 bits of 32-bit half set, add 16 to result
        r |= SafeCast.toUint((x >> r) > 0xffff) << 4;
        // Add 1 if upper 8 bits of 16-bit half set, and divide accumulated result by 8
        return (r >> 3) | SafeCast.toUint((x >> r) > 0xff);
    }

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

    /**
     * @dev Returns whether a provided rounding mode is considered rounding up for unsigned integers.
     */
    function unsignedRoundsUp(Rounding rounding) internal pure returns (bool) {
        return uint8(rounding) % 2 == 1;
    }
}

File 33 of 38 : IERC5313.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC5313.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface for the Light Contract Ownership Standard.
 *
 * A standardized minimal interface required to identify an account that controls a contract
 */
interface IERC5313 {
    /**
     * @dev Gets the address of the owner.
     */
    function owner() external view returns (address);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

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

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-20 standard as defined in the ERC.
 */
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
// OpenZeppelin Contracts (last updated v5.3.0) (access/IAccessControl.sol)

pragma solidity ^0.8.20;

/**
 * @dev External interface of AccessControl declared to support ERC-165 detection.
 */
interface IAccessControl {
    /**
     * @dev The `account` is missing a role.
     */
    error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);

    /**
     * @dev The caller of a function is not the expected one.
     *
     * NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
     */
    error AccessControlBadConfirmation();

    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted to signal this.
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call. This account bears the admin role (for the granted role).
     * Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `callerConfirmation`.
     */
    function renounceRole(bytes32 role, address callerConfirmation) external;
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/Panic.sol)

pragma solidity ^0.8.20;

/**
 * @dev Helper library for emitting standardized panic codes.
 *
 * ```solidity
 * contract Example {
 *      using Panic for uint256;
 *
 *      // Use any of the declared internal constants
 *      function foo() { Panic.GENERIC.panic(); }
 *
 *      // Alternatively
 *      function foo() { Panic.panic(Panic.GENERIC); }
 * }
 * ```
 *
 * Follows the list from https://github.com/ethereum/solidity/blob/v0.8.24/libsolutil/ErrorCodes.h[libsolutil].
 *
 * _Available since v5.1._
 */
// slither-disable-next-line unused-state
library Panic {
    /// @dev generic / unspecified error
    uint256 internal constant GENERIC = 0x00;
    /// @dev used by the assert() builtin
    uint256 internal constant ASSERT = 0x01;
    /// @dev arithmetic underflow or overflow
    uint256 internal constant UNDER_OVERFLOW = 0x11;
    /// @dev division or modulo by zero
    uint256 internal constant DIVISION_BY_ZERO = 0x12;
    /// @dev enum conversion error
    uint256 internal constant ENUM_CONVERSION_ERROR = 0x21;
    /// @dev invalid encoding in storage
    uint256 internal constant STORAGE_ENCODING_ERROR = 0x22;
    /// @dev empty array pop
    uint256 internal constant EMPTY_ARRAY_POP = 0x31;
    /// @dev array out of bounds access
    uint256 internal constant ARRAY_OUT_OF_BOUNDS = 0x32;
    /// @dev resource error (too large allocation or too large array)
    uint256 internal constant RESOURCE_ERROR = 0x41;
    /// @dev calling invalid internal function
    uint256 internal constant INVALID_INTERNAL_FUNCTION = 0x51;

    /// @dev Reverts with a panic code. Recommended to use with
    /// the internal constants with predefined codes.
    function panic(uint256 code) internal pure {
        assembly ("memory-safe") {
            mstore(0x00, 0x4e487b71)
            mstore(0x20, code)
            revert(0x1c, 0x24)
        }
    }
}

Settings
{
  "remappings": [
    "forge-std/=lib/ks-common-sc/lib/forge-std/src/",
    "openzeppelin-contracts/=lib/ks-common-sc/lib/openzeppelin-contracts/",
    "ks-common-sc/=lib/ks-common-sc/",
    "@openzeppelin/=lib/ks-growth-utils-sc/lib/openzeppelin-contracts/",
    "@src/=lib/ks-growth-utils-sc/contracts/",
    "erc4626-tests/=lib/ks-common-sc/lib/openzeppelin-contracts/lib/erc4626-tests/",
    "halmos-cheatcodes/=lib/ks-common-sc/lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "ks-growth-utils-sc/=lib/ks-growth-utils-sc/contracts/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 44444444
  },
  "metadata": {
    "useLiteralContent": false,
    "bytecodeHash": "ipfs",
    "appendCBOR": true
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "cancun",
  "viaIR": true,
  "libraries": {}
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"initialAdmin","type":"address"},{"internalType":"address[]","name":"initialOperators","type":"address[]"},{"internalType":"address[]","name":"initialGuardians","type":"address[]"},{"internalType":"address[]","name":"initialRescuers","type":"address[]"},{"internalType":"address[]","name":"initialWhitelistedHooks","type":"address[]"},{"internalType":"bytes4[]","name":"initialWhitelistedSelectors","type":"bytes4[]"},{"internalType":"uint256","name":"initDefaultTimeLock","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AccessControlBadConfirmation","type":"error"},{"inputs":[{"internalType":"uint48","name":"schedule","type":"uint48"}],"name":"AccessControlEnforcedDefaultAdminDelay","type":"error"},{"inputs":[],"name":"AccessControlEnforcedDefaultAdminRules","type":"error"},{"inputs":[{"internalType":"address","name":"defaultAdmin","type":"address"}],"name":"AccessControlInvalidDefaultAdmin","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"bytes32","name":"neededRole","type":"bytes32"}],"name":"AccessControlUnauthorizedAccount","type":"error"},{"inputs":[{"internalType":"address","name":"target","type":"address"}],"name":"AddressEmptyCode","type":"error"},{"inputs":[{"internalType":"bytes32","name":"campaignId","type":"bytes32"}],"name":"CampaignAlreadyExists","type":"error"},{"inputs":[{"internalType":"bytes32","name":"campaignId","type":"bytes32"}],"name":"CampaignDoesNotExist","type":"error"},{"inputs":[],"name":"EnforcedPause","type":"error"},{"inputs":[],"name":"ExpectedPause","type":"error"},{"inputs":[],"name":"FailedCall","type":"error"},{"inputs":[{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"InsufficientBalance","type":"error"},{"inputs":[],"name":"InvalidAddress","type":"error"},{"inputs":[],"name":"InvalidEffectiveTimestamp","type":"error"},{"inputs":[{"internalType":"bytes","name":"hookData","type":"bytes"}],"name":"InvalidHookData","type":"error"},{"inputs":[],"name":"InvalidLengths","type":"error"},{"inputs":[],"name":"InvalidProof","type":"error"},{"inputs":[{"internalType":"bytes4","name":"selector","type":"bytes4"}],"name":"InvalidSelector","type":"error"},{"inputs":[],"name":"MismatchedArrayLengths","type":"error"},{"inputs":[{"internalType":"address","name":"hook","type":"address"},{"internalType":"bytes4","name":"selector","type":"bytes4"}],"name":"NotWhitelistedHook","type":"error"},{"inputs":[],"name":"ReentrancyGuardReentrantCall","type":"error"},{"inputs":[{"internalType":"uint8","name":"bits","type":"uint8"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"SafeCastOverflowedUintDowncast","type":"error"},{"inputs":[],"name":"TooEarly","type":"error"},{"inputs":[],"name":"TooLate","type":"error"},{"inputs":[],"name":"TooShortDuration","type":"error"},{"inputs":[{"internalType":"address","name":"claimant","type":"address"}],"name":"UnauthorizedClaimant","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"campaignId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"startTimestamp","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"endTimestamp","type":"uint256"},{"indexed":false,"internalType":"string","name":"metadata","type":"string"}],"name":"CampaignCreated","type":"event"},{"anonymous":false,"inputs":[],"name":"DefaultAdminDelayChangeCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint48","name":"newDelay","type":"uint48"},{"indexed":false,"internalType":"uint48","name":"effectSchedule","type":"uint48"}],"name":"DefaultAdminDelayChangeScheduled","type":"event"},{"anonymous":false,"inputs":[],"name":"DefaultAdminTransferCanceled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"newAdmin","type":"address"},{"indexed":false,"internalType":"uint48","name":"acceptSchedule","type":"uint48"}],"name":"DefaultAdminTransferScheduled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"oldTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTime","type":"uint256"}],"name":"DefaultTimeLockUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"campaignId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"oldTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTime","type":"uint256"}],"name":"EndTimestampUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"campaignId","type":"bytes32"},{"indexed":false,"internalType":"string","name":"oldMetadata","type":"string"},{"indexed":false,"internalType":"string","name":"newMetadata","type":"string"}],"name":"MetadataUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IERC1155[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"}],"name":"RescueERC1155s","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"}],"name":"RescueERC20s","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"contract IERC721[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"}],"name":"RescueERC721s","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"campaignId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":false,"internalType":"bytes32","name":"root","type":"bytes32"},{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"}],"name":"RewardsClaimedForAccount","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"campaignId","type":"bytes32"},{"indexed":true,"internalType":"address","name":"erc721Addr","type":"address"},{"indexed":true,"internalType":"uint256","name":"erc721Id","type":"uint256"},{"indexed":false,"internalType":"address","name":"claimant","type":"address"},{"indexed":false,"internalType":"bytes32","name":"root","type":"bytes32"},{"indexed":false,"internalType":"address[]","name":"tokens","type":"address[]"},{"indexed":false,"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"}],"name":"RewardsClaimedForERC721","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"campaignId","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"oldRoot","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"newRoot","type":"bytes32"}],"name":"RootApplied","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"campaignId","type":"bytes32"},{"indexed":false,"internalType":"bytes32","name":"pendingRoot","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"effectiveTimestamp","type":"uint256"}],"name":"RootSubmitted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"campaignId","type":"bytes32"},{"indexed":false,"internalType":"uint256","name":"oldTime","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newTime","type":"uint256"}],"name":"StartTimestampUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"hook","type":"address"},{"indexed":true,"internalType":"bytes4","name":"selector","type":"bytes4"},{"indexed":false,"internalType":"bool","name":"grantOrRevoke","type":"bool"}],"name":"WhitelistedHookUpdated","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MIN_CAMPAIGN_DURATION","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"acceptDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"datas","type":"bytes[]"}],"name":"batchClaimRewards","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes[]","name":"datas","type":"bytes[]"},{"internalType":"address","name":"hook","type":"address"},{"internalType":"bytes","name":"hookData","type":"bytes"}],"name":"batchClaimRewardsWithHook","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address[]","name":"accounts","type":"address[]"}],"name":"batchGrantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address[]","name":"accounts","type":"address[]"}],"name":"batchRevokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAdmin","type":"address"}],"name":"beginDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"campaignId","type":"bytes32"}],"name":"campaigns","outputs":[{"internalType":"uint256","name":"startTimestamp","type":"uint256"},{"internalType":"uint256","name":"endTimestamp","type":"uint256"},{"internalType":"string","name":"metadata","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cancelDefaultAdminTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint48","name":"newDelay","type":"uint48"}],"name":"changeDefaultAdminDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"campaignId","type":"bytes32"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"address","name":"recipient","type":"address"}],"name":"claimRewardsForAccount","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"campaignId","type":"bytes32"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"hook","type":"address"},{"internalType":"bytes","name":"hookData","type":"bytes"}],"name":"claimRewardsForAccountWithHook","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"campaignId","type":"bytes32"},{"internalType":"address","name":"erc721Addr","type":"address"},{"internalType":"uint256","name":"erc721Id","type":"uint256"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"address","name":"recipient","type":"address"}],"name":"claimRewardsForERC721","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"campaignId","type":"bytes32"},{"internalType":"address","name":"erc721Addr","type":"address"},{"internalType":"uint256","name":"erc721Id","type":"uint256"},{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes32[]","name":"proof","type":"bytes32[]"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"hook","type":"address"},{"internalType":"bytes","name":"hookData","type":"bytes"}],"name":"claimRewardsForERC721WithHook","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"initStartTimestamp","type":"uint256"},{"internalType":"uint256","name":"initEndTimestamp","type":"uint256"},{"internalType":"string","name":"initMetadata","type":"string"},{"internalType":"bytes32","name":"salt","type":"bytes32"}],"name":"createCampaign","outputs":[{"internalType":"bytes32","name":"campaignId","type":"bytes32"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"defaultAdmin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultAdminDelay","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultAdminDelayIncreaseWait","outputs":[{"internalType":"uint48","name":"","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultTimeLock","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"campaignId","type":"bytes32"},{"internalType":"bytes32","name":"newRoot","type":"bytes32"}],"name":"forceUpdateRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"campaignId","type":"bytes32"},{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"token","type":"address"}],"name":"getClaimedAmountForAccount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"campaignId","type":"bytes32"},{"internalType":"address","name":"erc721Addr","type":"address"},{"internalType":"uint256","name":"erc721Id","type":"uint256"},{"internalType":"address","name":"token","type":"address"}],"name":"getClaimedAmountForERC721","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingDefaultAdmin","outputs":[{"internalType":"address","name":"newAdmin","type":"address"},{"internalType":"uint48","name":"schedule","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingDefaultAdminDelay","outputs":[{"internalType":"uint48","name":"newDelay","type":"uint48"},{"internalType":"uint48","name":"schedule","type":"uint48"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"campaignId","type":"bytes32"}],"name":"pendingRoots","outputs":[{"internalType":"bytes32","name":"root","type":"bytes32"},{"internalType":"uint256","name":"effectiveTimestamp","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC1155[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"bytes[]","name":"datas","type":"bytes[]"},{"internalType":"address","name":"recipient","type":"address"}],"name":"rescueERC1155s","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"amounts","type":"uint256[]"},{"internalType":"address","name":"recipient","type":"address"}],"name":"rescueERC20s","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract IERC721[]","name":"tokens","type":"address[]"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"address","name":"recipient","type":"address"}],"name":"rescueERC721s","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"rollbackDefaultAdminDelay","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"campaignId","type":"bytes32"}],"name":"roots","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"campaignId","type":"bytes32"},{"internalType":"bytes32","name":"newRoot","type":"bytes32"},{"internalType":"uint256","name":"effectiveTimestamp","type":"uint256"}],"name":"submitRoot","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newDefaultTimeLock","type":"uint256"}],"name":"updateDefaultTimeLock","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"campaignId","type":"bytes32"},{"internalType":"uint256","name":"endTimestamp","type":"uint256"}],"name":"updateEndTimestamp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"campaignId","type":"bytes32"},{"internalType":"string","name":"metadata","type":"string"}],"name":"updateMetadata","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"campaignId","type":"bytes32"},{"internalType":"uint256","name":"startTimestamp","type":"uint256"}],"name":"updateStartTimestamp","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"hooks","type":"address[]"},{"internalType":"bytes4[]","name":"selectors","type":"bytes4[]"},{"internalType":"bool","name":"grantOrRevoke","type":"bool"}],"name":"updateWhitelistedHooks","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"hook","type":"address"},{"internalType":"bytes4","name":"selector","type":"bytes4"}],"name":"whitelistedHooks","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}]

60806040523461037e576156ba8038038061001981610382565b928339810160e08282031261037e57610031826103bb565b60208301519091906001600160401b03811161037e57816100539185016103e6565b60408401519093906001600160401b03811161037e57826100759183016103e6565b60608201519092906001600160401b03811161037e57816100979184016103e6565b60808301519091906001600160401b03811161037e57816100b99185016103e6565b60a08401519093906001600160401b03811161037e5781019180601f8401121561037e578251906100f16100ec836103cf565b610382565b9360208086858152019360051b82010191821161037e57602001915b81831061035d5750505060c00151946001600160a01b0381161561034a57600180546001600160d01b0316905561014390610469565b505f5b86518110156101965760019061018f6001600160a01b03610167838b610441565b51167f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b9296104b1565b5001610146565b50845f5b85518110156101ea576001906101e36001600160a01b036101bb838a610441565b51167f55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a50416104b1565b500161019a565b50835f5b845181101561023e576001906102376001600160a01b0361020f8389610441565b51167fcf6f9f892731e14b8859835f2ff35575f447fb501f46243c4eb8bac19e31a0506104b1565b50016101ee565b5082815181510361033b575f5b82518110156102f5576001906001600160a01b036102698286610441565b51165f52600860205260405f2063ffffffff60e01b6102888386610441565b51165f5260205260405f208260ff19825416179055818060a01b036102ad8286610441565b51166001600160e01b03196102c28386610441565b5116907fa225c303f44c4dc28944b7ecc3cb66d6cdab2c385f4e7f7d69f85667d78a20566020604051868152a30161024b565b7f2c6e2678b0ceede9faf2caa4e09de2eb766ab3b5e36a7bcbd485207c2d1e91b1604085600454908060045582519182526020820152a160405161513e908161057c8239f35b631df89e8b60e01b5f5260045ffd5b636116401160e11b5f525f60045260245ffd5b82516001600160e01b03198116810361037e5781526020928301920161010d565b5f80fd5b6040519190601f01601f191682016001600160401b038111838210176103a757604052565b634e487b7160e01b5f52604160045260245ffd5b51906001600160a01b038216820361037e57565b6001600160401b0381116103a75760051b60200190565b9080601f8301121561037e5781516104006100ec826103cf565b9260208085848152019260051b82010192831161037e57602001905b8282106104295750505090565b60208091610436846103bb565b81520191019061041c565b80518210156104555760209160051b010190565b634e487b7160e01b5f52603260045260245ffd5b600254906001600160a01b0382166104a2576001600160a01b03199091166001600160a01b0382161760025561049f905f6104f3565b90565b631fe1e13d60e11b5f5260045ffd5b9081156104c2575b61049f916104f3565b600254916001600160a01b0383166104a2576001600160a01b03199092166001600160a01b038216176002556104b9565b5f818152602081815260408083206001600160a01b038616845290915290205460ff16610575575f818152602081815260408083206001600160a01b0395909516808452949091528120805460ff19166001179055339291907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9080a4600190565b50505f9056fe608080604052600436101561001c575b50361561001a575f80fd5b005b5f3560e01c90816301ffc9a71461340657508063022d63fb146133cb578063036738d81461321557806305a80d5d146131c45780630628e53414612fc35780630aa6220b14612edf5780630cb0b76f14612bcd5780630e3580a314612b5b578063206382cf14612ac1578063248a9ca314612a715780632f1fc006146129e25780632f2ff15d1461298157806336035eba146125f857806336568abe1461246d5780633b0f32891461221c5780633f4ba83a1461216157806346b5cb59146120fc578063565d43451461209e57806359044af914611db85780635c975abb14611d78578063634e93da14611c22578063649a5ec714611a225780636f39feec146119bd5780637fcd50c21461191d5780638456cb59146117cc57806384ef8ffc146117415780638aea3dc9146117925780638da5cb5b1461174157806390680e251461151457806391d14854146114a0578063934bc7231461135c5780639c36e141146113215780639eca2f1e146112b0578063a1eda53c1461122a578063a217fddf146111f2578063a375765e14610f94578063a731aa6314610ea7578063ad0f373c14610e2c578063ae6dead714610de4578063b089611214610a14578063b5f8a2a914610987578063cc8463c81461093f578063cefc14291461080c578063cf6eefb714610782578063d520e33f14610682578063d547741f146105f4578063d602b9fd1461055d578063eaf1b14b146102985763f2fde38b14610243575f61000f565b346102945760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945761001a61027d6135b2565b610285613ddc565b61028e336145a0565b50614683565b5f80fd5b346102945760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043567ffffffffffffffff8111610294576102e79036906004016134f5565b9060243567ffffffffffffffff811161029457366023820112156102945780600401359061031482613699565b916103226040519384613658565b8083526024602084019160051b8301019136831161029457602401905b82821061054d5750505061035161356c565b335f9081527f35be12757faf39521ceabc5bcd76ad643125bff13e41131da81a236ed69872a8602052604090205490919060ff161580610515575b6104c55773ffffffffffffffffffffffffffffffffffffffff821691821561049d5781518503610475575f5b858110610417577fb9b4c76aa8353dee2c821dd526b782fe929895b26bae365ac7098d3b0fb9f92385878661040c876103fe604051958695606087526060870191613b3e565b908482036020860152613b8c565b9060408301520390a1005b8061042d61042860019389896139f6565b613b09565b836104388387613b2a565b5191821561045d575b61044c918391614ad5565b6104568286613b2a565b52016103b8565b61044c91925061046d3082614a11565b929150610441565b7f568efce2000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fe6c4247b000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fe2517d3f000000000000000000000000000000000000000000000000000000005f52336004527fcf6f9f892731e14b8859835f2ff35575f447fb501f46243c4eb8bac19e31a05060245260445ffd5b50335f9081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff161561038c565b813581526020918201910161033f565b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261029457610593613ddc565b600180547fffffffffffff0000000000000000000000000000000000000000000000000000811690915560a01c65ffffffffffff166105ce57005b7f8886ebfc4259abdbc16601dd8fb5678e54878f47b3c34836cfc51154a96051095f80a1005b346102945760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043561062e613549565b811561065a578161065561065061001a945f525f602052600160405f20015490565b613ecc565b61460d565b7f3fc3c27a000000000000000000000000000000000000000000000000000000005f5260045ffd5b346102945760807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576106b9613549565b6064359073ffffffffffffffffffffffffffffffffffffffff82168203610294576040516107498161071d6020820194604435906004358773ffffffffffffffffffffffffffffffffffffffff604092959493606083019683521660208201520152565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101835282613658565b5190205f52600960205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052602060405f2054604051908152f35b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261029457604065ffffffffffff6107e66001549065ffffffffffff73ffffffffffffffffffffffffffffffffffffffff83169260a01c1690565b73ffffffffffffffffffffffffffffffffffffffff849392935193168352166020820152f35b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760015473ffffffffffffffffffffffffffffffffffffffff1633036109135760015460a081901c65ffffffffffff169073ffffffffffffffffffffffffffffffffffffffff1681158015610909575b6108dd576108b29061028e73ffffffffffffffffffffffffffffffffffffffff600254166145a0565b50600180547fffffffffffff0000000000000000000000000000000000000000000000000000169055005b507f19ca5ebb000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b5042821015610889565b7fc22c8022000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576020610977613ad0565b65ffffffffffff60405191168152f35b346102945760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043567ffffffffffffffff8111610294576109d96109ef9136906004016134f5565b906109e2613bbf565b6109ea613c33565b613f32565b5f7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d005b346102945760e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261029457600435610a4e613549565b6044359160643567ffffffffffffffff811161029457610a729036906004016134f5565b60843567ffffffffffffffff811161029457610a929036906004016134f5565b9260a43567ffffffffffffffff811161029457610ab39036906004016134f5565b929096610abe61358f565b92610ac7613bbf565b610acf613c33565b5f8881526005602052604090208054600190910154904210610dbc57421015610d9457868603610d6c57610b028861455c565b9473ffffffffffffffffffffffffffffffffffffffff8316998a60208d6024604051809481937f6352211e00000000000000000000000000000000000000000000000000000000835260048301525afa8015610d61575f90610cfe575b73ffffffffffffffffffffffffffffffffffffffff9150163303610cd25786610bfe92610bf18b8f610be98f8e908c93610bd161071d9d61071d60405193849260208401968773ffffffffffffffffffffffffffffffffffffffff604092959493606083019683521660208201520152565b5190209a8b946040519485938d602086019889613c67565b519020613c93565b602081519101209261475e565b15610caa57610c6d610c4d857fa7cddc59d500eff39733910ed97d6d46ce22672c36640271473d5d8cfed639649973ffffffffffffffffffffffffffffffffffffffff968a86610c7b986148eb565b91604051978897338952602089015260a0604089015260a0880191613b3e565b908582036060870152613b8c565b911660808301520390a45f7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d005b7f09bde339000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f8be4e902000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b506020813d602011610d59575b81610d1860209383613658565b81010312610294575173ffffffffffffffffffffffffffffffffffffffff811681036102945773ffffffffffffffffffffffffffffffffffffffff90610b5f565b3d9150610d0b565b6040513d5f823e3d90fd5b7f1df89e8b000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fecdd1c29000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f085de625000000000000000000000000000000000000000000000000000000005f5260045ffd5b346102945760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576004355f526006602052602060405f2054604051908152f35b346102945760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261029457610e63613549565b610e6b61356c565b906040516107498161071d60208201946004358690929173ffffffffffffffffffffffffffffffffffffffff6020916040840195845216910152565b3461029457610eb536613624565b610ebd613e44565b815f526005602052610ed58260405f205415156139c3565b815f52600560205260405f2054610e108101809111610f67578110610f3f575f828152600560209081526040918290206001018054908490558251908152908101929092527ffd7ab8ba96c5e02e94faadfbd23114f251d4b4eb80f7acff7b132bbdf607f0c791a2005b7f6868c07e000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b346102945760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043560243567ffffffffffffffff811161029457610fe69036906004016135f6565b90610fef613e44565b825f5260056020526110078360405f205415156139c3565b825f52600560205261101e600260405f20016137b8565b91835f526005602052600260405f200167ffffffffffffffff82116111c5576110518261104b8354613767565b83613974565b5f601f83116001146110fb5792826110eb926110c6827fc42c4edbc41dce02b01dd098a1f7a4c685c638d7a2fdfbe449b32e1f89fbfae198966110dd985f916110f0575b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8260011b9260031b1c19161790565b90555b604051948594604086526040860190613876565b9184830360208601526138c6565b0390a2005b90508501358b611095565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0831690825f5260205f20915f5b8181106111ad5750926110dd959285927fc42c4edbc41dce02b01dd098a1f7a4c685c638d7a2fdfbe449b32e1f89fbfae198966110eb9610611175575b5050600182811b0190556110c9565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88560031b161c19908501351690558880611166565b9192602060018192868a013581550194019201611129565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760206040515f8152f35b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576002548060d01c90811515806112a6575b1561129c5760a01c65ffffffffffff165b6040805165ffffffffffff9283168152929091166020830152819081015b0390f35b50505f5f9061127a565b5042821015611269565b346102945760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576004355f52600560205260405f2080546112986113036002600185015494016137b8565b60405193849384526020840152606060408401526060830190613876565b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576020600454604051908152f35b346102945760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043560243560443561139c613e44565b825f5260056020526113b48360405f205415156139c3565b801561148e575b6113c7600454426138b9565b81101580611476575b1561144e576113de8361455c565b5060405191604083019183831067ffffffffffffffff8411176111c5577f7f57a51d437e146db385e6f730415bc47c20256906b0338ded990f34779f5505936040938452828152600160208201838152875f526007602052855f20925183555191015582519182526020820152a2005b7f03a58aa9000000000000000000000000000000000000000000000000000000005f5260045ffd5b50825f526005602052600160405f20015481106113d0565b5061149b600454426138b9565b6113bb565b346102945760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576114d7613549565b6004355f525f60205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052602060ff60405f2054166040519015158152f35b346102945760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043567ffffffffffffffff8111610294576115639036906004016134f5565b60243567ffffffffffffffff8111610294576115839036906004016134f5565b92909160443591821515809303610294576115a7916115a0613ddc565b36916136b1565b926115b181613699565b926115bf6040519485613658565b818452602084019160051b81019036821161029457915b818310611708575050508251825103610d6c5782905f9260ff8216935b835181101561001a578073ffffffffffffffffffffffffffffffffffffffff61161e60019387613b2a565b51165f52600860205260405f207fffffffff000000000000000000000000000000000000000000000000000000006116568386613b2a565b51165f5260205260405f20867fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0082541617905573ffffffffffffffffffffffffffffffffffffffff6116a88287613b2a565b51167fffffffff000000000000000000000000000000000000000000000000000000006116d58386613b2a565b5116907fa225c303f44c4dc28944b7ecc3cb66d6cdab2c385f4e7f7d69f85667d78a20566020604051888152a3016115f3565b82357fffffffff0000000000000000000000000000000000000000000000000000000081168103610294578152602092830192016115d6565b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261029457602073ffffffffffffffffffffffffffffffffffffffff60025416604051908152f35b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576020604051610e108152f35b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261029457335f9081527f8a40f0b47fdc2a0ce293b772acfc7508c8315a4d462786c1adc3a56f92ca2d05602052604090205460ff1615806118e5575b6118955761183e613c33565b60017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0060035416176003557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b7fe2517d3f000000000000000000000000000000000000000000000000000000005f52336004527f55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a504160245260445ffd5b50335f9081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff1615611832565b346102945760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576119546135b2565b602435907fffffffff0000000000000000000000000000000000000000000000000000000082168092036102945773ffffffffffffffffffffffffffffffffffffffff165f52600860205260405f20905f52602052602060ff60405f2054166040519015158152f35b34610294576119cb36613705565b6119e3610650835f525f602052600160405f20015490565b5f5b815181101561001a5780611a1b73ffffffffffffffffffffffffffffffffffffffff611a1360019486613b2a565b51168561460d565b50016119e5565b346102945760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043565ffffffffffff81169081810361029457611a6d613ddc565b611a76426149c9565b9165ffffffffffff611a86613ad0565b1680821115611be857507ff1038c18cf84a56e432fdbfaf746924b7ea511dfe03a6506a0ceba4888788d9b9265ffffffffffff826206978080611ad395109118026206978018169061453e565b906002548060d01c80611b65575b50506002805473ffffffffffffffffffffffffffffffffffffffff1660a083901b79ffffffffffff0000000000000000000000000000000000000000161760d084901b7fffffffffffff0000000000000000000000000000000000000000000000000000161790556040805165ffffffffffff9283168152919092166020820152a1005b421115611bbe5779ffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffff00000000000000000000000000000000000000000000000000006001549260301b169116176001555b8380611ae1565b507f2b1fa2edafe6f7b9e97c1a9e0c3660e645beb2dcaa2d45bdbf9beaf5472e1ec55f80a1611bb7565b0365ffffffffffff8111610f67577ff1038c18cf84a56e432fdbfaf746924b7ea511dfe03a6506a0ceba4888788d9b92611ad3919061453e565b346102945760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261029457611c596135b2565b611c61613ddc565b7f3377dc44241e779dd06afab5b788a35ca5f3b778836e2990bdb26a2a4b2e5ed66020611c9e611c90426149c9565b611c98613ad0565b9061453e565b65ffffffffffff73ffffffffffffffffffffffffffffffffffffffff611ce76001549065ffffffffffff73ffffffffffffffffffffffffffffffffffffffff83169260a01c1690565b9690501694600154867fffffffffffff000000000000000000000000000000000000000000000000000079ffffffffffff00000000000000000000000000000000000000008660a01b169216171760015516611d4f575b65ffffffffffff60405191168152a2005b7f8886ebfc4259abdbc16601dd8fb5678e54878f47b3c34836cfc51154a96051095f80a1611d3e565b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261029457602060ff600354166040519015158152f35b34610294576101207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261029457600435611df3613549565b906044359160643567ffffffffffffffff811161029457611e189036906004016134f5565b909360843567ffffffffffffffff811161029457611e3a9036906004016134f5565b92909460a43567ffffffffffffffff811161029457611e5d9036906004016134f5565b949092611e6861358f565b9560e4359673ffffffffffffffffffffffffffffffffffffffff88168803610294576101043567ffffffffffffffff811161029457611eab9036906004016135f6565b9a9099611eb6613bbf565b611ebe613c33565b5f8781526005602052604090208054600190910154904210610dbc57421015610d9457858503610d6c57611ef18761455c565b9373ffffffffffffffffffffffffffffffffffffffff8216988960208c6024604051809481937f6352211e00000000000000000000000000000000000000000000000000000000835260048301525afa8015610d61575f9061203b575b73ffffffffffffffffffffffffffffffffffffffff9150163303610cd257858f92610bf18a8a8f611fd8978f610be992611fc061071d9c61071d60405193849260208401968773ffffffffffffffffffffffffffffffffffffffff604092959493606083019683521660208201520152565b519020998a948c604051958694602086019889613c67565b15610caa578c610c6d610c4d6109ef9f7fa7cddc59d500eff39733910ed97d6d46ce22672c36640271473d5d8cfed639649973ffffffffffffffffffffffffffffffffffffffff968a899361202c986148eb565b911660808301520390a4613cac565b506020813d602011612096575b8161205560209383613658565b81010312610294575173ffffffffffffffffffffffffffffffffffffffff811681036102945773ffffffffffffffffffffffffffffffffffffffff90611f4e565b3d9150612048565b346102945760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945761001a6004356120db613ddc565b805f5260056020526120f38160405f205415156139c3565b602435906144e4565b346102945761210a36613705565b612122610650835f525f602052600160405f20015490565b5f5b815181101561001a578061215a73ffffffffffffffffffffffffffffffffffffffff61215260019486613b2a565b5116856146ea565b5001612124565b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261029457612197613ddc565b60035460ff8116156121f4577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166003557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b7f8dfc202b000000000000000000000000000000000000000000000000000000005f5260045ffd5b346102945760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043567ffffffffffffffff81116102945761226b9036906004016134f5565b60243567ffffffffffffffff81116102945761228b9036906004016134f5565b61229693919361356c565b335f9081527f35be12757faf39521ceabc5bcd76ad643125bff13e41131da81a236ed69872a8602052604090205460ff161580612435575b6104c55773ffffffffffffffffffffffffffffffffffffffff1693841561049d57818403610475575f5b84811061238d575060405193806060860160608752526080850193905f905b808210612355577f26bdeb949280dfd0e9da292798484039bd60b27b35110cd7bac8c76ecc91471887808a61040c8a8a8a8583036020870152613a93565b90919485359073ffffffffffffffffffffffffffffffffffffffff821680920361029457602081600193829352019601920190612317565b6123988186866139f6565b359073ffffffffffffffffffffffffffffffffffffffff8216809203610294576123c38185856139f6565b35823b15610294575f926064849260405195869384927f42842e0e0000000000000000000000000000000000000000000000000000000084523060048501528d602485015260448401525af1918215610d6157600192612425575b50016122f8565b5f61242f91613658565b8761241e565b50335f9081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff16156122ce565b346102945760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576004356124a7613549565b8115806125c1575b612502575b3373ffffffffffffffffffffffffffffffffffffffff8216036124da5761001a9161460d565b7f6697b232000000000000000000000000000000000000000000000000000000005f5260045ffd5b60015465ffffffffffff60a082901c169073ffffffffffffffffffffffffffffffffffffffff16158015906125b1575b801561259f575b61256b57507fffffffffffff000000000000ffffffffffffffffffffffffffffffffffffffff600154166001556124b4565b65ffffffffffff907f19ca5ebb000000000000000000000000000000000000000000000000000000005f521660045260245ffd5b504265ffffffffffff82161015612539565b5065ffffffffffff811615612532565b5073ffffffffffffffffffffffffffffffffffffffff6002541673ffffffffffffffffffffffffffffffffffffffff8216146124af565b346102945760a07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043567ffffffffffffffff8111610294576126479036906004016134f5565b60243567ffffffffffffffff8111610294576126679036906004016134f5565b909260443567ffffffffffffffff8111610294576126899036906004016134f5565b91909260643567ffffffffffffffff8111610294576126ac9036906004016134f5565b6126b7979197613526565b335f9081527f35be12757faf39521ceabc5bcd76ad643125bff13e41131da81a236ed69872a8602052604090205460ff161580612949575b6104c55773ffffffffffffffffffffffffffffffffffffffff1697881561049d578388036104755785880361047557818803610475575f5b8881106127dc57505050604051958060808801608089525260a0870193905f905b8082106127a4577f791141318b8e941dff59e7bf43c8e9dc03cee067cb6d9ee265b15739aebc358d89808c6127998c8c61278b8d8d8d88830360208a0152613a93565b918583036040870152613a93565b9060608301520390a1005b90919485359073ffffffffffffffffffffffffffffffffffffffff821680920361029457602081600193829352019601920190612748565b6127e7818a886139f6565b359073ffffffffffffffffffffffffffffffffffffffff8216809203610294576128128187876139f6565b3561281e828a8c6139f6565b3561283461282d848888613a33565b369161393e565b9381156128c7575b803b15610294575f92838f61289d604051988996879586947ff242432a00000000000000000000000000000000000000000000000000000000865230600487015260248601526044850152606484015260a0608484015260a4830190613876565b03925af1918215610d61576001926128b7575b5001612727565b5f6128c191613658565b8b6128b0565b90506040517efdd58e000000000000000000000000000000000000000000000000000000008152306004820152826024820152602081604481855afa908115610d61575f91612918575b509061283c565b90506020813d8211612941575b8161293260209383613658565b8101031261029457518e612911565b3d9150612925565b50335f9081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff16156126ef565b346102945760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576004356129bb613549565b811561065a57816129dd61065061001a945f525f602052600160405f20015490565b6146ea565b346102945760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043567ffffffffffffffff811161029457612a319036906004016134f5565b612a39613549565b916044359267ffffffffffffffff841161029457612a6c612a616109ef9536906004016135f6565b9490936109e2613bbf565b613cac565b346102945760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576020612ab96004355f525f602052600160405f20015490565b604051908152f35b3461029457612acf36613624565b612ad7613e44565b815f526005602052612aef8260405f205415156139c3565b610e108101808211610f6757825f526005602052600160405f20015410610f3f5760407f2357555af1f28ffae5d980590e7e07ce9d654b2a2fc8de14aa5a8ba6c4cae8c491835f526005602052815f205490845f52600560205280835f205582519182526020820152a2005b346102945760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294577f2c6e2678b0ceede9faf2caa4e09de2eb766ab3b5e36a7bcbd485207c2d1e91b16040600435612bb8613ddc565b600454908060045582519182526020820152a1005b346102945760807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043560243560443567ffffffffffffffff811161029457612c229036906004016135f6565b90612c2b613e44565b82421015610d9457610e108401808511610f67578310610f3f57604051602081019085825284604082015260806060820152612ca381612c6f60a0820187876138c6565b6064356080830152037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101835282613658565b51902092835f52600560205260405f2054612eb357604051946060860186811067ffffffffffffffff8211176111c55760405280865260026020870196838852612cee36878761393e565b9760408201988952875f52600560205260405f20915182555160018201550195519283519667ffffffffffffffff88116111c557878795612d3b60209a612d358554613767565b85613974565b8990601f8311600114612de657827fb639e75db85f1e76bc512e6d060d7a9b0399b5e885400ca58bc7933a5c32e2eb989993612dd0969593612db0935f92612ddb575b50507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8260011b9260031b1c19161790565b90555b6040519485948552898501526060604085015260608401916138c6565b0390a2604051908152f35b015190508d80612d7e565b979291907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0821698835f52815f20995f5b818110612e995750996001928492612dd0989796957fb639e75db85f1e76bc512e6d060d7a9b0399b5e885400ca58bc7933a5c32e2eb9c9d10612e62575b505050811b019055612db3565b01517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88460031b161c191690558c8080612e55565b838301518c556001909b019a8c9a50928d01928d01612e17565b837f92b53c02000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261029457612f15613ddc565b6002548060d01c80612f40575b6002805473ffffffffffffffffffffffffffffffffffffffff169055005b421115612f995779ffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffff00000000000000000000000000000000000000000000000000006001549260301b169116176001555b8080612f22565b507f2b1fa2edafe6f7b9e97c1a9e0c3660e645beb2dcaa2d45bdbf9beaf5472e1ec55f80a1612f92565b346102945760e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043560243567ffffffffffffffff8111610294576130159036906004016134f5565b60443567ffffffffffffffff8111610294576130359036906004016134f5565b9360643567ffffffffffffffff8111610294576130569036906004016134f5565b919094613061613526565b9260a4359473ffffffffffffffffffffffffffffffffffffffff861686036102945760c43567ffffffffffffffff8111610294576130a39036906004016135f6565b9890976130ae613bbf565b6130b6613c33565b5f8681526005602052604090208054600190910154904210610dbc57421015610d94578a8103610d6c5761313961071d92878796610bf18f86610be96130fb8661455c565b60408051602081019889523391810191909152909c8d979091613121816060810161071d565b5190209a8b948d604051958694602086019889613c67565b15610caa576131a48561318c896109ef9e73ffffffffffffffffffffffffffffffffffffffff97867f7b7c3c0a4e01fdede95d991ec332a2e17194549cc22ff2086f874379ad10f3449b6131b2996148eb565b92604051968752608060208801526080870191613b3e565b908482036040860152613b8c565b941660608201528033940390a3613cac565b346102945760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576004355f5260076020526040805f206001815491015482519182526020820152f35b346102945760a07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043560243567ffffffffffffffff8111610294576132679036906004016134f5565b919060443567ffffffffffffffff8111610294576132899036906004016134f5565b9060643567ffffffffffffffff8111610294576132aa9036906004016134f5565b9290956132b5613526565b966132be613bbf565b6132c6613c33565b5f8781526005602052604090208054600190910154904210610dbc57421015610d9457828203610d6c5761334983918861071d97610bf18887610be98d61330c8761455c565b6040805160208101998a523391810191909152909e8f989091613332816060810161071d565b5190209c8d95604051958694602086019889613c67565b15610caa578561318c896131a49373ffffffffffffffffffffffffffffffffffffffff97867f7b7c3c0a4e01fdede95d991ec332a2e17194549cc22ff2086f874379ad10f3449b613399996148eb565b941660608201528033940390a35f7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d005b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576020604051620697808152f35b346102945760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261029457600435907fffffffff00000000000000000000000000000000000000000000000000000000821680920361029457817f314987860000000000000000000000000000000000000000000000000000000060209314908115613498575b5015158152f35b7f7965db0b000000000000000000000000000000000000000000000000000000008114915081156134cb575b5083613491565b7f01ffc9a700000000000000000000000000000000000000000000000000000000915014836134c4565b9181601f840112156102945782359167ffffffffffffffff8311610294576020808501948460051b01011161029457565b6084359073ffffffffffffffffffffffffffffffffffffffff8216820361029457565b6024359073ffffffffffffffffffffffffffffffffffffffff8216820361029457565b6044359073ffffffffffffffffffffffffffffffffffffffff8216820361029457565b60c4359073ffffffffffffffffffffffffffffffffffffffff8216820361029457565b6004359073ffffffffffffffffffffffffffffffffffffffff8216820361029457565b359073ffffffffffffffffffffffffffffffffffffffff8216820361029457565b9181601f840112156102945782359167ffffffffffffffff8311610294576020838186019501011161029457565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc6040910112610294576004359060243590565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176111c557604052565b67ffffffffffffffff81116111c55760051b60200190565b9291906136bd81613699565b936136cb6040519586613658565b602085838152019160051b810192831161029457905b8282106136ed57505050565b602080916136fa846135d5565b8152019101906136e1565b9060407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc83011261029457600435916024359067ffffffffffffffff8211610294578060238301121561029457816024613764936004013591016136b1565b90565b90600182811c921680156137ae575b602083101461378157565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b91607f1691613776565b9060405191825f8254926137cb84613767565b808452936001811690811561383657506001146137f2575b506137f092500383613658565b565b90505f9291925260205f20905f915b81831061381a5750509060206137f0928201015f6137e3565b6020919350806001915483858901015201910190918492613801565b602093506137f09592507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0091501682840152151560051b8201015f6137e3565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f602080948051918291828752018686015e5f8582860101520116010190565b91908201809211610f6757565b601f82602094937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe093818652868601375f8582860101520116010190565b67ffffffffffffffff81116111c557601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b92919261394a82613904565b916139586040519384613658565b829481845281830111610294578281602093845f960137010152565b601f821161398157505050565b5f5260205f20906020601f840160051c830193106139b9575b601f0160051c01905b8181106139ae575050565b5f81556001016139a3565b909150819061399a565b156139cb5750565b7f360c6da4000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b9190811015613a065760051b0190565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b9190811015613a065760051b810135907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18136030182121561029457019081359167ffffffffffffffff8311610294576020018236038113610294579190565b90918281527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83116102945760209260051b809284830137010190565b6002548060d01c8015159081613aff575b5015613af55760a01c65ffffffffffff1690565b5060015460d01c90565b905042115f613ae1565b3573ffffffffffffffffffffffffffffffffffffffff811681036102945790565b8051821015613a065760209160051b010190565b916020908281520191905f5b818110613b575750505090565b90919260208060019273ffffffffffffffffffffffffffffffffffffffff613b7e886135d5565b168152019401929101613b4a565b90602080835192838152019201905f5b818110613ba95750505090565b8251845260209384019390920191600101613b9c565b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005c613c0b5760017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d565b7f3ee5aeb5000000000000000000000000000000000000000000000000000000005f5260045ffd5b60ff60035416613c3f57565b7fd93c0665000000000000000000000000000000000000000000000000000000005f5260045ffd5b93916137649593613c85928652606060208701526060860191613b3e565b926040818503910152613a93565b90604051916020830152602082526137f0604083613658565b9160048110613d9b5780600411610294577fffffffff0000000000000000000000000000000000000000000000000000000082351673ffffffffffffffffffffffffffffffffffffffff8416805f52600860205260405f20825f5260205260ff60405f20541615613d6d5750505f613d2b613d6294938293369161393e565b60208151910182855af13d15613d65573d91613d4683613904565b92613d546040519485613658565b83523d5f602085013e615051565b50565b606091615051565b7fc6ca67c5000000000000000000000000000000000000000000000000000000005f5260045260245260445ffd5b613dd86040519283927f105908ea0000000000000000000000000000000000000000000000000000000084526020600485015260248401916138c6565b0390fd5b335f9081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff1615613e1457565b7fe2517d3f000000000000000000000000000000000000000000000000000000005f52336004525f60245260445ffd5b335f9081527fee57cd81e84075558e8fcc182a1f4393f91fc97f963a136e66b7f949a62f319f602052604090205460ff1615613e7c57565b7fe2517d3f000000000000000000000000000000000000000000000000000000005f52336004527f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92960245260445ffd5b805f525f60205260405f2073ffffffffffffffffffffffffffffffffffffffff33165f5260205260ff60405f20541615613f035750565b7fe2517d3f000000000000000000000000000000000000000000000000000000005f523360045260245260445ffd5b5f5b82811061408d575050507f667c036918e8dbe38a4ec9003830d89d321fbfffacba5bdecb14c1bbca99be015c5f7f667c036918e8dbe38a4ec9003830d89d321fbfffacba5bdecb14c1bbca99be015d7f667c036918e8dbe38a4ec9003830d89d321fbfffacba5bdecb14c1bbca99be025f9081527fe96e35370361806830d6ffae1085cb3cecf83f5e8c4d5baf97dbf2c679168812907f8ef871b0e777d2d19699d07d273e560f40eed55c2f5c0d2595bd0400809a6941905b838110613ffa5750505050565b8060019183015c8185015c9073ffffffffffffffffffffffffffffffffffffffff81165f527f667c036918e8dbe38a4ec9003830d89d321fbfffacba5bdecb14c1bbca99be0060205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f5260205260405f20905f825c925d8161407c575b50505001613fed565b61408592614ad5565b5f8080614073565b614098818484613a33565b60041161029457357fffffffff00000000000000000000000000000000000000000000000000000000167f036738d800000000000000000000000000000000000000000000000000000000810361423257506140f5818484613a33565b80600493929311610294578083019260848101359160048281018035936024808201358201808201959481013594929190850101891061422557604481013501600481013598602480830194928b010111614225577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc6141769201906150ea565b5f868152600560205260409020805460019091015492949192904210610dbc57421015610d9457888103610d6c576141bf61071d92878796610bf18d86610be96130fb8661455c565b15610caa576131a48561318c8960019c73ffffffffffffffffffffffffffffffffffffffff97867f7b7c3c0a4e01fdede95d991ec332a2e17194549cc22ff2086f874379ad10f3449b6142119961480c565b941660608201528033940390a35b01613f34565b633b99b53d5f526004601cfd5b7fb08961120000000000000000000000000000000000000000000000000000000081036144b95750614265818484613a33565b91908260041161029457600481019081356024820135916044810135936142b460c4830135917ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8901906150ea565b976084840135840160048101359492939183019260248083019287010184106142255760049060a48101350101968735936020808a019986010111614225575f8781526005602052604090208054600190910154904210610dbc57421015610d9457858503610d6c576143268761455c565b9373ffffffffffffffffffffffffffffffffffffffff8216988960208c6024604051809481937f6352211e00000000000000000000000000000000000000000000000000000000835260048301525afa8015610d61575f90614457575b73ffffffffffffffffffffffffffffffffffffffff9150163303610cd257856143f592610bf18f8a8f8d928f610be992611fc061071d9c61071d60405193849260208401968773ffffffffffffffffffffffffffffffffffffffff604092959493606083019683521660208201520152565b15610caa578a610c6d610c4d857fa7cddc59d500eff39733910ed97d6d46ce22672c36640271473d5d8cfed639649960019f968a73ffffffffffffffffffffffffffffffffffffffff986144489861480c565b911660808301520390a461421f565b506020813d82116144b1575b8161447060209383613658565b81010312610294575173ffffffffffffffffffffffffffffffffffffffff811681036102945773ffffffffffffffffffffffffffffffffffffffff90614383565b3d9150614463565b7f12ba286f000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b5f818152600660209081526040808320805490869055600783528184208481556001019390935580519283529082019390935290917fd1130d17a401a9f222864fc479ac48157a54fd10fc007f0ffe489d48bbf2394191a2565b9065ffffffffffff8091169116019065ffffffffffff8211610f6757565b805f52600760205260405f20548061457f575b505f52600660205260405f205490565b815f526007602052600160405f200154421061456f579081613764916144e4565b6137649073ffffffffffffffffffffffffffffffffffffffff6002541673ffffffffffffffffffffffffffffffffffffffff8216146145e0575b5f614b1b565b7fffffffffffffffffffffffff0000000000000000000000000000000000000000600254166002556145da565b906137649180158061464c575b15614b1b577fffffffffffffffffffffffff000000000000000000000000000000000000000060025416600255614b1b565b5073ffffffffffffffffffffffffffffffffffffffff6002541673ffffffffffffffffffffffffffffffffffffffff83161461461a565b6002549073ffffffffffffffffffffffffffffffffffffffff821661065a57613764917fffffffffffffffffffffffff000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff83169116176002555f614be9565b9081156146fb575b61376491614be9565b6002549173ffffffffffffffffffffffffffffffffffffffff831661065a577fffffffffffffffffffffffff000000000000000000000000000000000000000090921673ffffffffffffffffffffffffffffffffffffffff8216176002556146f2565b9192915f915b808310614772575050501490565b9091926147808483856139f6565b35908181101561479f575f52602052600160405f205b93019190614764565b905f52602052600160405f20614796565b906147ba82613699565b6147c76040519182613658565b8281527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe06147f58294613699565b0190602036910137565b91908203918211610f6757565b92919594909361481b876147b0565b965f5b81811061482e5750505050505050565b8089614840610428600194868c6139f6565b61488261484e84888b6139f6565b358a5f52600960205260405f2073ffffffffffffffffffffffffffffffffffffffff84165f5260205260405f2054906147ff565b908382614894575b505050500161481e565b6148db83916148e2958d5f52600960205260405f2073ffffffffffffffffffffffffffffffffffffffff86165f5260205260405f206148d48582546138b9565b9055613b2a565b5287614cb5565b895f808361488a565b929093959491956148fb876147b0565b965f5b81811061490e5750505050505050565b8080614920610428600194868c6139f6565b8761496361492f84898b6139f6565b358b5f52600960205260405f2073ffffffffffffffffffffffffffffffffffffffff85165f5260205260405f2054906147ff565b918d8b84614978575b505050505050016148fe565b6149be9585926149b8925f52600960205260405f2073ffffffffffffffffffffffffffffffffffffffff86165f5260205260405f206148d48582546138b9565b52614ad5565b805f87818d8b61496c565b65ffffffffffff81116149e15765ffffffffffff1690565b7f6dfcc650000000000000000000000000000000000000000000000000000000005f52603060045260245260445ffd5b73ffffffffffffffffffffffffffffffffffffffff1673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8103614a4757503190565b9073ffffffffffffffffffffffffffffffffffffffff602460209260405194859384927f70a082310000000000000000000000000000000000000000000000000000000084521660048301525afa908115610d61575f91614aa6575090565b90506020813d602011614acd575b81614ac160209383613658565b81010312610294575190565b3d9150614ab4565b919073ffffffffffffffffffffffffffffffffffffffff831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee03614b12576137f09250614f76565b6137f092614e19565b805f525f60205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f5260205260ff60405f2054165f14614be357805f525f60205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f5260205260405f207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00815416905573ffffffffffffffffffffffffffffffffffffffff339216907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b5f80a4600190565b50505f90565b805f525f60205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f5260205260ff60405f205416155f14614be357805f525f60205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f5260205260405f2060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0082541617905573ffffffffffffffffffffffffffffffffffffffff339216907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d5f80a4600190565b90918015614e145773ffffffffffffffffffffffffffffffffffffffff82165f527f667c036918e8dbe38a4ec9003830d89d321fbfffacba5bdecb14c1bbca99be0060205260405f2073ffffffffffffffffffffffffffffffffffffffff84165f5260205260405f20614d2a815c92836138b9565b905d15614d35575050565b7f667c036918e8dbe38a4ec9003830d89d321fbfffacba5bdecb14c1bbca99be015c9060018201808311610f67577f667c036918e8dbe38a4ec9003830d89d321fbfffacba5bdecb14c1bbca99be015d7f667c036918e8dbe38a4ec9003830d89d321fbfffacba5bdecb14c1bbca99be015f527f8ef871b0e777d2d19699d07d273e560f40eed55c2f5c0d2595bd0400809a694182015d7f667c036918e8dbe38a4ec9003830d89d321fbfffacba5bdecb14c1bbca99be025f527fe96e35370361806830d6ffae1085cb3cecf83f5e8c4d5baf97dbf2c679168812015d565b505050565b918015614e145773ffffffffffffffffffffffffffffffffffffffff604051927fa9059cbb00000000000000000000000000000000000000000000000000000000845216600483015260248201525f604060208260448582885af13d15601f3d11600185511416171692828152826020820152015215614e965750565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f3d011673ffffffffffffffffffffffffffffffffffffffff604051927f90bfb8650000000000000000000000000000000000000000000000000000000084521660048301527fa9059cbb000000000000000000000000000000000000000000000000000000006024830152608060448301528060a00160648301523d60848301523d5f60a484013e7ff27f64e40000000000000000000000000000000000000000000000000000000060c4828401600460a4820152015260e40190fd5b90801561504d575f80808093855af115614f8d5750565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f3d011673ffffffffffffffffffffffffffffffffffffffff604051927f90bfb8650000000000000000000000000000000000000000000000000000000084521660048301525f6024830152608060448301528060a00160648301523d60848301523d5f60a484013e7ff4b3b1bc0000000000000000000000000000000000000000000000000000000060c4828401600460a4820152015260e40190fd5b5050565b9061508e575080511561506657805190602001fd5b7fd6bda275000000000000000000000000000000000000000000000000000000005f5260045ffd5b815115806150e1575b61509f575090565b73ffffffffffffffffffffffffffffffffffffffff907f9996b315000000000000000000000000000000000000000000000000000000005f521660045260245ffd5b50803b15615097565b9160608301358301918235936020808501948601019101106142255756fea2646970667358221220123f7f60887de157fe217fb654a94f5fdbf230fa817536ed9e47f7bb33ca0ad564736f6c634300081c0033000000000000000000000000be2f0354d970265bfc36d383af77f72736b81b5400000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002600000000000000000000000000000000000000000000000000000000000001c200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000697161a9ece8afd6ae30946d790077050f993cbc0000000000000000000000000000000000000000000000000000000000000006000000000000000000000000697161a9ece8afd6ae30946d790077050f993cbc000000000000000000000000335b0100340e87d807cd2796895ca99fe74a6c590000000000000000000000001dcfc0de40453891c8574c8f6f7d51c67f069ad9000000000000000000000000dbef4af51b49ba2497ba16694475e109fc374999000000000000000000000000a322638e6891e8c4e2ab6d2f5539fb8b7931db130000000000000000000000000de7de941c89579f3c70307712ee257b9fd5eb9d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000e97c887b61ccd952a53578b04763e7134429e050000000000000000000000000000000000000000000000000000000000000001aa5d82c300000000000000000000000000000000000000000000000000000000

Deployed Bytecode

0x608080604052600436101561001c575b50361561001a575f80fd5b005b5f3560e01c90816301ffc9a71461340657508063022d63fb146133cb578063036738d81461321557806305a80d5d146131c45780630628e53414612fc35780630aa6220b14612edf5780630cb0b76f14612bcd5780630e3580a314612b5b578063206382cf14612ac1578063248a9ca314612a715780632f1fc006146129e25780632f2ff15d1461298157806336035eba146125f857806336568abe1461246d5780633b0f32891461221c5780633f4ba83a1461216157806346b5cb59146120fc578063565d43451461209e57806359044af914611db85780635c975abb14611d78578063634e93da14611c22578063649a5ec714611a225780636f39feec146119bd5780637fcd50c21461191d5780638456cb59146117cc57806384ef8ffc146117415780638aea3dc9146117925780638da5cb5b1461174157806390680e251461151457806391d14854146114a0578063934bc7231461135c5780639c36e141146113215780639eca2f1e146112b0578063a1eda53c1461122a578063a217fddf146111f2578063a375765e14610f94578063a731aa6314610ea7578063ad0f373c14610e2c578063ae6dead714610de4578063b089611214610a14578063b5f8a2a914610987578063cc8463c81461093f578063cefc14291461080c578063cf6eefb714610782578063d520e33f14610682578063d547741f146105f4578063d602b9fd1461055d578063eaf1b14b146102985763f2fde38b14610243575f61000f565b346102945760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945761001a61027d6135b2565b610285613ddc565b61028e336145a0565b50614683565b5f80fd5b346102945760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043567ffffffffffffffff8111610294576102e79036906004016134f5565b9060243567ffffffffffffffff811161029457366023820112156102945780600401359061031482613699565b916103226040519384613658565b8083526024602084019160051b8301019136831161029457602401905b82821061054d5750505061035161356c565b335f9081527f35be12757faf39521ceabc5bcd76ad643125bff13e41131da81a236ed69872a8602052604090205490919060ff161580610515575b6104c55773ffffffffffffffffffffffffffffffffffffffff821691821561049d5781518503610475575f5b858110610417577fb9b4c76aa8353dee2c821dd526b782fe929895b26bae365ac7098d3b0fb9f92385878661040c876103fe604051958695606087526060870191613b3e565b908482036020860152613b8c565b9060408301520390a1005b8061042d61042860019389896139f6565b613b09565b836104388387613b2a565b5191821561045d575b61044c918391614ad5565b6104568286613b2a565b52016103b8565b61044c91925061046d3082614a11565b929150610441565b7f568efce2000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fe6c4247b000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fe2517d3f000000000000000000000000000000000000000000000000000000005f52336004527fcf6f9f892731e14b8859835f2ff35575f447fb501f46243c4eb8bac19e31a05060245260445ffd5b50335f9081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff161561038c565b813581526020918201910161033f565b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261029457610593613ddc565b600180547fffffffffffff0000000000000000000000000000000000000000000000000000811690915560a01c65ffffffffffff166105ce57005b7f8886ebfc4259abdbc16601dd8fb5678e54878f47b3c34836cfc51154a96051095f80a1005b346102945760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043561062e613549565b811561065a578161065561065061001a945f525f602052600160405f20015490565b613ecc565b61460d565b7f3fc3c27a000000000000000000000000000000000000000000000000000000005f5260045ffd5b346102945760807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576106b9613549565b6064359073ffffffffffffffffffffffffffffffffffffffff82168203610294576040516107498161071d6020820194604435906004358773ffffffffffffffffffffffffffffffffffffffff604092959493606083019683521660208201520152565b037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101835282613658565b5190205f52600960205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052602060405f2054604051908152f35b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261029457604065ffffffffffff6107e66001549065ffffffffffff73ffffffffffffffffffffffffffffffffffffffff83169260a01c1690565b73ffffffffffffffffffffffffffffffffffffffff849392935193168352166020820152f35b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760015473ffffffffffffffffffffffffffffffffffffffff1633036109135760015460a081901c65ffffffffffff169073ffffffffffffffffffffffffffffffffffffffff1681158015610909575b6108dd576108b29061028e73ffffffffffffffffffffffffffffffffffffffff600254166145a0565b50600180547fffffffffffff0000000000000000000000000000000000000000000000000000169055005b507f19ca5ebb000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b5042821015610889565b7fc22c8022000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576020610977613ad0565b65ffffffffffff60405191168152f35b346102945760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043567ffffffffffffffff8111610294576109d96109ef9136906004016134f5565b906109e2613bbf565b6109ea613c33565b613f32565b5f7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d005b346102945760e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261029457600435610a4e613549565b6044359160643567ffffffffffffffff811161029457610a729036906004016134f5565b60843567ffffffffffffffff811161029457610a929036906004016134f5565b9260a43567ffffffffffffffff811161029457610ab39036906004016134f5565b929096610abe61358f565b92610ac7613bbf565b610acf613c33565b5f8881526005602052604090208054600190910154904210610dbc57421015610d9457868603610d6c57610b028861455c565b9473ffffffffffffffffffffffffffffffffffffffff8316998a60208d6024604051809481937f6352211e00000000000000000000000000000000000000000000000000000000835260048301525afa8015610d61575f90610cfe575b73ffffffffffffffffffffffffffffffffffffffff9150163303610cd25786610bfe92610bf18b8f610be98f8e908c93610bd161071d9d61071d60405193849260208401968773ffffffffffffffffffffffffffffffffffffffff604092959493606083019683521660208201520152565b5190209a8b946040519485938d602086019889613c67565b519020613c93565b602081519101209261475e565b15610caa57610c6d610c4d857fa7cddc59d500eff39733910ed97d6d46ce22672c36640271473d5d8cfed639649973ffffffffffffffffffffffffffffffffffffffff968a86610c7b986148eb565b91604051978897338952602089015260a0604089015260a0880191613b3e565b908582036060870152613b8c565b911660808301520390a45f7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d005b7f09bde339000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f8be4e902000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b506020813d602011610d59575b81610d1860209383613658565b81010312610294575173ffffffffffffffffffffffffffffffffffffffff811681036102945773ffffffffffffffffffffffffffffffffffffffff90610b5f565b3d9150610d0b565b6040513d5f823e3d90fd5b7f1df89e8b000000000000000000000000000000000000000000000000000000005f5260045ffd5b7fecdd1c29000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f085de625000000000000000000000000000000000000000000000000000000005f5260045ffd5b346102945760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576004355f526006602052602060405f2054604051908152f35b346102945760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261029457610e63613549565b610e6b61356c565b906040516107498161071d60208201946004358690929173ffffffffffffffffffffffffffffffffffffffff6020916040840195845216910152565b3461029457610eb536613624565b610ebd613e44565b815f526005602052610ed58260405f205415156139c3565b815f52600560205260405f2054610e108101809111610f67578110610f3f575f828152600560209081526040918290206001018054908490558251908152908101929092527ffd7ab8ba96c5e02e94faadfbd23114f251d4b4eb80f7acff7b132bbdf607f0c791a2005b7f6868c07e000000000000000000000000000000000000000000000000000000005f5260045ffd5b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b346102945760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043560243567ffffffffffffffff811161029457610fe69036906004016135f6565b90610fef613e44565b825f5260056020526110078360405f205415156139c3565b825f52600560205261101e600260405f20016137b8565b91835f526005602052600260405f200167ffffffffffffffff82116111c5576110518261104b8354613767565b83613974565b5f601f83116001146110fb5792826110eb926110c6827fc42c4edbc41dce02b01dd098a1f7a4c685c638d7a2fdfbe449b32e1f89fbfae198966110dd985f916110f0575b507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8260011b9260031b1c19161790565b90555b604051948594604086526040860190613876565b9184830360208601526138c6565b0390a2005b90508501358b611095565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0831690825f5260205f20915f5b8181106111ad5750926110dd959285927fc42c4edbc41dce02b01dd098a1f7a4c685c638d7a2fdfbe449b32e1f89fbfae198966110eb9610611175575b5050600182811b0190556110c9565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88560031b161c19908501351690558880611166565b9192602060018192868a013581550194019201611129565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760206040515f8152f35b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576002548060d01c90811515806112a6575b1561129c5760a01c65ffffffffffff165b6040805165ffffffffffff9283168152929091166020830152819081015b0390f35b50505f5f9061127a565b5042821015611269565b346102945760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576004355f52600560205260405f2080546112986113036002600185015494016137b8565b60405193849384526020840152606060408401526060830190613876565b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576020600454604051908152f35b346102945760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043560243560443561139c613e44565b825f5260056020526113b48360405f205415156139c3565b801561148e575b6113c7600454426138b9565b81101580611476575b1561144e576113de8361455c565b5060405191604083019183831067ffffffffffffffff8411176111c5577f7f57a51d437e146db385e6f730415bc47c20256906b0338ded990f34779f5505936040938452828152600160208201838152875f526007602052855f20925183555191015582519182526020820152a2005b7f03a58aa9000000000000000000000000000000000000000000000000000000005f5260045ffd5b50825f526005602052600160405f20015481106113d0565b5061149b600454426138b9565b6113bb565b346102945760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576114d7613549565b6004355f525f60205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052602060ff60405f2054166040519015158152f35b346102945760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043567ffffffffffffffff8111610294576115639036906004016134f5565b60243567ffffffffffffffff8111610294576115839036906004016134f5565b92909160443591821515809303610294576115a7916115a0613ddc565b36916136b1565b926115b181613699565b926115bf6040519485613658565b818452602084019160051b81019036821161029457915b818310611708575050508251825103610d6c5782905f9260ff8216935b835181101561001a578073ffffffffffffffffffffffffffffffffffffffff61161e60019387613b2a565b51165f52600860205260405f207fffffffff000000000000000000000000000000000000000000000000000000006116568386613b2a565b51165f5260205260405f20867fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0082541617905573ffffffffffffffffffffffffffffffffffffffff6116a88287613b2a565b51167fffffffff000000000000000000000000000000000000000000000000000000006116d58386613b2a565b5116907fa225c303f44c4dc28944b7ecc3cb66d6cdab2c385f4e7f7d69f85667d78a20566020604051888152a3016115f3565b82357fffffffff0000000000000000000000000000000000000000000000000000000081168103610294578152602092830192016115d6565b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261029457602073ffffffffffffffffffffffffffffffffffffffff60025416604051908152f35b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576020604051610e108152f35b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261029457335f9081527f8a40f0b47fdc2a0ce293b772acfc7508c8315a4d462786c1adc3a56f92ca2d05602052604090205460ff1615806118e5575b6118955761183e613c33565b60017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0060035416176003557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586020604051338152a1005b7fe2517d3f000000000000000000000000000000000000000000000000000000005f52336004527f55435dd261a4b9b3364963f7738a7a662ad9c84396d64be3365284bb7f0a504160245260445ffd5b50335f9081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff1615611832565b346102945760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576119546135b2565b602435907fffffffff0000000000000000000000000000000000000000000000000000000082168092036102945773ffffffffffffffffffffffffffffffffffffffff165f52600860205260405f20905f52602052602060ff60405f2054166040519015158152f35b34610294576119cb36613705565b6119e3610650835f525f602052600160405f20015490565b5f5b815181101561001a5780611a1b73ffffffffffffffffffffffffffffffffffffffff611a1360019486613b2a565b51168561460d565b50016119e5565b346102945760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043565ffffffffffff81169081810361029457611a6d613ddc565b611a76426149c9565b9165ffffffffffff611a86613ad0565b1680821115611be857507ff1038c18cf84a56e432fdbfaf746924b7ea511dfe03a6506a0ceba4888788d9b9265ffffffffffff826206978080611ad395109118026206978018169061453e565b906002548060d01c80611b65575b50506002805473ffffffffffffffffffffffffffffffffffffffff1660a083901b79ffffffffffff0000000000000000000000000000000000000000161760d084901b7fffffffffffff0000000000000000000000000000000000000000000000000000161790556040805165ffffffffffff9283168152919092166020820152a1005b421115611bbe5779ffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffff00000000000000000000000000000000000000000000000000006001549260301b169116176001555b8380611ae1565b507f2b1fa2edafe6f7b9e97c1a9e0c3660e645beb2dcaa2d45bdbf9beaf5472e1ec55f80a1611bb7565b0365ffffffffffff8111610f67577ff1038c18cf84a56e432fdbfaf746924b7ea511dfe03a6506a0ceba4888788d9b92611ad3919061453e565b346102945760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261029457611c596135b2565b611c61613ddc565b7f3377dc44241e779dd06afab5b788a35ca5f3b778836e2990bdb26a2a4b2e5ed66020611c9e611c90426149c9565b611c98613ad0565b9061453e565b65ffffffffffff73ffffffffffffffffffffffffffffffffffffffff611ce76001549065ffffffffffff73ffffffffffffffffffffffffffffffffffffffff83169260a01c1690565b9690501694600154867fffffffffffff000000000000000000000000000000000000000000000000000079ffffffffffff00000000000000000000000000000000000000008660a01b169216171760015516611d4f575b65ffffffffffff60405191168152a2005b7f8886ebfc4259abdbc16601dd8fb5678e54878f47b3c34836cfc51154a96051095f80a1611d3e565b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261029457602060ff600354166040519015158152f35b34610294576101207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261029457600435611df3613549565b906044359160643567ffffffffffffffff811161029457611e189036906004016134f5565b909360843567ffffffffffffffff811161029457611e3a9036906004016134f5565b92909460a43567ffffffffffffffff811161029457611e5d9036906004016134f5565b949092611e6861358f565b9560e4359673ffffffffffffffffffffffffffffffffffffffff88168803610294576101043567ffffffffffffffff811161029457611eab9036906004016135f6565b9a9099611eb6613bbf565b611ebe613c33565b5f8781526005602052604090208054600190910154904210610dbc57421015610d9457858503610d6c57611ef18761455c565b9373ffffffffffffffffffffffffffffffffffffffff8216988960208c6024604051809481937f6352211e00000000000000000000000000000000000000000000000000000000835260048301525afa8015610d61575f9061203b575b73ffffffffffffffffffffffffffffffffffffffff9150163303610cd257858f92610bf18a8a8f611fd8978f610be992611fc061071d9c61071d60405193849260208401968773ffffffffffffffffffffffffffffffffffffffff604092959493606083019683521660208201520152565b519020998a948c604051958694602086019889613c67565b15610caa578c610c6d610c4d6109ef9f7fa7cddc59d500eff39733910ed97d6d46ce22672c36640271473d5d8cfed639649973ffffffffffffffffffffffffffffffffffffffff968a899361202c986148eb565b911660808301520390a4613cac565b506020813d602011612096575b8161205560209383613658565b81010312610294575173ffffffffffffffffffffffffffffffffffffffff811681036102945773ffffffffffffffffffffffffffffffffffffffff90611f4e565b3d9150612048565b346102945760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945761001a6004356120db613ddc565b805f5260056020526120f38160405f205415156139c3565b602435906144e4565b346102945761210a36613705565b612122610650835f525f602052600160405f20015490565b5f5b815181101561001a578061215a73ffffffffffffffffffffffffffffffffffffffff61215260019486613b2a565b5116856146ea565b5001612124565b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261029457612197613ddc565b60035460ff8116156121f4577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00166003557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa6020604051338152a1005b7f8dfc202b000000000000000000000000000000000000000000000000000000005f5260045ffd5b346102945760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043567ffffffffffffffff81116102945761226b9036906004016134f5565b60243567ffffffffffffffff81116102945761228b9036906004016134f5565b61229693919361356c565b335f9081527f35be12757faf39521ceabc5bcd76ad643125bff13e41131da81a236ed69872a8602052604090205460ff161580612435575b6104c55773ffffffffffffffffffffffffffffffffffffffff1693841561049d57818403610475575f5b84811061238d575060405193806060860160608752526080850193905f905b808210612355577f26bdeb949280dfd0e9da292798484039bd60b27b35110cd7bac8c76ecc91471887808a61040c8a8a8a8583036020870152613a93565b90919485359073ffffffffffffffffffffffffffffffffffffffff821680920361029457602081600193829352019601920190612317565b6123988186866139f6565b359073ffffffffffffffffffffffffffffffffffffffff8216809203610294576123c38185856139f6565b35823b15610294575f926064849260405195869384927f42842e0e0000000000000000000000000000000000000000000000000000000084523060048501528d602485015260448401525af1918215610d6157600192612425575b50016122f8565b5f61242f91613658565b8761241e565b50335f9081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff16156122ce565b346102945760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576004356124a7613549565b8115806125c1575b612502575b3373ffffffffffffffffffffffffffffffffffffffff8216036124da5761001a9161460d565b7f6697b232000000000000000000000000000000000000000000000000000000005f5260045ffd5b60015465ffffffffffff60a082901c169073ffffffffffffffffffffffffffffffffffffffff16158015906125b1575b801561259f575b61256b57507fffffffffffff000000000000ffffffffffffffffffffffffffffffffffffffff600154166001556124b4565b65ffffffffffff907f19ca5ebb000000000000000000000000000000000000000000000000000000005f521660045260245ffd5b504265ffffffffffff82161015612539565b5065ffffffffffff811615612532565b5073ffffffffffffffffffffffffffffffffffffffff6002541673ffffffffffffffffffffffffffffffffffffffff8216146124af565b346102945760a07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043567ffffffffffffffff8111610294576126479036906004016134f5565b60243567ffffffffffffffff8111610294576126679036906004016134f5565b909260443567ffffffffffffffff8111610294576126899036906004016134f5565b91909260643567ffffffffffffffff8111610294576126ac9036906004016134f5565b6126b7979197613526565b335f9081527f35be12757faf39521ceabc5bcd76ad643125bff13e41131da81a236ed69872a8602052604090205460ff161580612949575b6104c55773ffffffffffffffffffffffffffffffffffffffff1697881561049d578388036104755785880361047557818803610475575f5b8881106127dc57505050604051958060808801608089525260a0870193905f905b8082106127a4577f791141318b8e941dff59e7bf43c8e9dc03cee067cb6d9ee265b15739aebc358d89808c6127998c8c61278b8d8d8d88830360208a0152613a93565b918583036040870152613a93565b9060608301520390a1005b90919485359073ffffffffffffffffffffffffffffffffffffffff821680920361029457602081600193829352019601920190612748565b6127e7818a886139f6565b359073ffffffffffffffffffffffffffffffffffffffff8216809203610294576128128187876139f6565b3561281e828a8c6139f6565b3561283461282d848888613a33565b369161393e565b9381156128c7575b803b15610294575f92838f61289d604051988996879586947ff242432a00000000000000000000000000000000000000000000000000000000865230600487015260248601526044850152606484015260a0608484015260a4830190613876565b03925af1918215610d61576001926128b7575b5001612727565b5f6128c191613658565b8b6128b0565b90506040517efdd58e000000000000000000000000000000000000000000000000000000008152306004820152826024820152602081604481855afa908115610d61575f91612918575b509061283c565b90506020813d8211612941575b8161293260209383613658565b8101031261029457518e612911565b3d9150612925565b50335f9081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff16156126ef565b346102945760407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576004356129bb613549565b811561065a57816129dd61065061001a945f525f602052600160405f20015490565b6146ea565b346102945760607ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043567ffffffffffffffff811161029457612a319036906004016134f5565b612a39613549565b916044359267ffffffffffffffff841161029457612a6c612a616109ef9536906004016135f6565b9490936109e2613bbf565b613cac565b346102945760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576020612ab96004355f525f602052600160405f20015490565b604051908152f35b3461029457612acf36613624565b612ad7613e44565b815f526005602052612aef8260405f205415156139c3565b610e108101808211610f6757825f526005602052600160405f20015410610f3f5760407f2357555af1f28ffae5d980590e7e07ce9d654b2a2fc8de14aa5a8ba6c4cae8c491835f526005602052815f205490845f52600560205280835f205582519182526020820152a2005b346102945760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294577f2c6e2678b0ceede9faf2caa4e09de2eb766ab3b5e36a7bcbd485207c2d1e91b16040600435612bb8613ddc565b600454908060045582519182526020820152a1005b346102945760807ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043560243560443567ffffffffffffffff811161029457612c229036906004016135f6565b90612c2b613e44565b82421015610d9457610e108401808511610f67578310610f3f57604051602081019085825284604082015260806060820152612ca381612c6f60a0820187876138c6565b6064356080830152037fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe08101835282613658565b51902092835f52600560205260405f2054612eb357604051946060860186811067ffffffffffffffff8211176111c55760405280865260026020870196838852612cee36878761393e565b9760408201988952875f52600560205260405f20915182555160018201550195519283519667ffffffffffffffff88116111c557878795612d3b60209a612d358554613767565b85613974565b8990601f8311600114612de657827fb639e75db85f1e76bc512e6d060d7a9b0399b5e885400ca58bc7933a5c32e2eb989993612dd0969593612db0935f92612ddb575b50507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8260011b9260031b1c19161790565b90555b6040519485948552898501526060604085015260608401916138c6565b0390a2604051908152f35b015190508d80612d7e565b979291907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0821698835f52815f20995f5b818110612e995750996001928492612dd0989796957fb639e75db85f1e76bc512e6d060d7a9b0399b5e885400ca58bc7933a5c32e2eb9c9d10612e62575b505050811b019055612db3565b01517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60f88460031b161c191690558c8080612e55565b838301518c556001909b019a8c9a50928d01928d01612e17565b837f92b53c02000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261029457612f15613ddc565b6002548060d01c80612f40575b6002805473ffffffffffffffffffffffffffffffffffffffff169055005b421115612f995779ffffffffffffffffffffffffffffffffffffffffffffffffffff7fffffffffffff00000000000000000000000000000000000000000000000000006001549260301b169116176001555b8080612f22565b507f2b1fa2edafe6f7b9e97c1a9e0c3660e645beb2dcaa2d45bdbf9beaf5472e1ec55f80a1612f92565b346102945760e07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043560243567ffffffffffffffff8111610294576130159036906004016134f5565b60443567ffffffffffffffff8111610294576130359036906004016134f5565b9360643567ffffffffffffffff8111610294576130569036906004016134f5565b919094613061613526565b9260a4359473ffffffffffffffffffffffffffffffffffffffff861686036102945760c43567ffffffffffffffff8111610294576130a39036906004016135f6565b9890976130ae613bbf565b6130b6613c33565b5f8681526005602052604090208054600190910154904210610dbc57421015610d94578a8103610d6c5761313961071d92878796610bf18f86610be96130fb8661455c565b60408051602081019889523391810191909152909c8d979091613121816060810161071d565b5190209a8b948d604051958694602086019889613c67565b15610caa576131a48561318c896109ef9e73ffffffffffffffffffffffffffffffffffffffff97867f7b7c3c0a4e01fdede95d991ec332a2e17194549cc22ff2086f874379ad10f3449b6131b2996148eb565b92604051968752608060208801526080870191613b3e565b908482036040860152613b8c565b941660608201528033940390a3613cac565b346102945760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576004355f5260076020526040805f206001815491015482519182526020820152f35b346102945760a07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc3601126102945760043560243567ffffffffffffffff8111610294576132679036906004016134f5565b919060443567ffffffffffffffff8111610294576132899036906004016134f5565b9060643567ffffffffffffffff8111610294576132aa9036906004016134f5565b9290956132b5613526565b966132be613bbf565b6132c6613c33565b5f8781526005602052604090208054600190910154904210610dbc57421015610d9457828203610d6c5761334983918861071d97610bf18887610be98d61330c8761455c565b6040805160208101998a523391810191909152909e8f989091613332816060810161071d565b5190209c8d95604051958694602086019889613c67565b15610caa578561318c896131a49373ffffffffffffffffffffffffffffffffffffffff97867f7b7c3c0a4e01fdede95d991ec332a2e17194549cc22ff2086f874379ad10f3449b613399996148eb565b941660608201528033940390a35f7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d005b34610294575f7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc360112610294576020604051620697808152f35b346102945760207ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc36011261029457600435907fffffffff00000000000000000000000000000000000000000000000000000000821680920361029457817f314987860000000000000000000000000000000000000000000000000000000060209314908115613498575b5015158152f35b7f7965db0b000000000000000000000000000000000000000000000000000000008114915081156134cb575b5083613491565b7f01ffc9a700000000000000000000000000000000000000000000000000000000915014836134c4565b9181601f840112156102945782359167ffffffffffffffff8311610294576020808501948460051b01011161029457565b6084359073ffffffffffffffffffffffffffffffffffffffff8216820361029457565b6024359073ffffffffffffffffffffffffffffffffffffffff8216820361029457565b6044359073ffffffffffffffffffffffffffffffffffffffff8216820361029457565b60c4359073ffffffffffffffffffffffffffffffffffffffff8216820361029457565b6004359073ffffffffffffffffffffffffffffffffffffffff8216820361029457565b359073ffffffffffffffffffffffffffffffffffffffff8216820361029457565b9181601f840112156102945782359167ffffffffffffffff8311610294576020838186019501011161029457565b7ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc6040910112610294576004359060243590565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff8211176111c557604052565b67ffffffffffffffff81116111c55760051b60200190565b9291906136bd81613699565b936136cb6040519586613658565b602085838152019160051b810192831161029457905b8282106136ed57505050565b602080916136fa846135d5565b8152019101906136e1565b9060407ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc83011261029457600435916024359067ffffffffffffffff8211610294578060238301121561029457816024613764936004013591016136b1565b90565b90600182811c921680156137ae575b602083101461378157565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52602260045260245ffd5b91607f1691613776565b9060405191825f8254926137cb84613767565b808452936001811690811561383657506001146137f2575b506137f092500383613658565b565b90505f9291925260205f20905f915b81831061381a5750509060206137f0928201015f6137e3565b6020919350806001915483858901015201910190918492613801565b602093506137f09592507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0091501682840152151560051b8201015f6137e3565b907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f602080948051918291828752018686015e5f8582860101520116010190565b91908201809211610f6757565b601f82602094937fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe093818652868601375f8582860101520116010190565b67ffffffffffffffff81116111c557601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe01660200190565b92919261394a82613904565b916139586040519384613658565b829481845281830111610294578281602093845f960137010152565b601f821161398157505050565b5f5260205f20906020601f840160051c830193106139b9575b601f0160051c01905b8181106139ae575050565b5f81556001016139a3565b909150819061399a565b156139cb5750565b7f360c6da4000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b9190811015613a065760051b0190565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b9190811015613a065760051b810135907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe18136030182121561029457019081359167ffffffffffffffff8311610294576020018236038113610294579190565b90918281527f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff83116102945760209260051b809284830137010190565b6002548060d01c8015159081613aff575b5015613af55760a01c65ffffffffffff1690565b5060015460d01c90565b905042115f613ae1565b3573ffffffffffffffffffffffffffffffffffffffff811681036102945790565b8051821015613a065760209160051b010190565b916020908281520191905f5b818110613b575750505090565b90919260208060019273ffffffffffffffffffffffffffffffffffffffff613b7e886135d5565b168152019401929101613b4a565b90602080835192838152019201905f5b818110613ba95750505090565b8251845260209384019390920191600101613b9c565b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005c613c0b5760017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005d565b7f3ee5aeb5000000000000000000000000000000000000000000000000000000005f5260045ffd5b60ff60035416613c3f57565b7fd93c0665000000000000000000000000000000000000000000000000000000005f5260045ffd5b93916137649593613c85928652606060208701526060860191613b3e565b926040818503910152613a93565b90604051916020830152602082526137f0604083613658565b9160048110613d9b5780600411610294577fffffffff0000000000000000000000000000000000000000000000000000000082351673ffffffffffffffffffffffffffffffffffffffff8416805f52600860205260405f20825f5260205260ff60405f20541615613d6d5750505f613d2b613d6294938293369161393e565b60208151910182855af13d15613d65573d91613d4683613904565b92613d546040519485613658565b83523d5f602085013e615051565b50565b606091615051565b7fc6ca67c5000000000000000000000000000000000000000000000000000000005f5260045260245260445ffd5b613dd86040519283927f105908ea0000000000000000000000000000000000000000000000000000000084526020600485015260248401916138c6565b0390fd5b335f9081527fad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5602052604090205460ff1615613e1457565b7fe2517d3f000000000000000000000000000000000000000000000000000000005f52336004525f60245260445ffd5b335f9081527fee57cd81e84075558e8fcc182a1f4393f91fc97f963a136e66b7f949a62f319f602052604090205460ff1615613e7c57565b7fe2517d3f000000000000000000000000000000000000000000000000000000005f52336004527f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92960245260445ffd5b805f525f60205260405f2073ffffffffffffffffffffffffffffffffffffffff33165f5260205260ff60405f20541615613f035750565b7fe2517d3f000000000000000000000000000000000000000000000000000000005f523360045260245260445ffd5b5f5b82811061408d575050507f667c036918e8dbe38a4ec9003830d89d321fbfffacba5bdecb14c1bbca99be015c5f7f667c036918e8dbe38a4ec9003830d89d321fbfffacba5bdecb14c1bbca99be015d7f667c036918e8dbe38a4ec9003830d89d321fbfffacba5bdecb14c1bbca99be025f9081527fe96e35370361806830d6ffae1085cb3cecf83f5e8c4d5baf97dbf2c679168812907f8ef871b0e777d2d19699d07d273e560f40eed55c2f5c0d2595bd0400809a6941905b838110613ffa5750505050565b8060019183015c8185015c9073ffffffffffffffffffffffffffffffffffffffff81165f527f667c036918e8dbe38a4ec9003830d89d321fbfffacba5bdecb14c1bbca99be0060205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f5260205260405f20905f825c925d8161407c575b50505001613fed565b61408592614ad5565b5f8080614073565b614098818484613a33565b60041161029457357fffffffff00000000000000000000000000000000000000000000000000000000167f036738d800000000000000000000000000000000000000000000000000000000810361423257506140f5818484613a33565b80600493929311610294578083019260848101359160048281018035936024808201358201808201959481013594929190850101891061422557604481013501600481013598602480830194928b010111614225577ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc6141769201906150ea565b5f868152600560205260409020805460019091015492949192904210610dbc57421015610d9457888103610d6c576141bf61071d92878796610bf18d86610be96130fb8661455c565b15610caa576131a48561318c8960019c73ffffffffffffffffffffffffffffffffffffffff97867f7b7c3c0a4e01fdede95d991ec332a2e17194549cc22ff2086f874379ad10f3449b6142119961480c565b941660608201528033940390a35b01613f34565b633b99b53d5f526004601cfd5b7fb08961120000000000000000000000000000000000000000000000000000000081036144b95750614265818484613a33565b91908260041161029457600481019081356024820135916044810135936142b460c4830135917ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc8901906150ea565b976084840135840160048101359492939183019260248083019287010184106142255760049060a48101350101968735936020808a019986010111614225575f8781526005602052604090208054600190910154904210610dbc57421015610d9457858503610d6c576143268761455c565b9373ffffffffffffffffffffffffffffffffffffffff8216988960208c6024604051809481937f6352211e00000000000000000000000000000000000000000000000000000000835260048301525afa8015610d61575f90614457575b73ffffffffffffffffffffffffffffffffffffffff9150163303610cd257856143f592610bf18f8a8f8d928f610be992611fc061071d9c61071d60405193849260208401968773ffffffffffffffffffffffffffffffffffffffff604092959493606083019683521660208201520152565b15610caa578a610c6d610c4d857fa7cddc59d500eff39733910ed97d6d46ce22672c36640271473d5d8cfed639649960019f968a73ffffffffffffffffffffffffffffffffffffffff986144489861480c565b911660808301520390a461421f565b506020813d82116144b1575b8161447060209383613658565b81010312610294575173ffffffffffffffffffffffffffffffffffffffff811681036102945773ffffffffffffffffffffffffffffffffffffffff90614383565b3d9150614463565b7f12ba286f000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b5f818152600660209081526040808320805490869055600783528184208481556001019390935580519283529082019390935290917fd1130d17a401a9f222864fc479ac48157a54fd10fc007f0ffe489d48bbf2394191a2565b9065ffffffffffff8091169116019065ffffffffffff8211610f6757565b805f52600760205260405f20548061457f575b505f52600660205260405f205490565b815f526007602052600160405f200154421061456f579081613764916144e4565b6137649073ffffffffffffffffffffffffffffffffffffffff6002541673ffffffffffffffffffffffffffffffffffffffff8216146145e0575b5f614b1b565b7fffffffffffffffffffffffff0000000000000000000000000000000000000000600254166002556145da565b906137649180158061464c575b15614b1b577fffffffffffffffffffffffff000000000000000000000000000000000000000060025416600255614b1b565b5073ffffffffffffffffffffffffffffffffffffffff6002541673ffffffffffffffffffffffffffffffffffffffff83161461461a565b6002549073ffffffffffffffffffffffffffffffffffffffff821661065a57613764917fffffffffffffffffffffffff000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff83169116176002555f614be9565b9081156146fb575b61376491614be9565b6002549173ffffffffffffffffffffffffffffffffffffffff831661065a577fffffffffffffffffffffffff000000000000000000000000000000000000000090921673ffffffffffffffffffffffffffffffffffffffff8216176002556146f2565b9192915f915b808310614772575050501490565b9091926147808483856139f6565b35908181101561479f575f52602052600160405f205b93019190614764565b905f52602052600160405f20614796565b906147ba82613699565b6147c76040519182613658565b8281527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe06147f58294613699565b0190602036910137565b91908203918211610f6757565b92919594909361481b876147b0565b965f5b81811061482e5750505050505050565b8089614840610428600194868c6139f6565b61488261484e84888b6139f6565b358a5f52600960205260405f2073ffffffffffffffffffffffffffffffffffffffff84165f5260205260405f2054906147ff565b908382614894575b505050500161481e565b6148db83916148e2958d5f52600960205260405f2073ffffffffffffffffffffffffffffffffffffffff86165f5260205260405f206148d48582546138b9565b9055613b2a565b5287614cb5565b895f808361488a565b929093959491956148fb876147b0565b965f5b81811061490e5750505050505050565b8080614920610428600194868c6139f6565b8761496361492f84898b6139f6565b358b5f52600960205260405f2073ffffffffffffffffffffffffffffffffffffffff85165f5260205260405f2054906147ff565b918d8b84614978575b505050505050016148fe565b6149be9585926149b8925f52600960205260405f2073ffffffffffffffffffffffffffffffffffffffff86165f5260205260405f206148d48582546138b9565b52614ad5565b805f87818d8b61496c565b65ffffffffffff81116149e15765ffffffffffff1690565b7f6dfcc650000000000000000000000000000000000000000000000000000000005f52603060045260245260445ffd5b73ffffffffffffffffffffffffffffffffffffffff1673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee8103614a4757503190565b9073ffffffffffffffffffffffffffffffffffffffff602460209260405194859384927f70a082310000000000000000000000000000000000000000000000000000000084521660048301525afa908115610d61575f91614aa6575090565b90506020813d602011614acd575b81614ac160209383613658565b81010312610294575190565b3d9150614ab4565b919073ffffffffffffffffffffffffffffffffffffffff831673eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee03614b12576137f09250614f76565b6137f092614e19565b805f525f60205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f5260205260ff60405f2054165f14614be357805f525f60205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f5260205260405f207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00815416905573ffffffffffffffffffffffffffffffffffffffff339216907ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b5f80a4600190565b50505f90565b805f525f60205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f5260205260ff60405f205416155f14614be357805f525f60205260405f2073ffffffffffffffffffffffffffffffffffffffff83165f5260205260405f2060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0082541617905573ffffffffffffffffffffffffffffffffffffffff339216907f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d5f80a4600190565b90918015614e145773ffffffffffffffffffffffffffffffffffffffff82165f527f667c036918e8dbe38a4ec9003830d89d321fbfffacba5bdecb14c1bbca99be0060205260405f2073ffffffffffffffffffffffffffffffffffffffff84165f5260205260405f20614d2a815c92836138b9565b905d15614d35575050565b7f667c036918e8dbe38a4ec9003830d89d321fbfffacba5bdecb14c1bbca99be015c9060018201808311610f67577f667c036918e8dbe38a4ec9003830d89d321fbfffacba5bdecb14c1bbca99be015d7f667c036918e8dbe38a4ec9003830d89d321fbfffacba5bdecb14c1bbca99be015f527f8ef871b0e777d2d19699d07d273e560f40eed55c2f5c0d2595bd0400809a694182015d7f667c036918e8dbe38a4ec9003830d89d321fbfffacba5bdecb14c1bbca99be025f527fe96e35370361806830d6ffae1085cb3cecf83f5e8c4d5baf97dbf2c679168812015d565b505050565b918015614e145773ffffffffffffffffffffffffffffffffffffffff604051927fa9059cbb00000000000000000000000000000000000000000000000000000000845216600483015260248201525f604060208260448582885af13d15601f3d11600185511416171692828152826020820152015215614e965750565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f3d011673ffffffffffffffffffffffffffffffffffffffff604051927f90bfb8650000000000000000000000000000000000000000000000000000000084521660048301527fa9059cbb000000000000000000000000000000000000000000000000000000006024830152608060448301528060a00160648301523d60848301523d5f60a484013e7ff27f64e40000000000000000000000000000000000000000000000000000000060c4828401600460a4820152015260e40190fd5b90801561504d575f80808093855af115614f8d5750565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f3d011673ffffffffffffffffffffffffffffffffffffffff604051927f90bfb8650000000000000000000000000000000000000000000000000000000084521660048301525f6024830152608060448301528060a00160648301523d60848301523d5f60a484013e7ff4b3b1bc0000000000000000000000000000000000000000000000000000000060c4828401600460a4820152015260e40190fd5b5050565b9061508e575080511561506657805190602001fd5b7fd6bda275000000000000000000000000000000000000000000000000000000005f5260045ffd5b815115806150e1575b61509f575090565b73ffffffffffffffffffffffffffffffffffffffff907f9996b315000000000000000000000000000000000000000000000000000000005f521660045260245ffd5b50803b15615097565b9160608301358301918235936020808501948601019101106142255756fea2646970667358221220123f7f60887de157fe217fb654a94f5fdbf230fa817536ed9e47f7bb33ca0ad564736f6c634300081c0033

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

000000000000000000000000be2f0354d970265bfc36d383af77f72736b81b5400000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000001200000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000022000000000000000000000000000000000000000000000000000000000000002600000000000000000000000000000000000000000000000000000000000001c200000000000000000000000000000000000000000000000000000000000000001000000000000000000000000697161a9ece8afd6ae30946d790077050f993cbc0000000000000000000000000000000000000000000000000000000000000006000000000000000000000000697161a9ece8afd6ae30946d790077050f993cbc000000000000000000000000335b0100340e87d807cd2796895ca99fe74a6c590000000000000000000000001dcfc0de40453891c8574c8f6f7d51c67f069ad9000000000000000000000000dbef4af51b49ba2497ba16694475e109fc374999000000000000000000000000a322638e6891e8c4e2ab6d2f5539fb8b7931db130000000000000000000000000de7de941c89579f3c70307712ee257b9fd5eb9d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000e97c887b61ccd952a53578b04763e7134429e050000000000000000000000000000000000000000000000000000000000000001aa5d82c300000000000000000000000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : initialAdmin (address): 0xBE2F0354D970265BFc36D383af77F72736b81B54
Arg [1] : initialOperators (address[]): 0x697161A9ECE8aFD6AE30946D790077050F993cbc
Arg [2] : initialGuardians (address[]): 0x697161A9ECE8aFD6AE30946D790077050F993cbc,0x335b0100340e87D807cD2796895Ca99Fe74A6c59,0x1dcfC0de40453891C8574c8F6F7d51c67F069aD9,0xdbEF4Af51B49Ba2497ba16694475e109Fc374999,0xa322638e6891e8c4E2ab6D2F5539fB8b7931Db13,0x0de7dE941c89579f3C70307712Ee257b9Fd5eb9d
Arg [3] : initialRescuers (address[]):
Arg [4] : initialWhitelistedHooks (address[]): 0x0e97C887b61cCd952a53578B04763E7134429e05
Arg [5] : initialWhitelistedSelectors (bytes4[]): System.Byte[]
Arg [6] : initDefaultTimeLock (uint256): 7200

-----Encoded View---------------
21 Constructor Arguments found :
Arg [0] : 000000000000000000000000be2f0354d970265bfc36d383af77f72736b81b54
Arg [1] : 00000000000000000000000000000000000000000000000000000000000000e0
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000120
Arg [3] : 0000000000000000000000000000000000000000000000000000000000000200
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000220
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000260
Arg [6] : 0000000000000000000000000000000000000000000000000000000000001c20
Arg [7] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [8] : 000000000000000000000000697161a9ece8afd6ae30946d790077050f993cbc
Arg [9] : 0000000000000000000000000000000000000000000000000000000000000006
Arg [10] : 000000000000000000000000697161a9ece8afd6ae30946d790077050f993cbc
Arg [11] : 000000000000000000000000335b0100340e87d807cd2796895ca99fe74a6c59
Arg [12] : 0000000000000000000000001dcfc0de40453891c8574c8f6f7d51c67f069ad9
Arg [13] : 000000000000000000000000dbef4af51b49ba2497ba16694475e109fc374999
Arg [14] : 000000000000000000000000a322638e6891e8c4e2ab6d2f5539fb8b7931db13
Arg [15] : 0000000000000000000000000de7de941c89579f3c70307712ee257b9fd5eb9d
Arg [16] : 0000000000000000000000000000000000000000000000000000000000000000
Arg [17] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [18] : 0000000000000000000000000e97c887b61ccd952a53578b04763e7134429e05
Arg [19] : 0000000000000000000000000000000000000000000000000000000000000001
Arg [20] : aa5d82c300000000000000000000000000000000000000000000000000000000


Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading
0xEae300Ac9409B2072697CA1d5fD137f8bB286f9c
Net Worth in USD
$91,379.80

Net Worth in ETH
46.843634

Token Allocations
KNC 46.52%
USDC 16.38%
ETH 12.76%
Others 24.34%
Chain Token Portfolio % Price Amount Value
ETH38.30%$0.144712241,821.7137$34,994.5
ETH7.92%$0.998417,249.8583$7,238.33
ETH7.89%$0.9995657,212.6599$7,209.52
ETH0.54%$1.22405.3756$494.56
ETH
Ether (ETH)
0.34%$1,950.740.1603$312.75
ETH0.17%$2,767.010.0549$151.94
ETH0.15%$5,102.580.0261$133.2
ETH0.05%$71,0990.00066621$47.37
ETH0.05%$76,3310.00061972$47.3
ETH0.04%$5,073.750.006957$35.3
ETH0.03%$0.99948726.1718$26.16
ETH0.01%$76,1490.00013466$10.25
ETH<0.01%$2,459.090.000141$0.3467
BASE15.17%$0.99990513,865.4694$13,864.15
BASE11.96%$1,949.865.6064$10,931.65
BASE1.22%$0.1446867,677.5011$1,110.83
BASE0.62%$0.5392891,048.9097$565.67
BASE0.28%$76,3310.00331932$253.37
BASE0.06%$0.250787206.8743$51.88
BASE0.03%$1.1923.9648$28.52
BASE0.03%$2,178.760.0113$24.56
BASE<0.01%$0.020507154.4305$3.17
BASE<0.01%$13.1434$3.15
BASE<0.01%$2,263.380.0001$0.2263
BSC4.89%$0.14468630,913.2469$4,472.71
BSC3.88%$0.9995343,542.7096$3,541.06
BSC1.62%$591.632.5061$1,482.66
BSC1.07%$0.999926981.9812$981.91
BSC0.36%$1,942.050.1684$327.12
BSC0.14%$0.65216190.3339$124.13
BSC0.08%$0.99978977.1741$77.16
BSC0.08%$0.0445541,615.8796$71.99
BSC0.05%$66,640.990.00070841$47.21
BSC0.02%$1.2713.2002$16.76
BSC0.01%$113.133$13.14
ARB2.12%$0.14471213,375.7325$1,935.63
ARB0.29%$76,1770.00343722$261.84
ARB0.17%$0.998438151.3823$151.15
ARB0.13%$0.999907122.9401$122.93
ARB0.13%$76,3900.00159735$122.02
ARB0.10%$1,950.720.0445$86.83
ARB<0.01%$2,767.960.00157585$4.36
ARB<0.01%$0.9999070.4966$0.4965
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ 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.