HYPE Price: $37.62 (-2.53%)

Contract

0x40Ba056B004Edd0b572509A1276Fd8530cf2bb7f

Overview

HYPE Balance

HyperEvm LogoHyperEvm LogoHyperEvm Logo0 HYPE

HYPE Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To
Claim26137822025-04-17 17:08:1481 days ago1744909694IN
0x40Ba056B...30cf2bb7f
0 HYPE0.000004020.1
Claim26137812025-04-17 17:08:1281 days ago1744909692IN
0x40Ba056B...30cf2bb7f
0 HYPE0.000004070.1
Claim26137802025-04-17 17:08:1081 days ago1744909690IN
0x40Ba056B...30cf2bb7f
0 HYPE0.000004070.1
Claim26137802025-04-17 17:08:1081 days ago1744909690IN
0x40Ba056B...30cf2bb7f
0 HYPE0.000004070.1
Claim23047962025-04-10 18:59:0888 days ago1744311548IN
0x40Ba056B...30cf2bb7f
0 HYPE0.00000520.1358111
Claim23039322025-04-10 18:31:1688 days ago1744309876IN
0x40Ba056B...30cf2bb7f
0 HYPE0.000004210.11
Update22767822025-04-10 3:55:2888 days ago1744257328IN
0x40Ba056B...30cf2bb7f
0 HYPE0.000007760.1
Claim22754192025-04-10 3:11:3088 days ago1744254690IN
0x40Ba056B...30cf2bb7f
0 HYPE0.000003820.1
Update22656222025-04-09 21:55:2889 days ago1744235728IN
0x40Ba056B...30cf2bb7f
0 HYPE0.000017980.23150668
Update22637682025-04-09 20:55:4089 days ago1744232140IN
0x40Ba056B...30cf2bb7f
0 HYPE0.000004520.1
Update22358652025-04-09 5:55:3489 days ago1744178134IN
0x40Ba056B...30cf2bb7f
0 HYPE0.000003140.1
Update22358642025-04-09 5:55:3289 days ago1744178132IN
0x40Ba056B...30cf2bb7f
0 HYPE0.000003170.1
Claim21733482025-04-07 20:18:5491 days ago1744057134IN
0x40Ba056B...30cf2bb7f
0 HYPE0.000004590.12
Update21707642025-04-07 18:55:3291 days ago1744052132IN
0x40Ba056B...30cf2bb7f
0 HYPE0.000003140.1
Update21707632025-04-07 18:55:3091 days ago1744052130IN
0x40Ba056B...30cf2bb7f
0 HYPE0.000003170.1
Claim21095172025-04-06 9:58:0492 days ago1743933484IN
0x40Ba056B...30cf2bb7f
0 HYPE0.000004630.12108118
Update20707062025-04-05 13:06:0693 days ago1743858366IN
0x40Ba056B...30cf2bb7f
0 HYPE0.000007940.10230748
Claim20689332025-04-05 12:08:5693 days ago1743854936IN
0x40Ba056B...30cf2bb7f
0 HYPE0.000004640.1211865
Claim20525172025-04-05 3:19:2293 days ago1743823162IN
0x40Ba056B...30cf2bb7f
0 HYPE0.000002620.10012656
Claim20525152025-04-05 3:19:1893 days ago1743823158IN
0x40Ba056B...30cf2bb7f
0 HYPE0.000002620.10012656
Claim20525092025-04-05 3:19:0693 days ago1743823146IN
0x40Ba056B...30cf2bb7f
0 HYPE0.000003830.10012656
Update20483872025-04-05 1:06:0894 days ago1743815168IN
0x40Ba056B...30cf2bb7f
0 HYPE0.000003140.1
Update20483852025-04-05 1:06:0494 days ago1743815164IN
0x40Ba056B...30cf2bb7f
0 HYPE0.000003190.10042857
Claim19887582025-04-03 17:02:3895 days ago1743699758IN
0x40Ba056B...30cf2bb7f
0 HYPE0.000007960.20803856
Claim19886852025-04-03 17:00:1695 days ago1743699616IN
0x40Ba056B...30cf2bb7f
0 HYPE0.00000590.15428157
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block From To
26137822025-04-17 17:08:1481 days ago1744909694
0x40Ba056B...30cf2bb7f
0.33405452 HYPE
26137812025-04-17 17:08:1281 days ago1744909692
0x40Ba056B...30cf2bb7f
0.59198288 HYPE
26137802025-04-17 17:08:1081 days ago1744909690
0x40Ba056B...30cf2bb7f
0.03608744 HYPE
26137802025-04-17 17:08:1081 days ago1744909690
0x40Ba056B...30cf2bb7f
0.08461697 HYPE
23047962025-04-10 18:59:0888 days ago1744311548
0x40Ba056B...30cf2bb7f
0.33404195 HYPE
23039322025-04-10 18:31:1688 days ago1744309876
0x40Ba056B...30cf2bb7f
1.50197466 HYPE
22767822025-04-10 3:55:2888 days ago1744257328
0x40Ba056B...30cf2bb7f
0.00668096 HYPE
22767812025-04-10 3:55:2688 days ago1744257326
0x40Ba056B...30cf2bb7f
0.67477744 HYPE
22754192025-04-10 3:11:3088 days ago1744254690
0x40Ba056B...30cf2bb7f
0.19706638 HYPE
22656222025-04-09 21:55:2889 days ago1744235728
0x40Ba056B...30cf2bb7f
0.00501974 HYPE
22656212025-04-09 21:55:2689 days ago1744235726
0x40Ba056B...30cf2bb7f
0.5069944 HYPE
22637672025-04-09 20:55:3889 days ago1744232138
0x40Ba056B...30cf2bb7f
1 HYPE
22358642025-04-09 5:55:3289 days ago1744178132
0x40Ba056B...30cf2bb7f
0.00197066 HYPE
22358632025-04-09 5:55:3089 days ago1744178130
0x40Ba056B...30cf2bb7f
0.19903704 HYPE
21733482025-04-07 20:18:5491 days ago1744057134
0x40Ba056B...30cf2bb7f
0.03007239 HYPE
21707632025-04-07 18:55:3091 days ago1744052130
0x40Ba056B...30cf2bb7f
0.00591982 HYPE
21707622025-04-07 18:55:2891 days ago1744052128
0x40Ba056B...30cf2bb7f
0.59790271 HYPE
21095172025-04-06 9:58:0492 days ago1743933484
0x40Ba056B...30cf2bb7f
0.02406594 HYPE
20707062025-04-05 13:06:0693 days ago1743858366
0x40Ba056B...30cf2bb7f
0.00024065 HYPE
20707052025-04-05 13:06:0493 days ago1743858364
0x40Ba056B...30cf2bb7f
0.0243066 HYPE
20689332025-04-05 12:08:5693 days ago1743854936
0x40Ba056B...30cf2bb7f
0.00601446 HYPE
20525092025-04-05 3:19:0693 days ago1743823146
0x40Ba056B...30cf2bb7f
0.03059407 HYPE
20483862025-04-05 1:06:0694 days ago1743815166
0x40Ba056B...30cf2bb7f
0.00030594 HYPE
20483852025-04-05 1:06:0494 days ago1743815164
0x40Ba056B...30cf2bb7f
0.03090001 HYPE
20336722025-04-04 17:11:2894 days ago1743786688
0x40Ba056B...30cf2bb7f
0.00072174 HYPE
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
stHYPEWithdrawalModule

Compiler Version
v0.8.25+commit.b61c2a91

Optimization Enabled:
Yes with 10000 runs

Other Settings:
cancun EvmVersion
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.25;

import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {SafeCast} from "@openzeppelin/contracts/utils/math/SafeCast.sol";
import {ReentrancyGuardTransient} from "@openzeppelin/contracts/utils/ReentrancyGuardTransient.sol";

import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {ISovereignPool} from "@valantis-core/pools/interfaces/ISovereignPool.sol";

import {IOverseer} from "./interfaces/IOverseer.sol";
import {IstHYPE} from "./interfaces/IstHYPE.sol";
import {IWithdrawalModule} from "./interfaces/IWithdrawalModule.sol";
import {IWETH9} from "./interfaces/IWETH9.sol";
import {ISTEXAMM} from "./interfaces/ISTEXAMM.sol";
import {ILendingModule} from "./interfaces/ILendingModule.sol";
import {LPWithdrawalRequest, LendingModuleProposal} from "./structs/WithdrawalModuleStructs.sol";

/**
 * @notice Withdrawal Module for integration between STEX AMM and Thunderheads' Staked Hype,
 *         and modular, upgradeable integration with a lending protocol via the Lending Module Interface.
 */
contract stHYPEWithdrawalModule is IWithdrawalModule, ReentrancyGuardTransient, Ownable {
    using SafeCast for uint256;
    using SafeERC20 for IWETH9;
    using SafeERC20 for ERC20;

    /**
     *
     *  EVENTS
     *
     */
    event STEXSet(address stex);
    event LPWithdrawalRequestCreated(uint256 id, uint256 amountToken1, address recipient);
    event LPWithdrawalRequestClaimed(uint256 id);
    event LendingModuleProposed(address lendingModule, uint256 startTimestamp);
    event LendingModuleProposalCancelled();
    event LendingModuleSet(address lendingModule);
    event AmountSuppliedToLendingModule(uint256 amount);
    event AmountWithdrawnFromLendingModule(uint256 amount);

    /**
     *
     *  CUSTOM ERRORS
     *
     */
    error stHYPEWithdrawalModule__ZeroAddress();
    error stHYPEWithdrawalModule__OnlySTEX();
    error stHYPEWithdrawalModule__OnlySTEXOrOwner();
    error stHYPEWithdrawalModule__PoolNonReentrant();
    error stHYPEWithdrawalModule__claim_alreadyClaimed();
    error stHYPEWithdrawalModule__claim_cannotYetClaim();
    error stHYPEWithdrawalModule__claim_insufficientAmountToClaim();
    error stHYPEWithdrawalModule__setSTEX_AlreadySet();
    error stHYPEWithdrawalModule__withdrawToken1FromLendingPool_insufficientAmountWithdrawn();
    error stHYPEWithdrawalModule___verifyTimelockDelay_timelockTooLow();
    error stHYPEWithdrawalModule___verifyTimelockDelay_timelockTooHigh();
    error stHYPEWithdrawalModule__proposeLendingModule_ProposalAlreadyActive();
    error stHYPEWithdrawalModule__setProposedLendingModule_ProposalNotActive();
    error stHYPEWithdrawalModule__setProposedLendingModule_InactiveProposal();

    /**
     *
     *  CONSTANTS
     *
     */
    uint256 private constant MIN_TIMELOCK_DELAY = 3 days;
    uint256 private constant MAX_TIMELOCK_DELAY = 7 days;

    /**
     *
     *  IMMUTABLES
     *
     */

    /**
     * @notice Overseer contract from Thunderheads' Liquid Staking Protocol.
     */
    address public immutable overseer;

    /**
     *
     *  STORAGE
     *
     */

    /**
     * @notice Address of Stake Exchange AMM (STEX AMM) deployment.
     */
    address public stex;

    /**
     * @notice Address of `stex` Sovereign Pool deployment.
     */
    address public pool;

    /**
     * @notice Amount of native `token1` which is ready for eligible STEX AMM LPs to claim.
     */
    uint256 public amountToken1ClaimableLPWithdrawal;

    /**
     * @notice Cumulative amount of native `token1` owed to LP withdrawals.
     */
    uint256 public cumulativeAmountToken1LPWithdrawal;

    /**
     * @notice Cumulative amount of native `token1` claimable by LP withdrawals.
     */
    uint256 public cumulativeAmountToken1ClaimableLPWithdrawal;

    /**
     * @notice Unique identifier for each LP Withdrawal Request.
     */
    uint256 public idLPWithdrawal;

    /**
     * @notice mapping from `idLPWithdrawal` to its respective `LPWithdrawalRequest` data.
     */
    mapping(uint256 => LPWithdrawalRequest) public LPWithdrawals;

    /**
     * @notice Address of proposed lending module to interact with lending protocol.
     * @dev WARNING: This is a critical dependency which can affect the solvency of the pool and this contract.
     *      Updates to lending module happen under a 3-7 days timelock and assumes that `owner`
     *      implements sufficient internal security checks.
     */
    LendingModuleProposal public lendingModuleProposal;

    /**
     * @notice Address of lending module to interact with lending protocol.
     */
    ILendingModule public lendingModule;

    /**
     * @notice Amount of `token0` pending unstaking in the `overseer` withdrawal queue.
     * @dev This will change as excess native token balance gets added to this contract.
     */
    uint256 private _amountToken0PendingUnstaking;

    /**
     * @notice Amount of native `token1` which is owed to STEX AMM LPs who have burnt their LP tokens.
     * @dev This will change as excess native token balance gets added to this contract.
     */
    uint256 public _amountToken1PendingLPWithdrawal;

    /**
     *
     *  CONSTRUCTOR
     *
     */
    constructor(address _overseer, address _owner) Ownable(_owner) {
        // _lendingPool can be zero address, in case it is not set
        if (_overseer == address(0) || _owner == address(0)) {
            revert stHYPEWithdrawalModule__ZeroAddress();
        }

        overseer = _overseer;
    }

    /**
     *
     *  MODIFIERS
     *
     */
    modifier onlySTEX() {
        if (msg.sender != stex) {
            revert stHYPEWithdrawalModule__OnlySTEX();
        }
        _;
    }

    modifier onlySTEXOrOwner() {
        if (msg.sender != stex && msg.sender != owner()) {
            revert stHYPEWithdrawalModule__OnlySTEXOrOwner();
        }
        _;
    }

    modifier whenPoolNotLocked() {
        if (ISovereignPool(pool).isLocked()) {
            revert stHYPEWithdrawalModule__PoolNonReentrant();
        }
        _;
    }

    /**
     *
     *  VIEW FUNCTIONS
     *
     */

    /**
     * @notice Returns true if ReentrancyGuard lock is active, false otherwise.
     */
    function isLocked() external view override returns (bool) {
        return _reentrancyGuardEntered();
    }

    function convertToToken0(uint256 _amountToken1) public pure override returns (uint256) {
        // stHYPE is rebase
        return _amountToken1;
    }

    function convertToToken1(uint256 _amountToken0) public pure override returns (uint256) {
        // stHYPE is rebase
        return _amountToken0;
    }

    function token0SharesToBalance(uint256 _shares) public view override returns (uint256) {
        ISTEXAMM stexInterface = ISTEXAMM(stex);
        IstHYPE token0 = IstHYPE(stexInterface.token0());

        return token0.sharesToBalance(_shares);
    }

    function token0BalanceToShares(uint256 _balance) public view override returns (uint256) {
        ISTEXAMM stexInterface = ISTEXAMM(stex);
        IstHYPE token0 = IstHYPE(stexInterface.token0());

        return token0.balanceToShares(_balance);
    }

    function token0SharesOf(address _account) public view override returns (uint256) {
        ISTEXAMM stexInterface = ISTEXAMM(stex);
        IstHYPE token0 = IstHYPE(stexInterface.token0());

        return token0.sharesOf(_account);
    }

    /**
     * @notice Returns the LP withdrawal request for the given `_idLPWithdrawal`.
     * @param _idLPWithdrawal The ID of the LP withdrawal request to retrieve.
     * @return The LP withdrawal request for the given ID.
     */
    function getLPWithdrawals(uint256 _idLPWithdrawal) public view override returns (LPWithdrawalRequest memory) {
        return LPWithdrawals[_idLPWithdrawal];
    }

    /**
     * @notice Tracks amount of token0 which is pending unstaking through `overseer`.
     * @dev It is assumed that `overseer` will replenish this contract with native token as
     *      unstaking requests get fulfilled.
     * @dev This needs to be tracked as a function of surplus native token balance in this contract,
     *      in order to maintain consistent accounting before `update` gets called.
     */
    function amountToken0PendingUnstaking() public view override returns (uint256) {
        // stHYPE is rebase, hence no need to convert from native to token0 balance
        uint256 excessToken0 = _getExcessNativeBalance();

        uint256 amountToken0PendingUnstakingCache = _amountToken0PendingUnstaking;
        if (amountToken0PendingUnstakingCache > excessToken0) {
            return amountToken0PendingUnstakingCache - excessToken0;
        } else {
            return 0;
        }
    }

    /**
     * @notice Tracks amount of token1 which is owed to LP withdrawal requests.
     * @dev This needs to be tracked as a function of surplus native token balance in this contract,
     *      in order to maintain consistent accounting before `update` gets called.
     */
    function amountToken1PendingLPWithdrawal() public view override returns (uint256) {
        uint256 excessNativeBalance = _getExcessNativeBalance();

        uint256 amountToken1PendingLPWithdrawalCache = _amountToken1PendingLPWithdrawal;
        if (amountToken1PendingLPWithdrawalCache > excessNativeBalance) {
            return amountToken1PendingLPWithdrawalCache - excessNativeBalance;
        } else {
            return 0;
        }
    }

    /**
     * @notice Returns amount of token1 owned in the lending module.
     */
    function amountToken1LendingPool() public view override returns (uint256) {
        if (address(lendingModule) != address(0)) {
            // Returns balance of underlying token (token1) in the Lending Module's lending protocol position
            return lendingModule.assetBalance();
        } else {
            return 0;
        }
    }

    /**
     *
     *  EXTERNAL FUNCTIONS
     *
     */

    /**
     * @notice Sets the STEX AMM address and respective Sovereign Pool deployment.
     * @dev Callable by `owner` only once.
     * @param _stex Stake Exchange AMM address to set.
     */
    function setSTEX(address _stex) external onlyOwner {
        if (_stex == address(0)) revert stHYPEWithdrawalModule__ZeroAddress();
        // Can only be set once
        if (stex != address(0)) {
            revert stHYPEWithdrawalModule__setSTEX_AlreadySet();
        }

        stex = _stex;
        pool = ISTEXAMM(_stex).pool();

        emit STEXSet(_stex);
    }

    /**
     * @notice Propose an update to Lending Module.
     * @dev Only callable by `owner`.
     * @dev WARNING: This is a critical dependency which affects the solvency of the pool and this contract,
     *      hence `owner` should have sufficient internal checks and protections.
     * @param _lendingModule Address of new Lending Module to set.
     * @param _timelockDelay 3-7 days timelock delay.
     */
    function proposeLendingModule(address _lendingModule, uint256 _timelockDelay) external onlyOwner {
        _verifyTimelockDelay(_timelockDelay);

        if (lendingModuleProposal.startTimestamp > 0) {
            revert stHYPEWithdrawalModule__proposeLendingModule_ProposalAlreadyActive();
        }

        lendingModuleProposal =
            LendingModuleProposal({lendingModule: _lendingModule, startTimestamp: block.timestamp + _timelockDelay});
        emit LendingModuleProposed(_lendingModule, block.timestamp + _timelockDelay);
    }

    /**
     * @notice Cancel a pending update proposal to Lending Module.
     * @dev Only callable by `owner`.
     */
    function cancelLendingModuleProposal() external onlyOwner {
        emit LendingModuleProposalCancelled();
        delete lendingModuleProposal;
    }

    /**
     * @notice Set the proposed Lending Module after timelock has passed.
     * @dev Only callable by `owner`.
     */
    function setProposedLendingModule() external onlyOwner whenPoolNotLocked {
        if (lendingModuleProposal.startTimestamp > block.timestamp) {
            revert stHYPEWithdrawalModule__setProposedLendingModule_ProposalNotActive();
        }

        if (lendingModuleProposal.startTimestamp == 0) {
            revert stHYPEWithdrawalModule__setProposedLendingModule_InactiveProposal();
        }

        // Withdraw all token1 amount from lending module back into pool
        if (address(lendingModule) != address(0)) {
            uint256 amountToken1LendingModule = lendingModule.assetBalance();

            if (amountToken1LendingModule > 0) {
                lendingModule.withdraw(amountToken1LendingModule, pool);
            }
        }

        // Set new lending module
        lendingModule = ILendingModule(lendingModuleProposal.lendingModule);

        delete lendingModuleProposal;

        emit LendingModuleSet(address(lendingModule));
    }

    /**
     * @dev This contract will receive token1 in native form,
     *      as pending unstaking requests are settled.
     */
    receive() external payable {}

    /**
     * @notice This function gets called after an LP burns its LP tokens,
     *         in order to create a pending request
     * @dev Only callable by the AMM.
     * @param _amountToken0 Amount of token0 which would be due to `_recipient`.
     * @param _recipient Address which should receive the amounts from this withdrawal's request once fulfilled.
     */
    function burnToken0AfterWithdraw(uint256 _amountToken0, address _recipient)
        external
        override
        onlySTEX
        nonReentrant
    {
        // stHYPE is rebase, hence to need for conversion
        uint256 amountToken1 = _amountToken0;

        _amountToken1PendingLPWithdrawal += amountToken1;

        emit LPWithdrawalRequestCreated(idLPWithdrawal, amountToken1, _recipient);

        LPWithdrawals[idLPWithdrawal] = LPWithdrawalRequest({
            recipient: _recipient,
            amountToken1: amountToken1.toUint96(),
            cumulativeAmountToken1LPWithdrawalCheckpoint: cumulativeAmountToken1LPWithdrawal
        });
        idLPWithdrawal++;

        cumulativeAmountToken1LPWithdrawal += amountToken1;
    }

    /**
     * @notice This function gets called by either:
     *         - AMM, after an LP burns its LP tokens,
     *           in order to withdraw `token1` amounts from the lending protocol.
     *         - `owner`, to withdraw `token1` from lending protocol back into pool.
     * @dev Only callable by the AMM or `owner`.
     * @param _amountToken1 Amount of token1 which is due to `_recipient` or pool.
     * @param _recipient Address which should receive `_amountToken1` of `token1`,
     *                   only relevant if msg.sender == AMM.
     */
    function withdrawToken1FromLendingPool(uint256 _amountToken1, address _recipient)
        external
        override
        onlySTEXOrOwner
        nonReentrant
        whenPoolNotLocked
    {
        if (address(lendingModule) == address(0)) return;
        if (_amountToken1 == 0) return;

        address recipient = msg.sender == stex ? _recipient : pool;
        address token1 = ISTEXAMM(stex).token1();

        uint256 preBalance = ERC20(token1).balanceOf(recipient);
        lendingModule.withdraw(_amountToken1, recipient);
        uint256 postBalance = ERC20(token1).balanceOf(recipient);
        // Ensure that recipient gets at least `_amountToken1` worth of token1
        if (postBalance - preBalance < _amountToken1) {
            revert stHYPEWithdrawalModule__withdrawToken1FromLendingPool_insufficientAmountWithdrawn();
        }
        emit AmountWithdrawnFromLendingModule(_amountToken1);
    }

    /**
     * @notice Withdraws a portion of pool's token1 reserves and supplies to `lendingPool` to earn extra yield.
     * @dev Only callable by `owner`.
     */
    function supplyToken1ToLendingPool(uint256 _amountToken1) external onlyOwner nonReentrant {
        if (address(lendingModule) == address(0)) return;
        if (_amountToken1 == 0) return;

        ISTEXAMM stexInterface = ISTEXAMM(stex);
        stexInterface.supplyToken1Reserves(_amountToken1);

        address token1 = stexInterface.token1();

        IWETH9(token1).forceApprove(address(lendingModule), _amountToken1);
        // WARNING: Assumes that lending module deposits the total `_amountToken1` (no partial deposits)
        lendingModule.deposit(_amountToken1);
        emit AmountSuppliedToLendingModule(_amountToken1);
    }

    /**
     * @notice Claims pool's accummulated token0 reserves and executes an unstaking request (burn) via `overseer`.
     * @dev Only callable by `owner`.
     * @param _unstakeAmountToken0 Amount of `token0` reserves to unstake.
     */
    function unstakeToken0Reserves(uint256 _unstakeAmountToken0) external override nonReentrant onlyOwner {
        ISTEXAMM stexInterface = ISTEXAMM(stex);
        stexInterface.unstakeToken0Reserves(_unstakeAmountToken0);

        address token0 = stexInterface.token0();
        uint256 amountToken0 = IstHYPE(token0).balanceOf(address(this));
        _amountToken0PendingUnstaking += amountToken0;

        // Burn amountToken0 worth of token0 through withdrawal queue.
        // Once completed, an equivalent amount of native token1 should be transferred into this contract
        // WARNING: This implementation assumes that there is no slashing enabled in the LST protocol
        ERC20(token0).forceApprove(overseer, amountToken0);
        IOverseer(overseer).burnAndRedeemIfPossible(address(this), amountToken0, "");
    }

    /**
     * @notice Checks current balance of native token and updates state.
     * @dev Pending LP withdrawals are prioritized,
     *      and any remaining native token is wrapped and transfered to
     *      the AMM's Sovereign Pool.
     */
    function update() external override nonReentrant whenPoolNotLocked {
        // Need to ensure that enough native token is reserved for settled LP withdrawals
        // WARNING: This implementation assumes that there is no slashing enabled in the LST protocol
        uint256 excessNativeBalance = _getExcessNativeBalance();
        if (excessNativeBalance == 0) return;

        uint256 amountToken0PendingUnstakingCache = _amountToken0PendingUnstaking;
        // token0 is rebase, hence directly comparable against native token balance
        if (amountToken0PendingUnstakingCache > excessNativeBalance) {
            _amountToken0PendingUnstaking = amountToken0PendingUnstakingCache - excessNativeBalance;
        } else {
            _amountToken0PendingUnstaking = 0;
        }

        // Prioritize pending LP withdrawal requests
        uint256 amountToken1PendingLPWithdrawalCache = _amountToken1PendingLPWithdrawal;
        if (excessNativeBalance > amountToken1PendingLPWithdrawalCache) {
            excessNativeBalance -= amountToken1PendingLPWithdrawalCache;
            amountToken1ClaimableLPWithdrawal += amountToken1PendingLPWithdrawalCache;
            cumulativeAmountToken1ClaimableLPWithdrawal += amountToken1PendingLPWithdrawalCache;
            _amountToken1PendingLPWithdrawal = 0;
        } else {
            _amountToken1PendingLPWithdrawal -= excessNativeBalance;
            amountToken1ClaimableLPWithdrawal += excessNativeBalance;
            cumulativeAmountToken1ClaimableLPWithdrawal += excessNativeBalance;
            excessNativeBalance = 0;
            return;
        }

        // Wrap native token into token1 and re-deposit into the pool
        address token1Address = ISTEXAMM(stex).token1();
        IWETH9 token1 = IWETH9(token1Address);

        token1.deposit{value: excessNativeBalance}();
        // Pool reserves are measured as balances, hence we can replenish it with token1
        // by transfering directly
        token1.safeTransfer(pool, excessNativeBalance);
    }

    /**
     * @notice Claims a LP withdrawal request which has already been fulfilled.
     * @dev Anyone can claim on behalf of its recipient.
     * @param _idLPQueue Id of LP's withdrawal request to claim.
     */
    function claim(uint256 _idLPQueue) external override nonReentrant {
        // WARNING: This implementation assumes that there is no slashing enabled in the LST protocol

        LPWithdrawalRequest memory request = LPWithdrawals[_idLPQueue];

        if (request.amountToken1 == 0) {
            revert stHYPEWithdrawalModule__claim_alreadyClaimed();
        }

        // Check if there is enough ETH available to fulfill this request
        if (amountToken1ClaimableLPWithdrawal < request.amountToken1) {
            revert stHYPEWithdrawalModule__claim_insufficientAmountToClaim();
        }

        // Check if it is the right time to claim (according to queue priority)
        if (
            cumulativeAmountToken1ClaimableLPWithdrawal
                < request.cumulativeAmountToken1LPWithdrawalCheckpoint + request.amountToken1
        ) {
            revert stHYPEWithdrawalModule__claim_cannotYetClaim();
        }

        amountToken1ClaimableLPWithdrawal -= request.amountToken1;

        emit LPWithdrawalRequestClaimed(_idLPQueue);

        delete LPWithdrawals[_idLPQueue];

        // Send equivalent amount of native token to recipient
        Address.sendValue(payable(request.recipient), request.amountToken1);
    }

    /**
     *
     *  PRIVATE FUNCTIONS
     *
     */
    function _getExcessNativeBalance() private view returns (uint256) {
        // Calculates native token balance in excess of the balance already claimable by processed LP withdrawals
        // This will be used to net against pending LP withdrawals, and any leftover can be transferred
        // to STEX AMM's pool via `update`
        uint256 balanceNative = address(this).balance;
        uint256 excessBalanceNative =
            balanceNative > amountToken1ClaimableLPWithdrawal ? balanceNative - amountToken1ClaimableLPWithdrawal : 0;

        return excessBalanceNative;
    }

    function _verifyTimelockDelay(uint256 _timelockDelay) private pure {
        if (_timelockDelay < MIN_TIMELOCK_DELAY) {
            revert stHYPEWithdrawalModule___verifyTimelockDelay_timelockTooLow();
        }

        if (_timelockDelay > MAX_TIMELOCK_DELAY) {
            revert stHYPEWithdrawalModule___verifyTimelockDelay_timelockTooHigh();
        }
    }
}

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

pragma solidity ^0.8.20;

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

/**
 * @dev Interface for the optional metadata functions from the ERC-20 standard.
 */
interface IERC20Metadata is IERC20 {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

File 3 of 33 : IFlashBorrower.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.19;

interface IFlashBorrower {
    /**
        @dev Receive a flash loan.
        @param initiator The initiator of the loan.
        @param token The loan currency.
        @param amount The amount of tokens lent.
        @param data Arbitrary data structure, intended to contain user-defined parameters.
        @return The keccak256 hash of "ERC3156FlashBorrower.onFlashLoan"
     */
    function onFlashLoan(
        address initiator,
        address token,
        uint256 amount,
        bytes calldata data
    ) external returns (bytes32);
}

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

File 5 of 33 : 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 6 of 33 : SovereignPoolStructs.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import { IERC20 } from '../../../lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol';

import { ISwapFeeModule } from '../../swap-fee-modules/interfaces/ISwapFeeModule.sol';

struct SovereignPoolConstructorArgs {
    address token0;
    address token1;
    address protocolFactory;
    address poolManager;
    address sovereignVault;
    address verifierModule;
    bool isToken0Rebase;
    bool isToken1Rebase;
    uint256 token0AbsErrorTolerance;
    uint256 token1AbsErrorTolerance;
    uint256 defaultSwapFeeBips;
}

struct SovereignPoolSwapContextData {
    bytes externalContext;
    bytes verifierContext;
    bytes swapCallbackContext;
    bytes swapFeeModuleContext;
}

struct SwapCache {
    ISwapFeeModule swapFeeModule;
    IERC20 tokenInPool;
    IERC20 tokenOutPool;
    uint256 amountInWithoutFee;
}

struct SovereignPoolSwapParams {
    bool isSwapCallback;
    bool isZeroToOne;
    uint256 amountIn;
    uint256 amountOutMin;
    uint256 deadline;
    address recipient;
    address swapTokenOut;
    SovereignPoolSwapContextData swapContext;
}

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

pragma solidity ^0.8.20;

import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";

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

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

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

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

    /**
     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 oldAllowance = token.allowance(address(this), spender);
        forceApprove(token, spender, oldAllowance + value);
    }

    /**
     * @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
     * value, non-reverting calls are assumed to be successful.
     *
     * IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
     * smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
     * this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
     * that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
     */
    function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
        unchecked {
            uint256 currentAllowance = token.allowance(address(this), spender);
            if (currentAllowance < requestedDecrease) {
                revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
            }
            forceApprove(token, spender, currentAllowance - requestedDecrease);
        }
    }

    /**
     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
     * to be set to zero before setting it to a non-zero value, such as USDT.
     *
     * NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
     * only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
     * set here.
     */
    function forceApprove(IERC20 token, address spender, uint256 value) internal {
        bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));

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

    /**
     * @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            safeTransfer(token, to, value);
        } else if (!token.transferAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
     * has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * Reverts if the returned value is other than `true`.
     */
    function transferFromAndCallRelaxed(
        IERC1363 token,
        address from,
        address to,
        uint256 value,
        bytes memory data
    ) internal {
        if (to.code.length == 0) {
            safeTransferFrom(token, from, to, value);
        } else if (!token.transferFromAndCall(from, to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
     * code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
     * targeting contracts.
     *
     * NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
     * Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
     * once without retrying, and relies on the returned value to be true.
     *
     * Reverts if the returned value is other than `true`.
     */
    function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
        if (to.code.length == 0) {
            forceApprove(token, to, value);
        } else if (!token.approveAndCall(to, value, data)) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
     */
    function _callOptionalReturn(IERC20 token, bytes memory data) private {
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            // bubble errors
            if iszero(success) {
                let ptr := mload(0x40)
                returndatacopy(ptr, 0, returndatasize())
                revert(ptr, returndatasize())
            }
            returnSize := returndatasize()
            returnValue := mload(0)
        }

        if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
            revert SafeERC20FailedOperation(address(token));
        }
    }

    /**
     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
     * on the return value: the return value is optional (but if data is returned, it must not be false).
     * @param token The token targeted by the call.
     * @param data The call data (encoded using abi.encode or one of its variants).
     *
     * This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
     */
    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
        bool success;
        uint256 returnSize;
        uint256 returnValue;
        assembly ("memory-safe") {
            success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
            returnSize := returndatasize()
            returnValue := mload(0)
        }
        return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
    }
}

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

import {LPWithdrawalRequest} from "../structs/WithdrawalModuleStructs.sol";
import {ILendingModule} from "./ILendingModule.sol";

interface IWithdrawalModule {
    function overseer() external view returns (address);

    function lendingModule() external view returns (ILendingModule);

    function stex() external view returns (address);

    function pool() external view returns (address);

    function amountToken0PendingUnstaking() external view returns (uint256);

    function amountToken1LendingPool() external view returns (uint256);

    function amountToken1PendingLPWithdrawal() external view returns (uint256);

    function amountToken1ClaimableLPWithdrawal() external view returns (uint256);

    function cumulativeAmountToken1LPWithdrawal() external view returns (uint256);

    function cumulativeAmountToken1ClaimableLPWithdrawal() external view returns (uint256);

    function isLocked() external view returns (bool);

    function convertToToken0(uint256 _amountToken1) external view returns (uint256);

    function convertToToken1(uint256 _amountToken0) external view returns (uint256);

    function token0SharesToBalance(uint256 _shares) external view returns (uint256);

    function token0BalanceToShares(uint256 _balance) external view returns (uint256);

    function token0SharesOf(address _account) external view returns (uint256);

    function getLPWithdrawals(uint256 _idLPWithdrawal) external view returns (LPWithdrawalRequest memory);

    function unstakeToken0Reserves(uint256 _unstakeAmountToken0) external;

    function burnToken0AfterWithdraw(uint256 _amountToken0, address _recipient) external;

    function supplyToken1ToLendingPool(uint256 _amountToken1) external;

    function withdrawToken1FromLendingPool(uint256 _amountToken1, address _recipient) external;

    function update() external;

    function claim(uint256 _idLPQueue) external;
}

File 9 of 33 : 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 10 of 33 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC165.sol)

pragma solidity ^0.8.20;

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

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

interface IOverseer {
    function burnAndRedeemIfPossible(address to, uint256 amount, string memory communityCode)
        external
        returns (uint256 burnId);

    function redeem(uint256 burnId) external;

    function redeemable(uint256 burnId) external view returns (bool);

    function getBurnIds(address account) external view returns (uint256[] memory);
}

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

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

import { ALMLiquidityQuoteInput, ALMLiquidityQuote } from '../structs/SovereignALMStructs.sol';

/**
    @title Sovereign ALM interface
    @notice All ALMs bound to a Sovereign Pool must implement it.
 */
interface ISovereignALM {
    /** 
        @notice Called by the Sovereign pool to request a liquidity quote from the ALM.
        @param _almLiquidityQuoteInput Contains fundamental data about the swap.
        @param _externalContext Data received by the pool from the user.
        @param _verifierData Verification data received by the pool from the verifier module
        @return almLiquidityQuote Liquidity quote containing tokenIn and tokenOut amounts filled.
    */
    function getLiquidityQuote(
        ALMLiquidityQuoteInput memory _almLiquidityQuoteInput,
        bytes calldata _externalContext,
        bytes calldata _verifierData
    ) external returns (ALMLiquidityQuote memory);

    /**
        @notice Callback function for `depositLiquidity` .
        @param _amount0 Amount of token0 being deposited.
        @param _amount1 Amount of token1 being deposited.
        @param _data Context data passed by the ALM, while calling `depositLiquidity`.
    */
    function onDepositLiquidityCallback(uint256 _amount0, uint256 _amount1, bytes memory _data) external;

    /**
        @notice Callback to ALM after swap into liquidity pool.
        @dev Only callable by pool.
        @param _isZeroToOne Direction of swap.
        @param _amountIn Amount of tokenIn in swap.
        @param _amountOut Amount of tokenOut in swap. 
     */
    function onSwapCallback(bool _isZeroToOne, uint256 _amountIn, uint256 _amountOut) external;
}

// 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.1.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 represent a slot holding a 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 represent 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 represent 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 represent 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 represent 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
pragma solidity ^0.8.19;

import { IValantisPool } from '../interfaces/IValantisPool.sol';
import { PoolLocks } from '../structs/ReentrancyGuardStructs.sol';
import { SovereignPoolSwapContextData, SovereignPoolSwapParams } from '../structs/SovereignPoolStructs.sol';

interface ISovereignPool is IValantisPool {
    event SwapFeeModuleSet(address swapFeeModule);
    event ALMSet(address alm);
    event GaugeSet(address gauge);
    event PoolManagerSet(address poolManager);
    event PoolManagerFeeSet(uint256 poolManagerFeeBips);
    event SovereignOracleSet(address sovereignOracle);
    event PoolManagerFeesClaimed(uint256 amount0, uint256 amount1);
    event DepositLiquidity(uint256 amount0, uint256 amount1);
    event WithdrawLiquidity(address indexed recipient, uint256 amount0, uint256 amount1);
    event Swap(address indexed sender, bool isZeroToOne, uint256 amountIn, uint256 fee, uint256 amountOut);

    function getTokens() external view returns (address[] memory tokens);

    function sovereignVault() external view returns (address);

    function protocolFactory() external view returns (address);

    function gauge() external view returns (address);

    function poolManager() external view returns (address);

    function sovereignOracleModule() external view returns (address);

    function swapFeeModule() external view returns (address);

    function verifierModule() external view returns (address);

    function isLocked() external view returns (bool);

    function isRebaseTokenPool() external view returns (bool);

    function poolManagerFeeBips() external view returns (uint256);

    function defaultSwapFeeBips() external view returns (uint256);

    function swapFeeModuleUpdateTimestamp() external view returns (uint256);

    function alm() external view returns (address);

    function getPoolManagerFees() external view returns (uint256 poolManagerFee0, uint256 poolManagerFee1);

    function getReserves() external view returns (uint256 reserve0, uint256 reserve1);

    function setPoolManager(address _manager) external;

    function setGauge(address _gauge) external;

    function setPoolManagerFeeBips(uint256 _poolManagerFeeBips) external;

    function setSovereignOracle(address sovereignOracle) external;

    function setSwapFeeModule(address _swapFeeModule) external;

    function setALM(address _alm) external;

    function swap(SovereignPoolSwapParams calldata _swapParams) external returns (uint256, uint256);

    function depositLiquidity(
        uint256 _amount0,
        uint256 _amount1,
        address _sender,
        bytes calldata _verificationContext,
        bytes calldata _depositData
    ) external returns (uint256 amount0Deposited, uint256 amount1Deposited);

    function withdrawLiquidity(
        uint256 _amount0,
        uint256 _amount1,
        address _sender,
        address _recipient,
        bytes calldata _verificationContext
    ) external;
}

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

pragma solidity ^0.8.20;

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

/**
 * @title IERC1363
 * @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
 *
 * Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
 * after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
 */
interface IERC1363 is IERC20, IERC165 {
    /*
     * Note: the ERC-165 identifier for this interface is 0xb0202a11.
     * 0xb0202a11 ===
     *   bytes4(keccak256('transferAndCall(address,uint256)')) ^
     *   bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
     *   bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256)')) ^
     *   bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
     */

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from the caller's account to `to`
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
     * and then calls {IERC1363Receiver-onTransferReceived} on `to`.
     * @param from The address which you want to send tokens from.
     * @param to The address which you want to transfer to.
     * @param value The amount of tokens to be transferred.
     * @param data Additional data with no specified format, sent in call to `to`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value) external returns (bool);

    /**
     * @dev Sets a `value` amount of tokens as the allowance of `spender` over the
     * caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
     * @param spender The address which will spend the funds.
     * @param value The amount of tokens to be spent.
     * @param data Additional data with no specified format, sent in call to `spender`.
     * @return A boolean value indicating whether the operation succeeded unless throwing.
     */
    function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}

File 18 of 33 : SovereignALMStructs.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

struct ALMLiquidityQuoteInput {
    bool isZeroToOne;
    uint256 amountInMinusFee;
    uint256 feeInBips;
    address sender;
    address recipient;
    address tokenOutSwap;
}

struct ALMLiquidityQuote {
    bool isCallbackOnSwap;
    uint256 amountOut;
    uint256 amountInFilled;
}

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

import {ISovereignALM} from "@valantis-core/ALM/interfaces/ISovereignALM.sol";
import {ISwapFeeModuleMinimal} from "@valantis-core/swap-fee-modules/interfaces/ISwapFeeModule.sol";

interface ISTEXAMM is ISovereignALM {
    event SwapFeeModuleProposed(address swapFeeModule, uint256 startTimestamp);

    event SwapFeeModuleProposalCancelled();

    event SwapFeeModuleSet(address swapFeeModule);

    event WithdrawalModuleProposed(address withdrawalModule, uint256 startTimestamp);

    event WithdrawalModuleProposalCancelled();

    event WithdrawalModuleSet(address withdrawalModule);

    event PoolManagerFeeSet(uint256 poolManagerFeeBips);

    event PoolManagerFeesClaimed(uint256 fee0, uint256 fee1);

    event Token0ReservesUnstaked(uint256 reserve0);

    event Deposit(address indexed sender, address indexed recipient, uint256 amountToken1, uint256 shares);

    event Withdraw(
        address indexed sender, address indexed recipient, uint256 amountToken0, uint256 amountToken1, uint256 shares
    );

    function isLocked() external view returns (bool);

    function pool() external view returns (address);

    function token0() external view returns (address);

    function token1() external view returns (address);

    function poolFeeRecipient1() external view returns (address);

    function poolFeeRecipient2() external view returns (address);

    function withdrawalModule() external view returns (address);

    function pause() external;

    function unpause() external;

    function proposeSwapFeeModule(address _swapFeeModule, uint256 _timelockDelay) external;

    function cancelSwapFeeModuleProposal() external;

    function setProposedSwapFeeModule() external;

    function proposeWithdrawalModule(address withdrawalModule_) external;

    function cancelWithdrawalModuleProposal() external;

    function setProposedWithdrawalModule() external;

    function setPoolManagerFeeBips(uint256 _poolManagerFeeBips) external;

    function claimPoolManagerFees() external;

    function unstakeToken0Reserves(uint256 _unstakeAmountToken0) external;

    function supplyToken1Reserves(uint256 _amount1) external;

    function getAmountOut(address _tokenIn, uint256 _amountIn, bool _isInstantWithdraw)
        external
        view
        returns (uint256 amountOut);

    function deposit(uint256 _amount, uint256 _minShares, uint256 _deadline, address _recipient)
        external
        returns (uint256 shares);

    function withdraw(
        uint256 _shares,
        uint256 _amount0Min,
        uint256 _amount1Min,
        uint256 _deadline,
        address _recipient,
        bool _unwrapToNativeToken,
        bool _isInstantWithdrawal
    ) external returns (uint256 amount0, uint256 amount1);
}

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

interface ILendingModule {
    function assetBalance() external view returns (uint256);

    function deposit(uint256 amount) external;

    function withdraw(uint256 amount, address recipient) external;
}

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

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

interface IValantisPool {
    /************************************************
     *  EVENTS
     ***********************************************/

    event Flashloan(address indexed initiator, address indexed receiver, uint256 amount, address token);

    /************************************************
     *  ERRORS
     ***********************************************/

    error ValantisPool__flashloan_callbackFailed();
    error ValantisPool__flashLoan_flashLoanDisabled();
    error ValantisPool__flashLoan_flashLoanNotRepaid();
    error ValantisPool__flashLoan_rebaseTokenNotAllowed();

    /************************************************
     *  VIEW FUNCTIONS
     ***********************************************/

    /**
        @notice Address of ERC20 token0 of the pool.
     */
    function token0() external view returns (address);

    /**
        @notice Address of ERC20 token1 of the pool.
     */
    function token1() external view returns (address);

    /************************************************
     *  EXTERNAL FUNCTIONS
     ***********************************************/

    /**
        @notice Claim share of protocol fees accrued by this pool.
        @dev Can only be claimed by `gauge` of the pool. 
     */
    function claimProtocolFees() external returns (uint256, uint256);

    /**
        @notice Claim share of fees accrued by this pool
                And optionally share some with the protocol.
        @dev Only callable by `poolManager`.
        @param _feeProtocol0Bips Percent of `token0` fees to be shared with protocol.
        @param _feeProtocol1Bips Percent of `token1` fees to be shared with protocol.
     */
    function claimPoolManagerFees(
        uint256 _feeProtocol0Bips,
        uint256 _feeProtocol1Bips
    ) external returns (uint256 feePoolManager0Received, uint256 feePoolManager1Received);

    /**
        @notice Sets the gauge contract address for the pool.
        @dev Only callable by `protocolFactory`.
        @dev Once a gauge is set it cannot be changed again.
        @param _gauge address of the gauge.
     */
    function setGauge(address _gauge) external;

    /**
        @notice Allows anyone to flash loan any amount of tokens from the pool.
        @param _isTokenZero True if token0 is being flash loaned, False otherwise.
        @param _receiver Address of the flash loan receiver.
        @param _amount Amount of tokens to be flash loaned.
        @param _data Bytes encoded data for flash loan callback.
     */
    function flashLoan(bool _isTokenZero, IFlashBorrower _receiver, uint256 _amount, bytes calldata _data) external;
}

File 22 of 33 : WithdrawalModuleStructs.sol
// SPDX-License-Identifier: BUSL-1.1
pragma solidity ^0.8.25;

struct LPWithdrawalRequest {
    address recipient;
    uint96 amountToken1;
    uint256 cumulativeAmountToken1LPWithdrawalCheckpoint;
}

struct LendingModuleProposal {
    address lendingModule;
    uint256 startTimestamp;
}

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

pragma solidity ^0.8.20;

import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * The default value of {decimals} is 18. To change this, you should override
 * this function so it returns a different value.
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC-20
 * applications.
 */
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
    mapping(address account => uint256) private _balances;

    mapping(address account => mapping(address spender => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the default value returned by this function, unless
     * it's overridden.
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - the caller must have a balance of at least `value`.
     */
    function transfer(address to, uint256 value) public virtual returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, value);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 value) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, value);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Skips emitting an {Approval} event indicating an allowance update. This is not
     * required by the ERC. See {xref-ERC20-_approve-address-address-uint256-bool-}[_approve].
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `value`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `value`.
     */
    function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, value);
        _transfer(from, to, value);
        return true;
    }

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _transfer(address from, address to, uint256 value) internal {
        if (from == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        if (to == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(from, to, value);
    }

    /**
     * @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
     * (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
     * this function.
     *
     * Emits a {Transfer} event.
     */
    function _update(address from, address to, uint256 value) internal virtual {
        if (from == address(0)) {
            // Overflow check required: The rest of the code assumes that totalSupply never overflows
            _totalSupply += value;
        } else {
            uint256 fromBalance = _balances[from];
            if (fromBalance < value) {
                revert ERC20InsufficientBalance(from, fromBalance, value);
            }
            unchecked {
                // Overflow not possible: value <= fromBalance <= totalSupply.
                _balances[from] = fromBalance - value;
            }
        }

        if (to == address(0)) {
            unchecked {
                // Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
                _totalSupply -= value;
            }
        } else {
            unchecked {
                // Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
                _balances[to] += value;
            }
        }

        emit Transfer(from, to, value);
    }

    /**
     * @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
     * Relies on the `_update` mechanism
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead.
     */
    function _mint(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidReceiver(address(0));
        }
        _update(address(0), account, value);
    }

    /**
     * @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
     * Relies on the `_update` mechanism.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * NOTE: This function is not virtual, {_update} should be overridden instead
     */
    function _burn(address account, uint256 value) internal {
        if (account == address(0)) {
            revert ERC20InvalidSender(address(0));
        }
        _update(account, address(0), value);
    }

    /**
     * @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     *
     * Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
     */
    function _approve(address owner, address spender, uint256 value) internal {
        _approve(owner, spender, value, true);
    }

    /**
     * @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
     *
     * By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
     * `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
     * `Approval` event during `transferFrom` operations.
     *
     * Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
     * true using the following override:
     *
     * ```solidity
     * function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
     *     super._approve(owner, spender, value, true);
     * }
     * ```
     *
     * Requirements are the same as {_approve}.
     */
    function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
        if (owner == address(0)) {
            revert ERC20InvalidApprover(address(0));
        }
        if (spender == address(0)) {
            revert ERC20InvalidSpender(address(0));
        }
        _allowances[owner][spender] = value;
        if (emitEvent) {
            emit Approval(owner, spender, value);
        }
    }

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `value`.
     *
     * Does not update the allowance value in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Does not emit an {Approval} event.
     */
    function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance < type(uint256).max) {
            if (currentAllowance < value) {
                revert ERC20InsufficientAllowance(spender, currentAllowance, value);
            }
            unchecked {
                _approve(owner, spender, currentAllowance - value, false);
            }
        }
    }
}

File 24 of 33 : ReentrancyGuardStructs.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

enum Lock {
    WITHDRAWAL,
    DEPOSIT,
    SWAP,
    SPOT_PRICE_TICK
}

struct PoolLocks {
    /**
        @notice Locks all functions that require any withdrawal of funds from the pool
                This involves the following functions -
                * withdrawLiquidity
                * claimProtocolFees
                * claimPoolManagerFees
     */
    uint8 withdrawals;
    /**
        @notice Only locks the deposit function
    */
    uint8 deposit;
    /**
        @notice Only locks the swap function
    */
    uint8 swap;
    /**
        @notice Only locks the spotPriceTick function
    */
    uint8 spotPriceTick;
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

interface IstHYPE {
    function balanceOf(address who) external view returns (uint256);

    function sharesOf(address who) external view returns (uint256);

    function sharesToBalance(uint256 shares) external view returns (uint256);

    function balanceToShares(uint256 balance) external view returns (uint256);
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.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, _status will be NOT_ENTERED
        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();
    }
}

File 28 of 33 : 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.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;

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

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * The initial owner is set to the address provided by the deployer. This can
 * later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;

/**
 * @dev Standard ERC-20 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-20 tokens.
 */
interface IERC20Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC20InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC20InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     * @param allowance Amount of tokens a `spender` is allowed to operate with.
     * @param needed Minimum amount required to perform a transfer.
     */
    error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC20InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `spender` to be approved. Used in approvals.
     * @param spender Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC20InvalidSpender(address spender);
}

/**
 * @dev Standard ERC-721 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-721 tokens.
 */
interface IERC721Errors {
    /**
     * @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in ERC-20.
     * Used in balance queries.
     * @param owner Address of the current owner of a token.
     */
    error ERC721InvalidOwner(address owner);

    /**
     * @dev Indicates a `tokenId` whose `owner` is the zero address.
     * @param tokenId Identifier number of a token.
     */
    error ERC721NonexistentToken(uint256 tokenId);

    /**
     * @dev Indicates an error related to the ownership over a particular token. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param tokenId Identifier number of a token.
     * @param owner Address of the current owner of a token.
     */
    error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC721InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC721InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param tokenId Identifier number of a token.
     */
    error ERC721InsufficientApproval(address operator, uint256 tokenId);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC721InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC721InvalidOperator(address operator);
}

/**
 * @dev Standard ERC-1155 Errors
 * Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC-1155 tokens.
 */
interface IERC1155Errors {
    /**
     * @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     * @param balance Current balance for the interacting account.
     * @param needed Minimum amount required to perform a transfer.
     * @param tokenId Identifier number of a token.
     */
    error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);

    /**
     * @dev Indicates a failure with the token `sender`. Used in transfers.
     * @param sender Address whose tokens are being transferred.
     */
    error ERC1155InvalidSender(address sender);

    /**
     * @dev Indicates a failure with the token `receiver`. Used in transfers.
     * @param receiver Address to which tokens are being transferred.
     */
    error ERC1155InvalidReceiver(address receiver);

    /**
     * @dev Indicates a failure with the `operator`’s approval. Used in transfers.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     * @param owner Address of the current owner of a token.
     */
    error ERC1155MissingApprovalForAll(address operator, address owner);

    /**
     * @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
     * @param approver Address initiating an approval operation.
     */
    error ERC1155InvalidApprover(address approver);

    /**
     * @dev Indicates a failure with the `operator` to be approved. Used in approvals.
     * @param operator Address that may be allowed to operate on tokens without being their owner.
     */
    error ERC1155InvalidOperator(address operator);

    /**
     * @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
     * Used in batch transfers.
     * @param idsLength Length of the array of token identifiers
     * @param valuesLength Length of the array of token amounts
     */
    error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}

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

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

interface IWETH9 is IERC20 {
    function deposit() external payable;

    function withdraw(uint256) external;
}

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

/**
    @notice Struct returned by the swapFeeModule during the getSwapFeeInBips call.
    * feeInBips: The swap fee in bips.
    * internalContext: Arbitrary bytes context data.
 */
struct SwapFeeModuleData {
    uint256 feeInBips;
    bytes internalContext;
}

interface ISwapFeeModuleMinimal {
    /**
        @notice Returns the swap fee in bips for both Universal & Sovereign Pools.
        @param _tokenIn The address of the token that the user wants to swap.
        @param _tokenOut The address of the token that the user wants to receive.
        @param _amountIn The amount of tokenIn being swapped.
        @param _user The address of the user.
        @param _swapFeeModuleContext Arbitrary bytes data which can be sent to the swap fee module.
        @return swapFeeModuleData A struct containing the swap fee in bips, and internal context data.
     */
    function getSwapFeeInBips(
        address _tokenIn,
        address _tokenOut,
        uint256 _amountIn,
        address _user,
        bytes memory _swapFeeModuleContext
    ) external returns (SwapFeeModuleData memory swapFeeModuleData);
}

interface ISwapFeeModule is ISwapFeeModuleMinimal {
    /**
        @notice Callback function called by the pool after the swap has finished. ( Universal Pools )
        @param _effectiveFee The effective fee charged for the swap.
        @param _spotPriceTick The spot price tick after the swap.
        @param _amountInUsed The amount of tokenIn used for the swap.
        @param _amountOut The amount of the tokenOut transferred to the user.
        @param _swapFeeModuleData The context data returned by getSwapFeeInBips.
     */
    function callbackOnSwapEnd(
        uint256 _effectiveFee,
        int24 _spotPriceTick,
        uint256 _amountInUsed,
        uint256 _amountOut,
        SwapFeeModuleData memory _swapFeeModuleData
    ) external;

    /**
        @notice Callback function called by the pool after the swap has finished. ( Sovereign Pools )
        @param _effectiveFee The effective fee charged for the swap.
        @param _amountInUsed The amount of tokenIn used for the swap.
        @param _amountOut The amount of the tokenOut transferred to the user.
        @param _swapFeeModuleData The context data returned by getSwapFeeInBips.
     */
    function callbackOnSwapEnd(
        uint256 _effectiveFee,
        uint256 _amountInUsed,
        uint256 _amountOut,
        SwapFeeModuleData memory _swapFeeModuleData
    ) external;
}

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

Settings
{
  "evmVersion": "cancun",
  "libraries": {},
  "metadata": {
    "appendCBOR": true,
    "bytecodeHash": "ipfs",
    "useLiteralContent": false
  },
  "optimizer": {
    "enabled": true,
    "runs": 10000
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "remappings": [
    "forge-std/=lib/forge-std/src/",
    "@valantis-core/=lib/valantis-core/src/",
    "@openzeppelin/=lib/openzeppelin-contracts/",
    "@solmate/=lib/solmate/src/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "ds-test/=lib/solmate/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "halmos-cheatcodes/=lib/openzeppelin-contracts/lib/halmos-cheatcodes/src/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "openzeppelin/=lib/valantis-core/lib/openzeppelin-contracts/contracts/",
    "solmate/=lib/solmate/src/",
    "valantis-core/=lib/valantis-core/src/"
  ],
  "viaIR": false
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"address","name":"_overseer","type":"address"},{"internalType":"address","name":"_owner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"FailedCall","type":"error"},{"inputs":[{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","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":[{"internalType":"address","name":"token","type":"address"}],"name":"SafeERC20FailedOperation","type":"error"},{"inputs":[],"name":"stHYPEWithdrawalModule__OnlySTEX","type":"error"},{"inputs":[],"name":"stHYPEWithdrawalModule__OnlySTEXOrOwner","type":"error"},{"inputs":[],"name":"stHYPEWithdrawalModule__PoolNonReentrant","type":"error"},{"inputs":[],"name":"stHYPEWithdrawalModule__ZeroAddress","type":"error"},{"inputs":[],"name":"stHYPEWithdrawalModule___verifyTimelockDelay_timelockTooHigh","type":"error"},{"inputs":[],"name":"stHYPEWithdrawalModule___verifyTimelockDelay_timelockTooLow","type":"error"},{"inputs":[],"name":"stHYPEWithdrawalModule__claim_alreadyClaimed","type":"error"},{"inputs":[],"name":"stHYPEWithdrawalModule__claim_cannotYetClaim","type":"error"},{"inputs":[],"name":"stHYPEWithdrawalModule__claim_insufficientAmountToClaim","type":"error"},{"inputs":[],"name":"stHYPEWithdrawalModule__proposeLendingModule_ProposalAlreadyActive","type":"error"},{"inputs":[],"name":"stHYPEWithdrawalModule__setProposedLendingModule_InactiveProposal","type":"error"},{"inputs":[],"name":"stHYPEWithdrawalModule__setProposedLendingModule_ProposalNotActive","type":"error"},{"inputs":[],"name":"stHYPEWithdrawalModule__setSTEX_AlreadySet","type":"error"},{"inputs":[],"name":"stHYPEWithdrawalModule__withdrawToken1FromLendingPool_insufficientAmountWithdrawn","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AmountSuppliedToLendingModule","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AmountWithdrawnFromLendingModule","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"}],"name":"LPWithdrawalRequestClaimed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amountToken1","type":"uint256"},{"indexed":false,"internalType":"address","name":"recipient","type":"address"}],"name":"LPWithdrawalRequestCreated","type":"event"},{"anonymous":false,"inputs":[],"name":"LendingModuleProposalCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"lendingModule","type":"address"},{"indexed":false,"internalType":"uint256","name":"startTimestamp","type":"uint256"}],"name":"LendingModuleProposed","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"lendingModule","type":"address"}],"name":"LendingModuleSet","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"stex","type":"address"}],"name":"STEXSet","type":"event"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"LPWithdrawals","outputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint96","name":"amountToken1","type":"uint96"},{"internalType":"uint256","name":"cumulativeAmountToken1LPWithdrawalCheckpoint","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"_amountToken1PendingLPWithdrawal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"amountToken0PendingUnstaking","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"amountToken1ClaimableLPWithdrawal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"amountToken1LendingPool","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"amountToken1PendingLPWithdrawal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amountToken0","type":"uint256"},{"internalType":"address","name":"_recipient","type":"address"}],"name":"burnToken0AfterWithdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"cancelLendingModuleProposal","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_idLPQueue","type":"uint256"}],"name":"claim","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amountToken1","type":"uint256"}],"name":"convertToToken0","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amountToken0","type":"uint256"}],"name":"convertToToken1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"cumulativeAmountToken1ClaimableLPWithdrawal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"cumulativeAmountToken1LPWithdrawal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_idLPWithdrawal","type":"uint256"}],"name":"getLPWithdrawals","outputs":[{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint96","name":"amountToken1","type":"uint96"},{"internalType":"uint256","name":"cumulativeAmountToken1LPWithdrawalCheckpoint","type":"uint256"}],"internalType":"struct LPWithdrawalRequest","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"idLPWithdrawal","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"isLocked","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lendingModule","outputs":[{"internalType":"contract ILendingModule","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lendingModuleProposal","outputs":[{"internalType":"address","name":"lendingModule","type":"address"},{"internalType":"uint256","name":"startTimestamp","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"overseer","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_lendingModule","type":"address"},{"internalType":"uint256","name":"_timelockDelay","type":"uint256"}],"name":"proposeLendingModule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"setProposedLendingModule","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_stex","type":"address"}],"name":"setSTEX","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stex","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amountToken1","type":"uint256"}],"name":"supplyToken1ToLendingPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_balance","type":"uint256"}],"name":"token0BalanceToShares","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_account","type":"address"}],"name":"token0SharesOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_shares","type":"uint256"}],"name":"token0SharesToBalance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_unstakeAmountToken0","type":"uint256"}],"name":"unstakeToken0Reserves","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"update","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amountToken1","type":"uint256"},{"internalType":"address","name":"_recipient","type":"address"}],"name":"withdrawToken1FromLendingPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60a060405234801561000f575f80fd5b5060405161276d38038061276d83398101604081905261002e9161011d565b806001600160a01b03811661005c57604051631e4fbdf760e01b81525f600482015260240160405180910390fd5b610065816100b3565b506001600160a01b038216158061008357506001600160a01b038116155b156100a1576040516350ea1c4160e01b815260040160405180910390fd5b506001600160a01b031660805261014e565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b0381168114610118575f80fd5b919050565b5f806040838503121561012e575f80fd5b61013783610102565b915061014560208401610102565b90509250929050565b6080516125f96101745f395f818161037f01528181610cb30152610d1a01526125f95ff3fe608060405260043610610212575f3560e01c80638da5cb5b11610117578063ce59f65d116100ac578063ea949a1c1161007c578063fb1b5db811610062578063fb1b5db81461067b578063fc02abec14610711578063feb3a26314610725575f80fd5b8063ea949a1c146103ea578063f2fde38b1461065c575f80fd5b8063ce59f65d146105f5578063d71cb1561461060a578063d73b52f91461061e578063e66bdfef1461063d575f80fd5b8063a628320c116100e7578063a628320c146104da578063b2d21856146105a2578063cb79520c146105b7578063cc9b8d95146105d6575f80fd5b80638da5cb5b14610459578063a2e6204514610475578063a2fd923614610489578063a4e2d6341461049d575f80fd5b80634083902e116101a75780636086d7ac1161017757806367cd08861161015d57806367cd0886146104075780637044dda714610426578063715018a614610445575f80fd5b80636086d7ac146103d557806364697b99146103ea575f80fd5b80634083902e1461035a5780634ba256561461036e5780635249b96d146103a15780635ae962f7146103c0575f80fd5b8063362a21cb116101e2578063362a21cb146102ad578063371ba7f9146102da578063379607f5146102f95780633fb7d3a514610318575f80fd5b80630a1100dc1461021d5780630b6a05581461023e5780630e41ee951461025257806316f0115b14610271575f80fd5b3661021957005b5f80fd5b348015610228575f80fd5b5061023c61023736600461245e565b61073a565b005b348015610249575f80fd5b5061023c61083f565b34801561025d575f80fd5b5061023c61026c366004612488565b61089d565b34801561027c575f80fd5b50600254610290906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156102b8575f80fd5b506102cc6102c73660046124b6565b610a0e565b6040519081526020016102a4565b3480156102e5575f80fd5b5061023c6102f43660046124b6565b610b22565b348015610304575f80fd5b5061023c6103133660046124b6565b610d9b565b348015610323575f80fd5b5060085460095461033b916001600160a01b03169082565b604080516001600160a01b0390931683526020830191909152016102a4565b348015610365575f80fd5b506102cc610f80565b348015610379575f80fd5b506102907f000000000000000000000000000000000000000000000000000000000000000081565b3480156103ac575f80fd5b50600154610290906001600160a01b031681565b3480156103cb575f80fd5b506102cc60055481565b3480156103e0575f80fd5b506102cc600c5481565b3480156103f5575f80fd5b506102cc6104043660046124b6565b90565b348015610412575f80fd5b5061023c6104213660046124b6565b611011565b348015610431575f80fd5b50600a54610290906001600160a01b031681565b348015610450575f80fd5b5061023c6111e0565b348015610464575f80fd5b505f546001600160a01b0316610290565b348015610480575f80fd5b5061023c6111f3565b348015610494575f80fd5b506102cc611480565b3480156104a8575f80fd5b506040517f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005c151581526020016102a4565b3480156104e5575f80fd5b506105696104f43660046124b6565b60408051606080820183525f808352602080840182905292840181905293845260078252928290208251938401835280546001600160a01b03811685527401000000000000000000000000000000000000000090046bffffffffffffffffffffffff1691840191909152600101549082015290565b6040805182516001600160a01b031681526020808401516bffffffffffffffffffffffff169082015291810151908201526060016102a4565b3480156105ad575f80fd5b506102cc60035481565b3480156105c2575f80fd5b5061023c6105d1366004612488565b6114b1565b3480156105e1575f80fd5b506102cc6105f03660046124cd565b61187d565b348015610600575f80fd5b506102cc60065481565b348015610615575f80fd5b5061023c611950565b348015610629575f80fd5b506102cc6106383660046124b6565b611c0e565b348015610648575f80fd5b5061023c6106573660046124cd565b611cdf565b348015610667575f80fd5b5061023c6106763660046124cd565b611e82565b348015610686575f80fd5b506106df6106953660046124b6565b60076020525f9081526040902080546001909101546001600160a01b038216917401000000000000000000000000000000000000000090046bffffffffffffffffffffffff169083565b604080516001600160a01b0390941684526bffffffffffffffffffffffff9092166020840152908201526060016102a4565b34801561071c575f80fd5b506102cc611eda565b348015610730575f80fd5b506102cc60045481565b610742611efc565b61074b81611f41565b60095415610785576040517fe914ed7700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040518060400160405280836001600160a01b0316815260200182426107ab9190612515565b90528051600880547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03909216919091179055602001516009557fd5dfcb0690d3d1f5628e92464ec861ac739ef80bab96b104ccc04d32883929d2826108198342612515565b604080516001600160a01b03909316835260208301919091520160405180910390a15050565b610847611efc565b6040517fa3761e1b7d07b15f6472ec7d734cdc86653fdb7ab5c9a4c27b89a21b4947857d905f90a1600880547fffffffffffffffffffffffff00000000000000000000000000000000000000001690555f600955565b6001546001600160a01b031633146108e1576040517f1f6a39b900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108e9611fbb565b5f82905080600c5f8282546108fe9190612515565b909155505060065460408051918252602082018390526001600160a01b03841682820152517fd1d2c783c624cac61c24ae22ea83a48cca9ac333c6a51c9b0d9604f59d801e489181900360600190a16040518060600160405280836001600160a01b0316815260200161097083612041565b6bffffffffffffffffffffffff9081168252600454602092830152600680545f90815260078452604080822086519587015190941674010000000000000000000000000000000000000000026001600160a01b0390951694909417835593909201516001909101558054916109e483612528565b91905055508060045f8282546109fa9190612515565b9250508190555050610a0a612096565b5050565b600154604080517f0dfe168100000000000000000000000000000000000000000000000000000000815290515f926001600160a01b03169183918391630dfe16819160048083019260209291908290030181865afa158015610a72573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a96919061255f565b6040517fd8ddf18f000000000000000000000000000000000000000000000000000000008152600481018690529091506001600160a01b0382169063d8ddf18f906024015b602060405180830381865afa158015610af6573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b1a919061257a565b949350505050565b610b2a611fbb565b610b32611efc565b6001546040517f371ba7f9000000000000000000000000000000000000000000000000000000008152600481018390526001600160a01b0390911690819063371ba7f9906024015f604051808303815f87803b158015610b90575f80fd5b505af1158015610ba2573d5f803e3d5ffd5b505050505f816001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015610be3573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c07919061255f565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529091505f906001600160a01b038316906370a0823190602401602060405180830381865afa158015610c67573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c8b919061257a565b905080600b5f828254610c9e9190612515565b90915550610cd890506001600160a01b0383167f0000000000000000000000000000000000000000000000000000000000000000836120c0565b6040517fe2a5f56900000000000000000000000000000000000000000000000000000000815230600482015260248101829052606060448201525f60648201527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063e2a5f569906084016020604051808303815f875af1158015610d68573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d8c919061257a565b50505050610d98612096565b50565b610da3611fbb565b5f818152600760209081526040808320815160608101835281546001600160a01b03811682527401000000000000000000000000000000000000000090046bffffffffffffffffffffffff16938101849052600190910154918101919091529103610e3a576040517fd0c91a5600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80602001516bffffffffffffffffffffffff166003541015610e88576040517f032b9aa800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80602001516bffffffffffffffffffffffff168160400151610eaa9190612515565b6005541015610ee5576040517f88773ec100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80602001516bffffffffffffffffffffffff1660035f828254610f089190612591565b90915550506040518281527f5168ef923a26f7481cc88aa6aeea168d1e1ca15e394c0c9691619c82fdecf9149060200160405180910390a15f828152600760209081526040822082815560010191909155815190820151610f7791906bffffffffffffffffffffffff166121c6565b50610d98612096565b600a545f906001600160a01b03161561100c57600a5f9054906101000a90046001600160a01b03166001600160a01b031663c66f24556040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fe3573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611007919061257a565b905090565b505f90565b611019611efc565b611021611fbb565b600a546001600160a01b0316156111d85780156111d8576001546040517ffc760cca000000000000000000000000000000000000000000000000000000008152600481018390526001600160a01b0390911690819063fc760cca906024015f604051808303815f87803b158015611096575f80fd5b505af11580156110a8573d5f803e3d5ffd5b505050505f816001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156110e9573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061110d919061255f565b600a5490915061112a906001600160a01b038084169116856120c0565b600a546040517fb6b55f25000000000000000000000000000000000000000000000000000000008152600481018590526001600160a01b039091169063b6b55f25906024015f604051808303815f87803b158015611186575f80fd5b505af1158015611198573d5f803e3d5ffd5b505050507f27db4d3a00a377e928f10e16b0f8f2281070bf94a4a42a9f9177c451ac413a03836040516111cd91815260200190565b60405180910390a150505b610d98612096565b6111e8611efc565b6111f15f61226b565b565b6111fb611fbb565b60025f9054906101000a90046001600160a01b03166001600160a01b031663a4e2d6346040518163ffffffff1660e01b8152600401602060405180830381865afa15801561124b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061126f91906125a4565b156112a6576040517f60cda84c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6112af6122d2565b9050805f036112be5750611478565b600b54818111156112db576112d38282612591565b600b556112e0565b5f600b555b600c548083111561132e576112f58184612591565b92508060035f8282546113089190612515565b925050819055508060055f8282546113209190612515565b90915550505f600c5561137d565b82600c5f82825461133f9190612591565b925050819055508260035f8282546113579190612515565b925050819055508260055f82825461136f9190612515565b909155506114789350505050565b600154604080517fd21220a700000000000000000000000000000000000000000000000000000000815290515f926001600160a01b03169163d21220a79160048083019260209291908290030181865afa1580156113dd573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611401919061255f565b90505f819050806001600160a01b031663d0e30db0866040518263ffffffff1660e01b81526004015f604051808303818588803b158015611440575f80fd5b505af1158015611452573d5f803e3d5ffd5b505060025461147293506001600160a01b038581169350169050876122fb565b50505050505b6111f1612096565b5f8061148a6122d2565b600c54909150818111156114a9576114a28282612591565b9250505090565b5f9250505090565b6001546001600160a01b031633148015906114d657505f546001600160a01b03163314155b1561150d576040517f57d047fb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611515611fbb565b60025f9054906101000a90046001600160a01b03166001600160a01b031663a4e2d6346040518163ffffffff1660e01b8152600401602060405180830381865afa158015611565573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061158991906125a4565b156115c0576040517f60cda84c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600a546001600160a01b031615611875578115611875576001545f906001600160a01b031633146115fc576002546001600160a01b03166115fe565b815b90505f60015f9054906101000a90046001600160a01b03166001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611651573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611675919061255f565b6040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b0384811660048301529192505f918316906370a0823190602401602060405180830381865afa1580156116d7573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906116fb919061257a565b600a546040517ef714ce000000000000000000000000000000000000000000000000000000008152600481018890526001600160a01b03868116602483015292935091169062f714ce906044015f604051808303815f87803b15801561175f575f80fd5b505af1158015611771573d5f803e3d5ffd5b50506040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b0386811660048301525f9350851691506370a0823190602401602060405180830381865afa1580156117d4573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117f8919061257a565b9050856118058383612591565b101561183d576040517f47b79b4400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040518681527ff10b515d698b054051a65f6465ca03d722b7c71723c33372f5b4723b425911619060200160405180910390a1505050505b610a0a612096565b600154604080517f0dfe168100000000000000000000000000000000000000000000000000000000815290515f926001600160a01b03169183918391630dfe16819160048083019260209291908290030181865afa1580156118e1573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611905919061255f565b6040517ff5eb42dc0000000000000000000000000000000000000000000000000000000081526001600160a01b0386811660048301529192509082169063f5eb42dc90602401610adb565b611958611efc565b60025f9054906101000a90046001600160a01b03166001600160a01b031663a4e2d6346040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119a8573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906119cc91906125a4565b15611a03576040517f60cda84c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600954421015611a3f576040517fad6374b200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6009545f03611a7a576040517f7d3155f800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600a546001600160a01b031615611b9457600a54604080517fc66f245500000000000000000000000000000000000000000000000000000000815290515f926001600160a01b03169163c66f24559160048083019260209291908290030181865afa158015611aeb573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611b0f919061257a565b90508015611b9257600a546002546040517ef714ce000000000000000000000000000000000000000000000000000000008152600481018490526001600160a01b03918216602482015291169062f714ce906044015f604051808303815f87803b158015611b7b575f80fd5b505af1158015611b8d573d5f803e3d5ffd5b505050505b505b60088054600a80546001600160a01b0383167fffffffffffffffffffffffff000000000000000000000000000000000000000091821681179092559091169091555f6009556040519081527f7203a83a94f3f6031d8ba216195cb3a5984634df59ce6457512d2211c88b95e29060200160405180910390a1565b600154604080517f0dfe168100000000000000000000000000000000000000000000000000000000815290515f926001600160a01b03169183918391630dfe16819160048083019260209291908290030181865afa158015611c72573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611c96919061255f565b6040517f53735f37000000000000000000000000000000000000000000000000000000008152600481018690529091506001600160a01b038216906353735f3790602401610adb565b611ce7611efc565b6001600160a01b038116611d27576040517f50ea1c4100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001546001600160a01b031615611d6a576040517f971eba1d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038316908117909155604080517f16f0115b00000000000000000000000000000000000000000000000000000000815290516316f0115b916004808201926020929091908290030181865afa158015611df2573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611e16919061255f565b600280547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392831617905560405190821681527f1800999767e413aff1424b2ef4640c197542e07fa0ae4fb1b3392750e49e32489060200160405180910390a150565b611e8a611efc565b6001600160a01b038116611ed1576040517f1e4fbdf70000000000000000000000000000000000000000000000000000000081525f60048201526024015b60405180910390fd5b610d988161226b565b5f80611ee46122d2565b600b54909150818111156114a9576114a28282612591565b5f546001600160a01b031633146111f1576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401611ec8565b6203f480811015611f7e576040517f37d08e5300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62093a80811115610d98576040517fea9ea48300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005c15612014576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6111f160017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005b90612331565b5f6bffffffffffffffffffffffff821115612092576040517f6dfcc6500000000000000000000000000000000000000000000000000000000081526060600482015260248101839052604401611ec8565b5090565b6111f15f7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0061203b565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b30000000000000000000000000000000000000000000000000000000017905261213f8482612338565b6121c0576040516001600160a01b0384811660248301525f60448301526121b691869182169063095ea7b3906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050612383565b6121c08482612383565b50505050565b80471015612209576040517fcf47918100000000000000000000000000000000000000000000000000000000815247600482015260248101829052604401611ec8565b5f80836001600160a01b0316836040515f6040518083038185875af1925050503d805f8114612253576040519150601f19603f3d011682016040523d82523d5f602084013e612258565b606091505b5091509150816121c0576121c081612408565b5f80546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b5f804790505f60035482116122e7575f6122f4565b6003546122f49083612591565b9392505050565b6040516001600160a01b0383811660248301526044820183905261232c91859182169063a9059cbb9060640161216f565b505050565b80825d5050565b5f805f8060205f8651602088015f8a5af192503d91505f519050828015612377575081156123695780600114612377565b5f866001600160a01b03163b115b93505050505b92915050565b5f8060205f8451602086015f885af1806123a2576040513d5f823e3d81fd5b50505f513d915081156123b95780600114156123c6565b6001600160a01b0384163b155b156121c0576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401611ec8565b8051156124185780518082602001fd5b6040517fd6bda27500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0381168114610d98575f80fd5b5f806040838503121561246f575f80fd5b823561247a8161244a565b946020939093013593505050565b5f8060408385031215612499575f80fd5b8235915060208301356124ab8161244a565b809150509250929050565b5f602082840312156124c6575f80fd5b5035919050565b5f602082840312156124dd575f80fd5b81356122f48161244a565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b8082018082111561237d5761237d6124e8565b5f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612558576125586124e8565b5060010190565b5f6020828403121561256f575f80fd5b81516122f48161244a565b5f6020828403121561258a575f80fd5b5051919050565b8181038181111561237d5761237d6124e8565b5f602082840312156125b4575f80fd5b815180151581146122f4575f80fdfea2646970667358221220f1e8d33b3035a5c75e300e56af97000484ab76491ad12b80f1a954c52db778b964736f6c63430008190033000000000000000000000000b96f07367e69e86d6e9c3f29215885104813eeae000000000000000000000000388e360edaac94372df1a2663ffe52671bbd8b58

Deployed Bytecode

0x608060405260043610610212575f3560e01c80638da5cb5b11610117578063ce59f65d116100ac578063ea949a1c1161007c578063fb1b5db811610062578063fb1b5db81461067b578063fc02abec14610711578063feb3a26314610725575f80fd5b8063ea949a1c146103ea578063f2fde38b1461065c575f80fd5b8063ce59f65d146105f5578063d71cb1561461060a578063d73b52f91461061e578063e66bdfef1461063d575f80fd5b8063a628320c116100e7578063a628320c146104da578063b2d21856146105a2578063cb79520c146105b7578063cc9b8d95146105d6575f80fd5b80638da5cb5b14610459578063a2e6204514610475578063a2fd923614610489578063a4e2d6341461049d575f80fd5b80634083902e116101a75780636086d7ac1161017757806367cd08861161015d57806367cd0886146104075780637044dda714610426578063715018a614610445575f80fd5b80636086d7ac146103d557806364697b99146103ea575f80fd5b80634083902e1461035a5780634ba256561461036e5780635249b96d146103a15780635ae962f7146103c0575f80fd5b8063362a21cb116101e2578063362a21cb146102ad578063371ba7f9146102da578063379607f5146102f95780633fb7d3a514610318575f80fd5b80630a1100dc1461021d5780630b6a05581461023e5780630e41ee951461025257806316f0115b14610271575f80fd5b3661021957005b5f80fd5b348015610228575f80fd5b5061023c61023736600461245e565b61073a565b005b348015610249575f80fd5b5061023c61083f565b34801561025d575f80fd5b5061023c61026c366004612488565b61089d565b34801561027c575f80fd5b50600254610290906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156102b8575f80fd5b506102cc6102c73660046124b6565b610a0e565b6040519081526020016102a4565b3480156102e5575f80fd5b5061023c6102f43660046124b6565b610b22565b348015610304575f80fd5b5061023c6103133660046124b6565b610d9b565b348015610323575f80fd5b5060085460095461033b916001600160a01b03169082565b604080516001600160a01b0390931683526020830191909152016102a4565b348015610365575f80fd5b506102cc610f80565b348015610379575f80fd5b506102907f000000000000000000000000b96f07367e69e86d6e9c3f29215885104813eeae81565b3480156103ac575f80fd5b50600154610290906001600160a01b031681565b3480156103cb575f80fd5b506102cc60055481565b3480156103e0575f80fd5b506102cc600c5481565b3480156103f5575f80fd5b506102cc6104043660046124b6565b90565b348015610412575f80fd5b5061023c6104213660046124b6565b611011565b348015610431575f80fd5b50600a54610290906001600160a01b031681565b348015610450575f80fd5b5061023c6111e0565b348015610464575f80fd5b505f546001600160a01b0316610290565b348015610480575f80fd5b5061023c6111f3565b348015610494575f80fd5b506102cc611480565b3480156104a8575f80fd5b506040517f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005c151581526020016102a4565b3480156104e5575f80fd5b506105696104f43660046124b6565b60408051606080820183525f808352602080840182905292840181905293845260078252928290208251938401835280546001600160a01b03811685527401000000000000000000000000000000000000000090046bffffffffffffffffffffffff1691840191909152600101549082015290565b6040805182516001600160a01b031681526020808401516bffffffffffffffffffffffff169082015291810151908201526060016102a4565b3480156105ad575f80fd5b506102cc60035481565b3480156105c2575f80fd5b5061023c6105d1366004612488565b6114b1565b3480156105e1575f80fd5b506102cc6105f03660046124cd565b61187d565b348015610600575f80fd5b506102cc60065481565b348015610615575f80fd5b5061023c611950565b348015610629575f80fd5b506102cc6106383660046124b6565b611c0e565b348015610648575f80fd5b5061023c6106573660046124cd565b611cdf565b348015610667575f80fd5b5061023c6106763660046124cd565b611e82565b348015610686575f80fd5b506106df6106953660046124b6565b60076020525f9081526040902080546001909101546001600160a01b038216917401000000000000000000000000000000000000000090046bffffffffffffffffffffffff169083565b604080516001600160a01b0390941684526bffffffffffffffffffffffff9092166020840152908201526060016102a4565b34801561071c575f80fd5b506102cc611eda565b348015610730575f80fd5b506102cc60045481565b610742611efc565b61074b81611f41565b60095415610785576040517fe914ed7700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040518060400160405280836001600160a01b0316815260200182426107ab9190612515565b90528051600880547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b03909216919091179055602001516009557fd5dfcb0690d3d1f5628e92464ec861ac739ef80bab96b104ccc04d32883929d2826108198342612515565b604080516001600160a01b03909316835260208301919091520160405180910390a15050565b610847611efc565b6040517fa3761e1b7d07b15f6472ec7d734cdc86653fdb7ab5c9a4c27b89a21b4947857d905f90a1600880547fffffffffffffffffffffffff00000000000000000000000000000000000000001690555f600955565b6001546001600160a01b031633146108e1576040517f1f6a39b900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6108e9611fbb565b5f82905080600c5f8282546108fe9190612515565b909155505060065460408051918252602082018390526001600160a01b03841682820152517fd1d2c783c624cac61c24ae22ea83a48cca9ac333c6a51c9b0d9604f59d801e489181900360600190a16040518060600160405280836001600160a01b0316815260200161097083612041565b6bffffffffffffffffffffffff9081168252600454602092830152600680545f90815260078452604080822086519587015190941674010000000000000000000000000000000000000000026001600160a01b0390951694909417835593909201516001909101558054916109e483612528565b91905055508060045f8282546109fa9190612515565b9250508190555050610a0a612096565b5050565b600154604080517f0dfe168100000000000000000000000000000000000000000000000000000000815290515f926001600160a01b03169183918391630dfe16819160048083019260209291908290030181865afa158015610a72573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610a96919061255f565b6040517fd8ddf18f000000000000000000000000000000000000000000000000000000008152600481018690529091506001600160a01b0382169063d8ddf18f906024015b602060405180830381865afa158015610af6573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610b1a919061257a565b949350505050565b610b2a611fbb565b610b32611efc565b6001546040517f371ba7f9000000000000000000000000000000000000000000000000000000008152600481018390526001600160a01b0390911690819063371ba7f9906024015f604051808303815f87803b158015610b90575f80fd5b505af1158015610ba2573d5f803e3d5ffd5b505050505f816001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015610be3573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c07919061255f565b6040517f70a082310000000000000000000000000000000000000000000000000000000081523060048201529091505f906001600160a01b038316906370a0823190602401602060405180830381865afa158015610c67573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610c8b919061257a565b905080600b5f828254610c9e9190612515565b90915550610cd890506001600160a01b0383167f000000000000000000000000b96f07367e69e86d6e9c3f29215885104813eeae836120c0565b6040517fe2a5f56900000000000000000000000000000000000000000000000000000000815230600482015260248101829052606060448201525f60648201527f000000000000000000000000b96f07367e69e86d6e9c3f29215885104813eeae6001600160a01b03169063e2a5f569906084016020604051808303815f875af1158015610d68573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610d8c919061257a565b50505050610d98612096565b50565b610da3611fbb565b5f818152600760209081526040808320815160608101835281546001600160a01b03811682527401000000000000000000000000000000000000000090046bffffffffffffffffffffffff16938101849052600190910154918101919091529103610e3a576040517fd0c91a5600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80602001516bffffffffffffffffffffffff166003541015610e88576040517f032b9aa800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80602001516bffffffffffffffffffffffff168160400151610eaa9190612515565b6005541015610ee5576040517f88773ec100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b80602001516bffffffffffffffffffffffff1660035f828254610f089190612591565b90915550506040518281527f5168ef923a26f7481cc88aa6aeea168d1e1ca15e394c0c9691619c82fdecf9149060200160405180910390a15f828152600760209081526040822082815560010191909155815190820151610f7791906bffffffffffffffffffffffff166121c6565b50610d98612096565b600a545f906001600160a01b03161561100c57600a5f9054906101000a90046001600160a01b03166001600160a01b031663c66f24556040518163ffffffff1660e01b8152600401602060405180830381865afa158015610fe3573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611007919061257a565b905090565b505f90565b611019611efc565b611021611fbb565b600a546001600160a01b0316156111d85780156111d8576001546040517ffc760cca000000000000000000000000000000000000000000000000000000008152600481018390526001600160a01b0390911690819063fc760cca906024015f604051808303815f87803b158015611096575f80fd5b505af11580156110a8573d5f803e3d5ffd5b505050505f816001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa1580156110e9573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061110d919061255f565b600a5490915061112a906001600160a01b038084169116856120c0565b600a546040517fb6b55f25000000000000000000000000000000000000000000000000000000008152600481018590526001600160a01b039091169063b6b55f25906024015f604051808303815f87803b158015611186575f80fd5b505af1158015611198573d5f803e3d5ffd5b505050507f27db4d3a00a377e928f10e16b0f8f2281070bf94a4a42a9f9177c451ac413a03836040516111cd91815260200190565b60405180910390a150505b610d98612096565b6111e8611efc565b6111f15f61226b565b565b6111fb611fbb565b60025f9054906101000a90046001600160a01b03166001600160a01b031663a4e2d6346040518163ffffffff1660e01b8152600401602060405180830381865afa15801561124b573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061126f91906125a4565b156112a6576040517f60cda84c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f6112af6122d2565b9050805f036112be5750611478565b600b54818111156112db576112d38282612591565b600b556112e0565b5f600b555b600c548083111561132e576112f58184612591565b92508060035f8282546113089190612515565b925050819055508060055f8282546113209190612515565b90915550505f600c5561137d565b82600c5f82825461133f9190612591565b925050819055508260035f8282546113579190612515565b925050819055508260055f82825461136f9190612515565b909155506114789350505050565b600154604080517fd21220a700000000000000000000000000000000000000000000000000000000815290515f926001600160a01b03169163d21220a79160048083019260209291908290030181865afa1580156113dd573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611401919061255f565b90505f819050806001600160a01b031663d0e30db0866040518263ffffffff1660e01b81526004015f604051808303818588803b158015611440575f80fd5b505af1158015611452573d5f803e3d5ffd5b505060025461147293506001600160a01b038581169350169050876122fb565b50505050505b6111f1612096565b5f8061148a6122d2565b600c54909150818111156114a9576114a28282612591565b9250505090565b5f9250505090565b6001546001600160a01b031633148015906114d657505f546001600160a01b03163314155b1561150d576040517f57d047fb00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611515611fbb565b60025f9054906101000a90046001600160a01b03166001600160a01b031663a4e2d6346040518163ffffffff1660e01b8152600401602060405180830381865afa158015611565573d5f803e3d5ffd5b505050506040513d601f19601f8201168201806040525081019061158991906125a4565b156115c0576040517f60cda84c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600a546001600160a01b031615611875578115611875576001545f906001600160a01b031633146115fc576002546001600160a01b03166115fe565b815b90505f60015f9054906101000a90046001600160a01b03166001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015611651573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611675919061255f565b6040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b0384811660048301529192505f918316906370a0823190602401602060405180830381865afa1580156116d7573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906116fb919061257a565b600a546040517ef714ce000000000000000000000000000000000000000000000000000000008152600481018890526001600160a01b03868116602483015292935091169062f714ce906044015f604051808303815f87803b15801561175f575f80fd5b505af1158015611771573d5f803e3d5ffd5b50506040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b0386811660048301525f9350851691506370a0823190602401602060405180830381865afa1580156117d4573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906117f8919061257a565b9050856118058383612591565b101561183d576040517f47b79b4400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6040518681527ff10b515d698b054051a65f6465ca03d722b7c71723c33372f5b4723b425911619060200160405180910390a1505050505b610a0a612096565b600154604080517f0dfe168100000000000000000000000000000000000000000000000000000000815290515f926001600160a01b03169183918391630dfe16819160048083019260209291908290030181865afa1580156118e1573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611905919061255f565b6040517ff5eb42dc0000000000000000000000000000000000000000000000000000000081526001600160a01b0386811660048301529192509082169063f5eb42dc90602401610adb565b611958611efc565b60025f9054906101000a90046001600160a01b03166001600160a01b031663a4e2d6346040518163ffffffff1660e01b8152600401602060405180830381865afa1580156119a8573d5f803e3d5ffd5b505050506040513d601f19601f820116820180604052508101906119cc91906125a4565b15611a03576040517f60cda84c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600954421015611a3f576040517fad6374b200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6009545f03611a7a576040517f7d3155f800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600a546001600160a01b031615611b9457600a54604080517fc66f245500000000000000000000000000000000000000000000000000000000815290515f926001600160a01b03169163c66f24559160048083019260209291908290030181865afa158015611aeb573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611b0f919061257a565b90508015611b9257600a546002546040517ef714ce000000000000000000000000000000000000000000000000000000008152600481018490526001600160a01b03918216602482015291169062f714ce906044015f604051808303815f87803b158015611b7b575f80fd5b505af1158015611b8d573d5f803e3d5ffd5b505050505b505b60088054600a80546001600160a01b0383167fffffffffffffffffffffffff000000000000000000000000000000000000000091821681179092559091169091555f6009556040519081527f7203a83a94f3f6031d8ba216195cb3a5984634df59ce6457512d2211c88b95e29060200160405180910390a1565b600154604080517f0dfe168100000000000000000000000000000000000000000000000000000000815290515f926001600160a01b03169183918391630dfe16819160048083019260209291908290030181865afa158015611c72573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611c96919061255f565b6040517f53735f37000000000000000000000000000000000000000000000000000000008152600481018690529091506001600160a01b038216906353735f3790602401610adb565b611ce7611efc565b6001600160a01b038116611d27576040517f50ea1c4100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001546001600160a01b031615611d6a576040517f971eba1d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600180547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b038316908117909155604080517f16f0115b00000000000000000000000000000000000000000000000000000000815290516316f0115b916004808201926020929091908290030181865afa158015611df2573d5f803e3d5ffd5b505050506040513d601f19601f82011682018060405250810190611e16919061255f565b600280547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392831617905560405190821681527f1800999767e413aff1424b2ef4640c197542e07fa0ae4fb1b3392750e49e32489060200160405180910390a150565b611e8a611efc565b6001600160a01b038116611ed1576040517f1e4fbdf70000000000000000000000000000000000000000000000000000000081525f60048201526024015b60405180910390fd5b610d988161226b565b5f80611ee46122d2565b600b54909150818111156114a9576114a28282612591565b5f546001600160a01b031633146111f1576040517f118cdaa7000000000000000000000000000000000000000000000000000000008152336004820152602401611ec8565b6203f480811015611f7e576040517f37d08e5300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b62093a80811115610d98576040517fea9ea48300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005c15612014576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6111f160017f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f005b90612331565b5f6bffffffffffffffffffffffff821115612092576040517f6dfcc6500000000000000000000000000000000000000000000000000000000081526060600482015260248101839052604401611ec8565b5090565b6111f15f7f9b779b17422d0df92223018b32b4d1fa46e071723d6817e2486d003becc55f0061203b565b604080516001600160a01b038416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b30000000000000000000000000000000000000000000000000000000017905261213f8482612338565b6121c0576040516001600160a01b0384811660248301525f60448301526121b691869182169063095ea7b3906064015b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050612383565b6121c08482612383565b50505050565b80471015612209576040517fcf47918100000000000000000000000000000000000000000000000000000000815247600482015260248101829052604401611ec8565b5f80836001600160a01b0316836040515f6040518083038185875af1925050503d805f8114612253576040519150601f19603f3d011682016040523d82523d5f602084013e612258565b606091505b5091509150816121c0576121c081612408565b5f80546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b5f804790505f60035482116122e7575f6122f4565b6003546122f49083612591565b9392505050565b6040516001600160a01b0383811660248301526044820183905261232c91859182169063a9059cbb9060640161216f565b505050565b80825d5050565b5f805f8060205f8651602088015f8a5af192503d91505f519050828015612377575081156123695780600114612377565b5f866001600160a01b03163b115b93505050505b92915050565b5f8060205f8451602086015f885af1806123a2576040513d5f823e3d81fd5b50505f513d915081156123b95780600114156123c6565b6001600160a01b0384163b155b156121c0576040517f5274afe70000000000000000000000000000000000000000000000000000000081526001600160a01b0385166004820152602401611ec8565b8051156124185780518082602001fd5b6040517fd6bda27500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6001600160a01b0381168114610d98575f80fd5b5f806040838503121561246f575f80fd5b823561247a8161244a565b946020939093013593505050565b5f8060408385031215612499575f80fd5b8235915060208301356124ab8161244a565b809150509250929050565b5f602082840312156124c6575f80fd5b5035919050565b5f602082840312156124dd575f80fd5b81356122f48161244a565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b8082018082111561237d5761237d6124e8565b5f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203612558576125586124e8565b5060010190565b5f6020828403121561256f575f80fd5b81516122f48161244a565b5f6020828403121561258a575f80fd5b5051919050565b8181038181111561237d5761237d6124e8565b5f602082840312156125b4575f80fd5b815180151581146122f4575f80fdfea2646970667358221220f1e8d33b3035a5c75e300e56af97000484ab76491ad12b80f1a954c52db778b964736f6c63430008190033

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

000000000000000000000000b96f07367e69e86d6e9c3f29215885104813eeae000000000000000000000000388e360edaac94372df1a2663ffe52671bbd8b58

-----Decoded View---------------
Arg [0] : _overseer (address): 0xB96f07367e69e86d6e9C3F29215885104813eeAE
Arg [1] : _owner (address): 0x388E360eDaaC94372df1a2663FFe52671bbd8B58

-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000b96f07367e69e86d6e9c3f29215885104813eeae
Arg [1] : 000000000000000000000000388e360edaac94372df1a2663ffe52671bbd8b58


Block Transaction Gas Used Reward
view all blocks ##produced##

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

Validator Index Block Amount
View All Withdrawals

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