false
true
0

Contract Address Details

0xF43Bc20062D0e32739f15b66B6E1927aE01092cD

Contract Name
Vault
Creator
0x4876c8–ac0965 at 0x7d862b–869237
Balance
0.000000000000000006 tPLS
Tokens
Fetching tokens...
Transactions
Fetching transactions...
Transfers
Fetching transfers...
Gas Used
Fetching gas used...
Last Balance Update
26069883
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
Vault




Optimization enabled
false
Compiler version
v0.8.26+commit.8a97fa7a




EVM Version




Verified at
2026-09-28T15:48:47.162062Z

Constructor Arguments


              

src/Vault.sol

// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright (C) 2024 PancakeSwap
pragma solidity 0.8.26;

import {Ownable, Ownable2Step} from "@openzeppelin/contracts/access/Ownable2Step.sol";
import {IVault, IVaultToken} from "./interfaces/IVault.sol";
import {SettlementGuard} from "./libraries/SettlementGuard.sol";
import {Currency, CurrencyLibrary} from "./types/Currency.sol";
import {BalanceDelta} from "./types/BalanceDelta.sol";
import {ILockCallback} from "./interfaces/ILockCallback.sol";
import {SafeCast} from "./libraries/SafeCast.sol";
import {AppDeficit} from "./libraries/AppDeficit.sol";
import {VaultReserve} from "./libraries/VaultReserve.sol";
import {VaultToken} from "./VaultToken.sol";

contract Vault is IVault, VaultToken, Ownable2Step {
    using SafeCast for *;
    using CurrencyLibrary for Currency;

    constructor() Ownable(msg.sender) {}

    mapping(address app => bool isRegistered) public override isAppRegistered;

    /// @dev keep track of each app's reserves
    mapping(address app => mapping(Currency currency => uint256 reserve)) public reservesOfApp;

    /// @notice only registered app is allowed to perform accounting
    modifier onlyRegisteredApp() {
        if (!isAppRegistered[msg.sender]) revert AppUnregistered();

        _;
    }

    /// @notice revert if no locker is set
    modifier isLocked() {
        if (SettlementGuard.getLocker() == address(0)) revert NoLocker();
        _;
    }

    /// @inheritdoc IVault
    function registerApp(address app) external override onlyOwner {
        isAppRegistered[app] = true;

        emit AppRegistered(app);
    }

    /// @inheritdoc IVault
    function getLocker() external view override returns (address) {
        return SettlementGuard.getLocker();
    }

    /// @inheritdoc IVault
    function getUnsettledDeltasCount() external view override returns (uint256) {
        return SettlementGuard.getUnsettledDeltasCount();
    }

    /// @inheritdoc IVault
    function currencyDelta(address settler, Currency currency) external view override returns (int256) {
        return SettlementGuard.getCurrencyDelta(settler, currency);
    }

    /// @inheritdoc IVault
    function getAppDeficitCount() external view override returns (uint256) {
        return AppDeficit.count();
    }

    /// @inheritdoc IVault
    function appCurrencyDeficit(address app, Currency currency) external view override returns (uint256) {
        return AppDeficit.getDeficit(app, currency);
    }

    /// @dev interaction must start from lock
    /// @inheritdoc IVault
    function lock(bytes calldata data) external override returns (bytes memory result) {
        /// @dev only one locker at a time
        SettlementGuard.setLocker(msg.sender);
        /// @dev Shanghai: transient storage would have wiped a `sync` made in an EARLIER transaction; normal storage
        /// does not, so forget any recorded reserve here. `settle` is lock-only, so no stale reserve can ever be
        /// read by it (a `sync` must now happen inside the lock that settles it).
        VaultReserve.setVaultReserve(CurrencyLibrary.NATIVE, 0);

        result = ILockCallback(msg.sender).lockAcquired(data);
        /// @notice the caller can do anything in this callback as long as all deltas are offset after this
        if (SettlementGuard.getUnsettledDeltasCount() != 0) revert CurrencyNotSettled();
        /// @notice any mid-lock borrow against an app's reserves must be fully repaid by now
        if (AppDeficit.count() != 0) revert AppCurrencyNotFullyRepaid();

        /// @dev release the lock
        SettlementGuard.setLocker(address(0));
    }

    /// @inheritdoc IVault
    function accountAppBalanceDelta(
        Currency currency0,
        Currency currency1,
        BalanceDelta delta,
        address settler,
        BalanceDelta hookDelta,
        address hook
    ) external override isLocked onlyRegisteredApp {
        (int128 delta0, int128 delta1) = (delta.amount0(), delta.amount1());
        (int128 hookDelta0, int128 hookDelta1) = (hookDelta.amount0(), hookDelta.amount1());

        /// @dev call _accountDeltaForApp once with both delta/hookDelta to save gas and prevent
        /// reservesOfApp from underflow when it deduct before addition
        _accountDeltaForApp(currency0, delta0 + hookDelta0);
        _accountDeltaForApp(currency1, delta1 + hookDelta1);

        // keep track of the balance on vault level
        SettlementGuard.accountDelta(settler, currency0, delta0);
        SettlementGuard.accountDelta(settler, currency1, delta1);
        SettlementGuard.accountDelta(hook, currency0, hookDelta0);
        SettlementGuard.accountDelta(hook, currency1, hookDelta1);
    }

    /// @inheritdoc IVault
    function accountAppBalanceDelta(Currency currency0, Currency currency1, BalanceDelta delta, address settler)
        external
        override
        isLocked
        onlyRegisteredApp
    {
        int128 delta0 = delta.amount0();
        int128 delta1 = delta.amount1();

        // keep track of the balance on app level
        _accountDeltaForApp(currency0, delta0);
        _accountDeltaForApp(currency1, delta1);

        // keep track of the balance on vault level
        SettlementGuard.accountDelta(settler, currency0, delta0);
        SettlementGuard.accountDelta(settler, currency1, delta1);
    }

    /// @inheritdoc IVault
    function accountAppBalanceDelta(Currency currency, int128 delta, address settler)
        external
        override
        isLocked
        onlyRegisteredApp
    {
        _accountDeltaForApp(currency, delta);
        SettlementGuard.accountDelta(settler, currency, delta);
    }

    /// @inheritdoc IVault
    function take(Currency currency, address to, uint256 amount) external override isLocked {
        unchecked {
            SettlementGuard.accountDelta(msg.sender, currency, -(amount.toInt128()));
            currency.transfer(to, amount);
        }
    }

    /// @inheritdoc IVault
    function mint(address to, Currency currency, uint256 amount) external override isLocked {
        unchecked {
            SettlementGuard.accountDelta(msg.sender, currency, -(amount.toInt128()));
            _mint(to, currency, amount);
        }
    }

    function sync(Currency currency) public override {
        if (currency.isNative()) {
            VaultReserve.setVaultReserve(CurrencyLibrary.NATIVE, 0);
        } else {
            uint256 balance = currency.balanceOfSelf();
            VaultReserve.setVaultReserve(currency, balance);
        }
    }

    /// @inheritdoc IVault
    function settle() external payable override isLocked returns (uint256) {
        return _settle(msg.sender);
    }

    /// @inheritdoc IVault
    function settleFor(address recipient) external payable override isLocked returns (uint256) {
        return _settle(recipient);
    }

    /// @inheritdoc IVault
    function clear(Currency currency, uint256 amount) external isLocked {
        int256 existingDelta = SettlementGuard.getCurrencyDelta(msg.sender, currency);
        int128 amountDelta = amount.toInt128();
        /// @dev since amount is uint256, existingDelta must be positive otherwise revert
        if (amountDelta != existingDelta) revert MustClearExactPositiveDelta();
        unchecked {
            SettlementGuard.accountDelta(msg.sender, currency, -amountDelta);
        }
    }

    /// @inheritdoc IVault
    function burn(address from, Currency currency, uint256 amount) external override isLocked {
        SettlementGuard.accountDelta(msg.sender, currency, amount.toInt128());
        _burnFrom(from, currency, amount);
    }

    /// @inheritdoc IVault
    function collectFee(Currency currency, uint256 amount, address recipient) external onlyRegisteredApp {
        // prevent transfer between the sync and settle balanceOfs (native settle uses msg.value)
        (Currency syncedCurrency,) = VaultReserve.getVaultReserve();
        if (!currency.isNative() && syncedCurrency == currency) revert FeeCurrencySynced();
        reservesOfApp[msg.sender][currency] -= amount;
        currency.transfer(recipient, amount);
    }

    /// @inheritdoc IVault
    function getVaultReserve() external view returns (Currency, uint256) {
        return VaultReserve.getVaultReserve();
    }

    function _accountDeltaForApp(Currency currency, int128 delta) internal {
        if (delta == 0) return;

        /// @dev optimization: msg.sender will always be app address, verification should be done on caller address
        if (delta >= 0) {
            /// @dev "trader can't withdraw too much from app" is enforced at the end of the lock:
            /// mid-lock the reserve may be transiently overdrawn (e.g. a hook re-enters the app in a
            /// callback before the outer operation's delta is booked). The shortfall is floored here
            /// and recorded as a transient deficit that must be repaid before the lock is released.
            uint256 reserve = reservesOfApp[msg.sender][currency];
            uint256 amount = uint128(delta);
            unchecked {
                if (reserve >= amount) {
                    reservesOfApp[msg.sender][currency] = reserve - amount;
                } else {
                    reservesOfApp[msg.sender][currency] = 0;
                    AppDeficit.add(msg.sender, currency, amount - reserve);
                }
            }
        } else {
            /// @dev repay any outstanding deficit first; while a deficit exists the storage reserve is 0
            uint256 remaining = AppDeficit.repay(msg.sender, currency, uint128(-delta));
            if (remaining != 0) {
                /// @dev arithmetic overflow make sure trader won't deposit too much into app
                reservesOfApp[msg.sender][currency] += remaining;
            }
        }
    }

    // if settling native, integrators should still call `sync` first to avoid DoS attack vectors
    function _settle(address recipient) internal returns (uint256 paid) {
        (Currency currency, uint256 reservesBefore) = VaultReserve.getVaultReserve();
        if (!currency.isNative()) {
            if (msg.value > 0) revert SettleNonNativeCurrencyWithValue();
            uint256 reservesNow = currency.balanceOfSelf();
            paid = reservesNow - reservesBefore;

            /// @dev reset the reserve after settled
            VaultReserve.setVaultReserve(CurrencyLibrary.NATIVE, 0);
        } else {
            // NATIVE token does not require sync call before settle
            paid = msg.value;
        }

        SettlementGuard.accountDelta(recipient, currency, paid.toInt128());
    }
}
        

src/interfaces/IHooks.sol

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

interface IHooks {
    function getHooksRegistrationBitmap() external view returns (uint16);
}
          

src/libraries/SettlementGuard.sol

// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright (C) 2024 PancakeSwap
pragma solidity ^0.8.24;

import {Currency} from "../types/Currency.sol";
import {ShanghaiTransient as T} from "./ShanghaiTransient.sol";
import {IVault} from "../interfaces/IVault.sol";

/// @notice This is a workaround when transient keyword is absent. It manages:
///  - 0: address locker
///  - 1: uint256 unsettledDeltasCount
///  - 2: mapping(address, mapping(Currency => int256)) currencyDelta
library SettlementGuard {
    /// @dev uint256 internal constant LOCKER_SLOT = uint256(keccak256("SETTLEMENT_LOCKER")) - 1;
    uint256 internal constant LOCKER_SLOT = 0xedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d70;

    /// @dev uint256 internal constant UNSETTLED_DELTAS_COUNT = uint256(keccak256("SETTLEMENT_UNSETTLEMENTD_DELTAS_COUNT")) - 1;
    uint256 internal constant UNSETTLED_DELTAS_COUNT =
        0xa88ffc6a483ae852b901fb1c3a0df606e2e4461b493434e6643ebdc3ffabd151;

    /// @dev uint256 internal constant CURRENCY_DELTA = uint256(keccak256("SETTLEMENT_CURRENCY_DELTA")) - 1;
    uint256 internal constant CURRENCY_DELTA = 0x6dc13502b9ba2a9e8e42c53a1856d632b29d5aab3bcb4a2476bfec06cbd9cf22;

    /// Shanghai gas: the locker (bits 0..159) and the unsettled-deltas count (bits 160..254) share LOCKER_SLOT, so a
    /// lock touches one emulated slot instead of two. The count lives in its own masked 95-bit field: arithmetic on it
    /// can never carry into the locker bits or into the emulation's marker bit 255. UNSETTLED_DELTAS_COUNT is unused.
    uint256 private constant ADDR_MASK = (uint256(1) << 160) - 1;
    uint256 private constant COUNT_MASK = (uint256(1) << 95) - 1;

    /// @notice Update the locker address stored in the transient store
    /// @param newLocker The new locker address
    function setLocker(address newLocker) internal {
        address currentLocker = getLocker();

        // either set from non-zero to zero (set) or from zero to non-zero (reset)
        if (currentLocker != address(0) && newLocker != address(0)) revert IVault.LockerAlreadySet(currentLocker);

        uint256 w = T.load(LOCKER_SLOT);
        T.store(LOCKER_SLOT, (w & ~ADDR_MASK) | uint256(uint160(newLocker)));
    }

    /// @notice Get the locker address stored in the transient store
    /// @return locker The locker address
    function getLocker() internal view returns (address locker) {
        locker = address(uint160(T.load(LOCKER_SLOT)));
    }

    /// @notice Get the count of non-zero (unsettled) deltas stored in the transient store
    /// @return count The count of non-zero deltas
    function getUnsettledDeltasCount() internal view returns (uint256 count) {
        count = (T.load(LOCKER_SLOT) >> 160) & COUNT_MASK;
    }

    /// @notice Create or update the delta record for a settler and currency
    /// if a new record is added then increment the count of non-zero deltas
    /// if an existing record is updated to zero then decrement the count of non-zero deltas
    /// @param settler The address of who is responsible for the settlement
    /// @param currency The currency of the settlement
    /// @param newlyAddedDelta The delta to be added to the existing delta
    function accountDelta(address settler, Currency currency, int256 newlyAddedDelta) internal {
        if (newlyAddedDelta == 0) return;

        /// @dev update the count of non-zero deltas if necessary
        int256 currentDelta = getCurrencyDelta(settler, currency);
        int256 nextDelta = currentDelta + newlyAddedDelta;
        unchecked {
            if (nextDelta == 0) {
                uint256 w = T.load(LOCKER_SLOT);
                T.store(LOCKER_SLOT, (w & ADDR_MASK) | ((((w >> 160) - 1) & COUNT_MASK) << 160));
            } else if (currentDelta == 0) {
                uint256 w = T.load(LOCKER_SLOT);
                T.store(LOCKER_SLOT, (w & ADDR_MASK) | ((((w >> 160) + 1) & COUNT_MASK) << 160));
            }
        }

        /// @dev ref: https://docs.soliditylang.org/en/v0.8.24/internals/layout_in_storage.html#mappings-and-dynamic-arrays
        /// simulating mapping index but with a single hash
        /// save one keccak256 hash compared to built-in nested mapping
        uint256 elementSlot = uint256(keccak256(abi.encode(settler, currency, CURRENCY_DELTA)));
        T.store(elementSlot, uint256(nextDelta));
    }

    /// @notice Get the current delta record for a given settler and currency
    /// @param settler The address of who is responsible for the settlement
    /// @param currency The currency of the settlement
    /// @return delta The delta value
    function getCurrencyDelta(address settler, Currency currency) internal view returns (int256 delta) {
        uint256 elementSlot = uint256(keccak256(abi.encode(settler, currency, CURRENCY_DELTA)));
        delta = int256(T.load(elementSlot));
    }
}
          

src/libraries/SafeCast.sol

// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright (C) 2024 PancakeSwap
pragma solidity ^0.8.0;

/// @title Safe casting methods
/// @notice Contains methods for safely casting between types
library SafeCast {
    error SafeCastOverflow();

    function _revertOverflow() private pure {
        assembly ("memory-safe") {
            // Store the function selector of `SafeCastOverflow()`.
            mstore(0x00, 0x93dafdf1)
            // Revert with (offset, size).
            revert(0x1c, 0x04)
        }
    }

    /// @notice Cast a uint256 to a uint160, revert on overflow
    /// @param x The uint256 to be downcasted
    /// @return y The downcasted integer, now type uint160
    function toUint160(uint256 x) internal pure returns (uint160 y) {
        y = uint160(x);
        if (y != x) _revertOverflow();
    }

    /// @notice Cast a int256 to a int128, revert on overflow or underflow
    /// @param x The int256 to be downcasted
    /// @return y The downcasted integer, now type int128
    function toInt128(int256 x) internal pure returns (int128 y) {
        y = int128(x);
        if (y != x) _revertOverflow();
    }

    /// @notice Cast a uint256 to a int256, revert on overflow
    /// @param x The uint256 to be casted
    /// @return y The casted integer, now type int256
    function toInt256(uint256 x) internal pure returns (int256 y) {
        y = int256(x);
        if (y < 0) _revertOverflow();
    }

    /// @notice Cast a int256 to a uint256, revert on overflow
    /// @param x The int256 to be casted
    /// @return y The casted integer, now type uint256
    function toUint256(int256 x) internal pure returns (uint256 y) {
        if (x < 0) _revertOverflow();
        y = uint256(x);
    }

    /// @notice Cast a uint256 to a int128, revert on overflow
    /// @param x The uint256 to be downcasted
    /// @return The downcasted integer, now type int128
    function toInt128(uint256 x) internal pure returns (int128) {
        if (x >= 1 << 127) _revertOverflow();
        return int128(int256(x));
    }
}
          

src/types/Currency.sol

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

import {IERC20Minimal} from "../interfaces/IERC20Minimal.sol";
import {CustomRevert} from "../libraries/CustomRevert.sol";

type Currency is address;

using {greaterThan as >, lessThan as <, greaterThanOrEqualTo as >=, equals as ==} for Currency global;
using CurrencyLibrary for Currency global;

function equals(Currency currency, Currency other) pure returns (bool) {
    return Currency.unwrap(currency) == Currency.unwrap(other);
}

function greaterThan(Currency currency, Currency other) pure returns (bool) {
    return Currency.unwrap(currency) > Currency.unwrap(other);
}

function lessThan(Currency currency, Currency other) pure returns (bool) {
    return Currency.unwrap(currency) < Currency.unwrap(other);
}

function greaterThanOrEqualTo(Currency currency, Currency other) pure returns (bool) {
    return Currency.unwrap(currency) >= Currency.unwrap(other);
}

/// @title CurrencyLibrary
/// @dev This library allows for transferring and holding native tokens and ERC20 tokens
library CurrencyLibrary {
    using CurrencyLibrary for Currency;

    /// @notice Additional context for ERC-7751 wrapped error when a native transfer fails
    error NativeTransferFailed();

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

    /// @notice A constant to represent the native currency
    Currency public constant NATIVE = Currency.wrap(address(0));

    function transfer(Currency currency, address to, uint256 amount) internal {
        // altered from https://github.com/transmissions11/solmate/blob/44a9963d4c78111f77caa0e65d677b8b46d6f2e6/src/utils/SafeTransferLib.sol
        // modified custom error selectors

        bool success;
        if (currency.isNative()) {
            assembly ("memory-safe") {
                // Transfer the ETH and revert if it fails.
                success := call(gas(), to, amount, 0, 0, 0, 0)
            }
            // revert with NativeTransferFailed, containing the bubbled up error as an argument
            if (!success) CustomRevert.bubbleUpAndRevertWith(to, bytes4(0), NativeTransferFailed.selector);
        } else {
            assembly ("memory-safe") {
                // Get a pointer to some free memory.
                let fmp := mload(0x40)

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

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

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

    function balanceOfSelf(Currency currency) internal view returns (uint256) {
        if (currency.isNative()) {
            return address(this).balance;
        } else {
            return IERC20Minimal(Currency.unwrap(currency)).balanceOf(address(this));
        }
    }

    function balanceOf(Currency currency, address owner) internal view returns (uint256) {
        if (currency.isNative()) {
            return owner.balance;
        } else {
            return IERC20Minimal(Currency.unwrap(currency)).balanceOf(owner);
        }
    }

    function isNative(Currency currency) internal pure returns (bool) {
        return Currency.unwrap(currency) == Currency.unwrap(NATIVE);
    }

    function toId(Currency currency) internal pure returns (uint256) {
        return uint160(Currency.unwrap(currency));
    }

    function fromId(uint256 id) internal pure returns (Currency) {
        return Currency.wrap(address(uint160(id)));
    }
}
          

src/interfaces/IERC20Minimal.sol

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

/// @title Minimal ERC20 interface for PancakeSwap
/// @notice Contains a subset of the full ERC20 interface that is used in PancakeSwap V3
interface IERC20Minimal {
    /// @notice Returns the balance of a token
    /// @param account The account for which to look up the number of tokens it has, i.e. its balance
    /// @return The number of tokens held by the account
    function balanceOf(address account) external view returns (uint256);

    /// @notice Transfers the amount of token from the `msg.sender` to the recipient
    /// @param recipient The account that will receive the amount transferred
    /// @param amount The number of tokens to send from the sender to the recipient
    /// @return Returns true for a successful transfer, false for an unsuccessful transfer
    function transfer(address recipient, uint256 amount) external returns (bool);

    /// @notice Returns the current allowance given to a spender by an owner
    /// @param owner The account of the token owner
    /// @param spender The account of the token spender
    /// @return The current allowance granted by `owner` to `spender`
    function allowance(address owner, address spender) external view returns (uint256);

    /// @notice Sets the allowance of a spender from the `msg.sender` to the value `amount`
    /// @param spender The account which will be allowed to spend a given amount of the owners tokens
    /// @param amount The amount of tokens allowed to be used by `spender`
    /// @return Returns true for a successful approval, false for unsuccessful
    function approve(address spender, uint256 amount) external returns (bool);

    /// @notice Transfers `amount` tokens from `sender` to `recipient` up to the allowance given to the `msg.sender`
    /// @param sender The account from which the transfer will be initiated
    /// @param recipient The recipient of the transfer
    /// @param amount The amount of the transfer
    /// @return Returns true for a successful transfer, false for unsuccessful
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

    /// @notice Event emitted when tokens are transferred from one address to another, either via `#transfer` or `#transferFrom`.
    /// @param from The account from which the tokens were sent, i.e. the balance decreased
    /// @param to The account to which the tokens were sent, i.e. the balance increased
    /// @param value The amount of tokens that were transferred
    event Transfer(address indexed from, address indexed to, uint256 value);

    /// @notice Event emitted when the approval amount for the spender of a given owner's tokens changes.
    /// @param owner The account that approved spending of its tokens
    /// @param spender The account for which the spending allowance was modified
    /// @param value The new allowance from the owner to the spender
    event Approval(address indexed owner, address indexed spender, uint256 value);
}
          

src/libraries/AppDeficit.sol

// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright (C) 2024 PancakeSwap
pragma solidity ^0.8.24;

import {Currency} from "../types/Currency.sol";
import {ShanghaiTransient as T} from "./ShanghaiTransient.sol";

/// @notice Transient accounting for per-app reserve deficits within a lock.
/// A deficit is created when an app's `reservesOfApp` would underflow mid-lock
/// (e.g. a hook re-enters the app during a callback before the outer operation's
/// delta is booked). The deficit must be fully repaid before the lock ends. It manages:
///  - 0: uint256 deficitCount (number of non-zero (app, currency) deficits)
///  - 1: mapping(address app => mapping(Currency currency => uint256 deficit))
library AppDeficit {
    /// @dev uint256 internal constant DEFICIT_COUNT_SLOT = uint256(keccak256("APP_DEFICIT_COUNT")) - 1;
    uint256 internal constant DEFICIT_COUNT_SLOT = 0x8441ca20eb4e3f4809b32435cc73fbff7fb24d1abccd9553e242325f6e57cdb9;

    /// @dev uint256 internal constant DEFICIT_SLOT = uint256(keccak256("APP_DEFICIT")) - 1;
    uint256 internal constant DEFICIT_SLOT = 0xb15a985351e7fec20c5ab24bbbbeccb6443ba2a83f05cd1411825d064d91cf43;

    /// @notice Get the count of (app, currency) pairs with a non-zero deficit
    /// @return c The count of non-zero deficits
    function count() internal view returns (uint256 c) {
        c = T.load(DEFICIT_COUNT_SLOT);
    }

    /// @notice Get the current deficit for a given app and currency
    /// @param app The app whose reserves are in deficit
    /// @param currency The currency of the deficit
    /// @return deficit The deficit amount
    function getDeficit(address app, Currency currency) internal view returns (uint256 deficit) {
        uint256 elementSlot = uint256(keccak256(abi.encode(app, currency, DEFICIT_SLOT)));
        deficit = T.load(elementSlot);
    }

    /// @notice Record an additional deficit for an app and currency
    /// if the deficit goes from zero to non-zero then increment the count of non-zero deficits
    /// @param app The app whose reserves are in deficit
    /// @param currency The currency of the deficit
    /// @param amount The deficit to be added to the existing deficit
    function add(address app, Currency currency, uint256 amount) internal {
        if (amount == 0) return;

        uint256 elementSlot = uint256(keccak256(abi.encode(app, currency, DEFICIT_SLOT)));
        uint256 current = T.load(elementSlot);
        if (current == 0) {
            unchecked {
                T.store(DEFICIT_COUNT_SLOT, T.load(DEFICIT_COUNT_SLOT) + 1);
            }
        }
        /// @dev checked addition: an app's aggregated deficit must never wrap
        uint256 next = current + amount;
        T.store(elementSlot, next);
    }

    /// @notice Repay an app's deficit with `amount`, returning whatever is left over
    /// if the deficit goes from non-zero to zero then decrement the count of non-zero deficits
    /// @dev fast path: when no deficit exists anywhere, a single tload and `amount` is returned untouched
    /// @param app The app whose deficit is being repaid
    /// @param currency The currency of the deficit
    /// @param amount The amount available for repayment
    /// @return remaining The portion of `amount` left after the deficit is repaid
    function repay(address app, Currency currency, uint256 amount) internal returns (uint256 remaining) {
        if (count() == 0) return amount;

        uint256 elementSlot = uint256(keccak256(abi.encode(app, currency, DEFICIT_SLOT)));
        uint256 current = T.load(elementSlot);
        if (current == 0) return amount;

        unchecked {
            if (amount >= current) {
                remaining = amount - current;
                T.store(elementSlot, 0);
                T.store(DEFICIT_COUNT_SLOT, T.load(DEFICIT_COUNT_SLOT) - 1);
            } else {
                // remaining stays 0, deficit partially repaid
                uint256 next = current - amount;
                T.store(elementSlot, next);
            }
        }
    }
}
          

src/libraries/VaultReserve.sol

// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright (C) 2024 PancakeSwap
pragma solidity ^0.8.24;

import {Currency} from "../types/Currency.sol";
import {ShanghaiTransient as T} from "./ShanghaiTransient.sol";

/// @notice This is a workaround when transient keyword is absent.
/// It records a single reserve for a currency each time, this is helpful for
/// calculating how many tokens has been transferred to the vault right after the sync
library VaultReserve {
    // uint256 constant RESERVE_TYPE_SLOT = uint256(keccak256("reserveType")) - 1;
    uint256 internal constant RESERVE_TYPE_SLOT = 0x52a1be34b47478d7c75e2b6c3eea1e05dcb8dbb8c6a42c6482d0dca0df53cb27;

    // uint256 constant RESERVE_AMOUNT_SLOT = uint256(keccak256("reserveAmount")) - 1;
    uint256 internal constant RESERVE_AMOUNT_SLOT = 0xb0879d96d58bcff08d1fd45590200072d5a8c380da0b5aa1052b48b84e115207;

    /// @notice Transient store the currency reserve
    /// @param currency The currency to be saved
    /// @param amount The amount of the currency to be saved
    function setVaultReserve(Currency currency, uint256 amount) internal {
        // record <currency, amount> in never-zero storage (ShanghaiTransient)
        T.store(RESERVE_TYPE_SLOT, uint256(uint160(Currency.unwrap(currency))));
        T.store(RESERVE_AMOUNT_SLOT, amount);
    }

    /// @notice Transient load the currency reserve
    /// @return currency The currency that was most recently saved
    /// @return amount The amount of the currency that was most recently saved
    function getVaultReserve() internal view returns (Currency currency, uint256 amount) {
        currency = Currency.wrap(address(uint160(T.load(RESERVE_TYPE_SLOT))));
        amount = T.load(RESERVE_AMOUNT_SLOT);
    }
}
          

src/interfaces/IPoolManager.sol

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

import {IHooks} from "./IHooks.sol";
import {PoolKey} from "../types/PoolKey.sol";
import {PoolId} from "../types/PoolId.sol";
import {Currency} from "../types/Currency.sol";

interface IPoolManager {
    /// @notice Thrown when trying to interact with a non-initialized pool
    error PoolNotInitialized();

    /// @notice PoolKey must have currencies where address(currency0) < address(currency1)
    error CurrenciesInitializedOutOfOrder(address currency0, address currency1);

    /// @notice Thrown when a call to updateDynamicLPFee is made by an address that is not the hook,
    /// or on a pool is not a dynamic fee pool.
    error UnauthorizedDynamicLPFeeUpdate();

    /// @notice Emitted when lp fee is updated
    /// @dev The event is emitted even if the updated fee value is the same as previous one
    event DynamicLPFeeUpdated(PoolId indexed id, uint24 dynamicLPFee);

    /// @notice Updates lp fee for a dyanmic fee pool
    /// @dev Some of the use case could be:
    ///   1) when hook#beforeSwap() is called and hook call this function to update the lp fee
    ///   2) For BinPool only, when hook#beforeMint() is called and hook call this function to update the lp fee
    ///   3) other use case where the hook might want to on an ad-hoc basis increase/reduce lp fee
    function updateDynamicLPFee(PoolKey memory key, uint24 newDynamicLPFee) external;

    /// @notice Return PoolKey for a given PoolId
    function poolIdToPoolKey(PoolId id)
        external
        view
        returns (
            Currency currency0,
            Currency currency1,
            IHooks hooks,
            IPoolManager poolManager,
            uint24 fee,
            bytes32 parameters
        );
}
          

src/types/PoolKey.sol

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

import {Currency} from "./Currency.sol";
import {IPoolManager} from "../interfaces/IPoolManager.sol";
import {IHooks} from "../interfaces/IHooks.sol";
import {PoolIdLibrary} from "./PoolId.sol";

using PoolIdLibrary for PoolKey global;

/// @notice Returns the key for identifying a pool
struct PoolKey {
    /// @notice The lower currency of the pool, sorted numerically
    Currency currency0;
    /// @notice The higher currency of the pool, sorted numerically
    Currency currency1;
    /// @notice The hooks of the pool, won't have a general interface because hooks interface vary on pool type
    IHooks hooks;
    /// @notice The pool manager of the pool
    IPoolManager poolManager;
    /// @notice The pool lp fee, capped at 1_000_000. If the pool has a dynamic fee then it must be exactly equal to 0x800000
    uint24 fee;
    /// @notice Hooks callback and pool specific parameters, i.e. tickSpacing for CL, binStep for bin
    bytes32 parameters;
}
          

lib/openzeppelin-contracts/contracts/access/Ownable2Step.sol

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

pragma solidity ^0.8.20;

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

/**
 * @dev Contract module which provides access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * This extension of the {Ownable} contract includes a two-step mechanism to transfer
 * ownership, where the new owner must call {acceptOwnership} in order to replace the
 * old one. This can help prevent common mistakes, such as transfers of ownership to
 * incorrect accounts, or to contracts that are unable to interact with the
 * permission system.
 *
 * The initial owner is specified at deployment time in the constructor for `Ownable`. This
 * can later be changed with {transferOwnership} and {acceptOwnership}.
 *
 * This module is used through inheritance. It will make available all functions
 * from parent (Ownable).
 */
abstract contract Ownable2Step is Ownable {
    address private _pendingOwner;

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

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

    /**
     * @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual override onlyOwner {
        _pendingOwner = newOwner;
        emit OwnershipTransferStarted(owner(), newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual override {
        delete _pendingOwner;
        super._transferOwnership(newOwner);
    }

    /**
     * @dev The new owner accepts the ownership transfer.
     */
    function acceptOwnership() public virtual {
        address sender = _msgSender();
        if (pendingOwner() != sender) {
            revert OwnableUnauthorizedAccount(sender);
        }
        _transferOwnership(sender);
    }
}
          

lib/openzeppelin-contracts/contracts/utils/Context.sol

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

src/types/PoolId.sol

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

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

type PoolId is bytes32;

/// @notice Library for computing the ID of a pool
library PoolIdLibrary {
    function toId(PoolKey memory poolKey) internal pure returns (PoolId poolId) {
        assembly ("memory-safe") {
            // 0xc0 represents the total size of the poolKey struct (6 slots of 32 bytes)
            poolId := keccak256(poolKey, 0xc0)
        }
    }
}
          

src/interfaces/IVault.sol

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

import {Currency} from "../types/Currency.sol";
import {BalanceDelta} from "../types/BalanceDelta.sol";
import {IVaultToken} from "./IVaultToken.sol";

interface IVault is IVaultToken {
    event AppRegistered(address indexed app);

    /// @notice Thrown when a app is not registered
    error AppUnregistered();

    /// @notice Thrown when a currency is not netted out after a lock
    error CurrencyNotSettled();

    /// @notice Thrown when an app's reserve deficit (transient mid-lock borrow against
    /// reservesOfApp) is not fully repaid by the end of the lock
    error AppCurrencyNotFullyRepaid();

    /// @notice Thrown when there is already a locker
    /// @param locker The address of the current locker
    error LockerAlreadySet(address locker);

    /// @notice Thrown when passing in msg.value for non-native currency
    error SettleNonNativeCurrencyWithValue();

    /// @notice Thrown when `clear` is called with an amount that is not exactly equal to the open currency delta.
    error MustClearExactPositiveDelta();

    /// @notice Thrown when there is no locker
    error NoLocker();

    /// @notice Thrown when collectFee is attempted on a token that is synced.
    error FeeCurrencySynced();

    function isAppRegistered(address app) external returns (bool);

    /// @notice Returns the reserves for a a given pool type and currency
    function reservesOfApp(address app, Currency currency) external view returns (uint256);

    /// @notice register an app so that it can perform accounting base on vault
    function registerApp(address app) external;

    /// @notice Returns the locker who is locking the vault
    function getLocker() external view returns (address locker);

    /// @notice Returns the reserve and its amount that is currently being stored in trnasient storage
    function getVaultReserve() external view returns (Currency, uint256);

    /// @notice Returns lock data
    function getUnsettledDeltasCount() external view returns (uint256 count);

    /// @notice Get the current delta for a locker in the given currency
    /// @param currency The currency for which to lookup the delta
    function currencyDelta(address settler, Currency currency) external view returns (int256);

    /// @notice Returns the number of (app, currency) pairs with an outstanding transient reserve deficit
    function getAppDeficitCount() external view returns (uint256 count);

    /// @notice Get the outstanding transient reserve deficit for a given app and currency
    /// @param app The app whose deficit to lookup
    /// @param currency The currency for which to lookup the deficit
    function appCurrencyDeficit(address app, Currency currency) external view returns (uint256);

    /// @notice All operations go through this function
    /// @param data Any data to pass to the callback, via `ILockCallback(msg.sender).lockCallback(data)`
    /// @return The data returned by the call to `ILockCallback(msg.sender).lockCallback(data)`
    function lock(bytes calldata data) external returns (bytes memory);

    /// @notice Called by registered app to account for a change in the pool balance,
    /// convenient for AMM pool manager, typically after modifyLiquidity, swap, donate,
    /// include the case where hookDelta is involved
    /// @param currency0 The PoolKey currency0 to update
    /// @param currency1 The PoolKey currency1 to update
    /// @param delta The change in the pool's balance
    /// @param settler The address whose delta will be updated
    /// @param hookDelta The change in the pool's balance from hook
    /// @param hook The address whose hookDelta will be updated
    function accountAppBalanceDelta(
        Currency currency0,
        Currency currency1,
        BalanceDelta delta,
        address settler,
        BalanceDelta hookDelta,
        address hook
    ) external;

    /// @notice Called by registered app to account for a change in the pool balance,
    /// convenient for AMM pool manager, typically after modifyLiquidity, swap, donate
    /// @param currency0 The PoolKey currency0 to update
    /// @param currency1 The PoolKey currency1 to update
    /// @param delta The change in the pool's balance
    /// @param settler The address whose delta will be updated
    function accountAppBalanceDelta(Currency currency0, Currency currency1, BalanceDelta delta, address settler)
        external;

    /// @notice This works as a general accounting mechanism for non-dex app
    /// @param currency The currency to update
    /// @param delta The change in the balance
    /// @param settler The address whose delta will be updated
    function accountAppBalanceDelta(Currency currency, int128 delta, address settler) external;

    /// @notice Called by the user to net out some value owed to the user
    /// @dev Will revert if the requested amount is not available, consider using `mint` instead
    /// @dev Can also be used as a mechanism for free flash loans
    function take(Currency currency, address to, uint256 amount) external;

    /// @notice Writes the current ERC20 balance of the specified currency to transient storage
    /// This is used to checkpoint balances for the manager and derive deltas for the caller.
    /// @dev This MUST be called before any ERC20 tokens are sent into the contract, but can be skipped
    /// for native tokens because the amount to settle is determined by the sent value.
    /// However, if an ERC20 token has been synced and not settled, and the caller instead wants to settle
    /// native funds, this function can be called with the native currency to then be able to settle the native currency
    function sync(Currency token0) external;

    /// @notice Called by the user to pay what is owed
    function settle() external payable returns (uint256 paid);

    /// @notice Called by the user to pay on behalf of another address
    /// @param recipient The address to credit for the payment
    /// @return paid The amount of currency settled
    function settleFor(address recipient) external payable returns (uint256 paid);

    /// @notice WARNING - Any currency that is cleared, will be non-retreivable, and locked in the contract permanently.
    /// A call to clear will zero out a positive balance WITHOUT a corresponding transfer.
    /// @dev This could be used to clear a balance that is considered dust.
    /// Additionally, the amount must be the exact positive balance. This is to enforce that the caller is aware of the amount being cleared.
    function clear(Currency currency, uint256 amount) external;

    /// @notice Called by app to collect any fee related
    /// @dev no restriction on caller, underflow happen if caller collect more than the reserve
    function collectFee(Currency currency, uint256 amount, address recipient) external;

    /// @notice Called by the user to store surplus tokens in the vault
    function mint(address to, Currency currency, uint256 amount) external;

    /// @notice Called by the user to use surplus tokens for payment settlement
    function burn(address from, Currency currency, uint256 amount) external;
}
          

src/types/BalanceDelta.sol

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

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

/// @dev Two `int128` values packed into a single `int256` where the upper 128 bits represent the amount0
/// and the lower 128 bits represent the amount1.
type BalanceDelta is int256;

using {add as +, sub as -, eq as ==, neq as !=} for BalanceDelta global;
using BalanceDeltaLibrary for BalanceDelta global;
using SafeCast for int256;

function toBalanceDelta(int128 _amount0, int128 _amount1) pure returns (BalanceDelta balanceDelta) {
    assembly ("memory-safe") {
        balanceDelta := or(shl(128, _amount0), and(sub(shl(128, 1), 1), _amount1))
    }
}

function add(BalanceDelta a, BalanceDelta b) pure returns (BalanceDelta) {
    int256 res0;
    int256 res1;
    assembly ("memory-safe") {
        let a0 := sar(128, a)
        let a1 := signextend(15, a)
        let b0 := sar(128, b)
        let b1 := signextend(15, b)
        res0 := add(a0, b0)
        res1 := add(a1, b1)
    }
    return toBalanceDelta(res0.toInt128(), res1.toInt128());
}

function sub(BalanceDelta a, BalanceDelta b) pure returns (BalanceDelta) {
    int256 res0;
    int256 res1;
    assembly ("memory-safe") {
        let a0 := sar(128, a)
        let a1 := signextend(15, a)
        let b0 := sar(128, b)
        let b1 := signextend(15, b)
        res0 := sub(a0, b0)
        res1 := sub(a1, b1)
    }
    return toBalanceDelta(res0.toInt128(), res1.toInt128());
}

function eq(BalanceDelta a, BalanceDelta b) pure returns (bool) {
    return BalanceDelta.unwrap(a) == BalanceDelta.unwrap(b);
}

function neq(BalanceDelta a, BalanceDelta b) pure returns (bool) {
    return BalanceDelta.unwrap(a) != BalanceDelta.unwrap(b);
}

/// @notice Library for getting the amount0 and amount1 deltas from the BalanceDelta type
library BalanceDeltaLibrary {
    /// @notice Constant for a BalanceDelta of zero value
    BalanceDelta public constant ZERO_DELTA = BalanceDelta.wrap(0);

    function amount0(BalanceDelta balanceDelta) internal pure returns (int128 _amount0) {
        assembly ("memory-safe") {
            _amount0 := sar(128, balanceDelta)
        }
    }

    function amount1(BalanceDelta balanceDelta) internal pure returns (int128 _amount1) {
        assembly ("memory-safe") {
            _amount1 := signextend(15, balanceDelta)
        }
    }
}
          

src/interfaces/ILockCallback.sol

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

/// @notice Interface for the callback executed when an address locks the vault
interface ILockCallback {
    /// @notice Called by the pool manager on `msg.sender` when a lock is acquired
    /// @param data The data that was passed to the call to lock
    /// @return Any data that you want to be returned from the lock call
    function lockAcquired(bytes calldata data) external returns (bytes memory);
}
          

src/libraries/CustomRevert.sol

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

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

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

            let fmp := mload(0x40)

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

src/libraries/ShanghaiTransient.sol

// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright (C) 2024 PancakeSwap; Shanghai adaptation (C) 2026 SquirrelSwap
pragma solidity ^0.8.24;

/// @notice Transient-storage emulation for chains without EIP-1153 (PulseChain = Shanghai).
///
/// Every slot that transient storage would clear at the end of a transaction is instead a normal storage
/// slot kept NEVER-ZERO once used: a logical value v is stored as (v XOR MARK), so a logical zero is stored
/// as MARK. The Vault already returns every such value to its logical zero before a lock ends, so each slot
/// ends the transaction holding exactly what it held at the start (MARK). EIP-2200 then refunds the dirty
/// write (restore-to-original: 2,800), leaving roughly 2,300 gas per slot per transaction instead of the
/// ~20,000+ a zero->nonzero->zero round trip costs once the EIP-3529 refund cap bites. The very first use of
/// a slot ever pays the one-time 20,000 zero->MARK initialisation.
///
/// A raw 0 (a slot never written) decodes to logical 0, so untouched slots read as empty, as with TLOAD.
/// The single unrepresentable logical value is MARK itself (bit 255 set, all else clear): as an address or a
/// count it is impossible; as an int256 delta it is type(int256).min; as a uint256 amount it is 2^255. Writers
/// refuse it outright rather than let it alias to zero.
library ShanghaiTransient {
    uint256 internal constant MARK = 1 << 255;

    error TransientValueUnrepresentable();

    function load(uint256 slot) internal view returns (uint256 v) {
        assembly ("memory-safe") {
            v := sload(slot)
            if v { v := xor(v, MARK) }
        }
    }

    function store(uint256 slot, uint256 v) internal {
        if (v == MARK) revert TransientValueUnrepresentable();
        assembly ("memory-safe") {
            sstore(slot, xor(v, MARK))
        }
    }
}
          

src/VaultToken.sol

// SPDX-License-Identifier: GPL-2.0-or-later
// Copyright (C) 2024 PancakeSwap
pragma solidity ^0.8.0;

import {Currency} from "./types/Currency.sol";
import {IVaultToken} from "./interfaces/IVaultToken.sol";

/// @dev This contract is a modified version of the ERC6909 implementation:
/// 1. totalSupply is removed
/// 2. tokenId is changed to Currency to fit our use case
/// @author Solmate (https://github.com/transmissions11/solmate/blob/main/src/tokens/ERC6909.sol)

/// @notice Users are allowed to store their surplus tokens i.e. unsettled balance that the pool
/// owed to user in the vault, and they will be able to withdraw them or use them to settle future
/// transactions. VaultToken is designed as a minimum implementation to achieve this goal. It keeps
/// track of users' surplus tokens and allows users to approve others to spend their tokens.
abstract contract VaultToken is IVaultToken {
    /*//////////////////////////////////////////////////////////////
                             ERC6909 STORAGE
    //////////////////////////////////////////////////////////////*/

    mapping(address owner => mapping(address operator => bool isOperator)) public isOperator;

    mapping(address owner => mapping(Currency currency => uint256 balance)) public balanceOf;

    mapping(address owner => mapping(address spender => mapping(Currency currency => uint256 amount))) public allowance;

    /*//////////////////////////////////////////////////////////////
                              ERC6909 LOGIC
    //////////////////////////////////////////////////////////////*/

    function transfer(address receiver, Currency currency, uint256 amount) public virtual returns (bool) {
        balanceOf[msg.sender][currency] -= amount;

        balanceOf[receiver][currency] += amount;

        emit Transfer(msg.sender, msg.sender, receiver, currency, amount);

        return true;
    }

    function transferFrom(address sender, address receiver, Currency currency, uint256 amount)
        public
        virtual
        returns (bool)
    {
        if (msg.sender != sender && !isOperator[sender][msg.sender]) {
            uint256 allowed = allowance[sender][msg.sender][currency];
            if (allowed != type(uint256).max) allowance[sender][msg.sender][currency] -= amount;
        }

        balanceOf[sender][currency] -= amount;

        balanceOf[receiver][currency] += amount;

        emit Transfer(msg.sender, sender, receiver, currency, amount);

        return true;
    }

    function approve(address spender, Currency currency, uint256 amount) public virtual returns (bool) {
        allowance[msg.sender][spender][currency] = amount;

        emit Approval(msg.sender, spender, currency, amount);

        return true;
    }

    function setOperator(address operator, bool approved) public virtual returns (bool) {
        isOperator[msg.sender][operator] = approved;

        emit OperatorSet(msg.sender, operator, approved);

        return true;
    }

    /*//////////////////////////////////////////////////////////////
                              ERC165 LOGIC
    //////////////////////////////////////////////////////////////*/

    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == 0x01ffc9a7 // ERC165 Interface ID for ERC165
            || interfaceId == 0xb2e69f8a; // ERC165 Interface ID for ERC6909
    }

    /*//////////////////////////////////////////////////////////////
                        INTERNAL MINT/BURN LOGIC
    //////////////////////////////////////////////////////////////*/

    function _mint(address receiver, Currency currency, uint256 amount) internal virtual {
        balanceOf[receiver][currency] += amount;

        emit Transfer(msg.sender, address(0), receiver, currency, amount);
    }

    function _burn(address sender, Currency currency, uint256 amount) internal virtual {
        balanceOf[sender][currency] -= amount;

        emit Transfer(msg.sender, sender, address(0), currency, amount);
    }

    function _burnFrom(address from, Currency currency, uint256 amount) internal virtual {
        if (msg.sender != from && !isOperator[from][msg.sender]) {
            uint256 allowed = allowance[from][msg.sender][currency];
            if (allowed != type(uint256).max) allowance[from][msg.sender][currency] -= amount;
        }

        _burn(from, currency, amount);
    }
}
          

lib/openzeppelin-contracts/contracts/access/Ownable.sol

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

src/interfaces/IVaultToken.sol

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

import {PoolId} from "../types/PoolId.sol";
import {PoolKey} from "../types/PoolKey.sol";
import {BalanceDelta} from "../types/BalanceDelta.sol";
import {IPoolManager} from "./IPoolManager.sol";
import {Currency} from "../types/Currency.sol";

interface IVaultToken {
    /*//////////////////////////////////////////////////////////////
                                 EVENTS
    //////////////////////////////////////////////////////////////*/

    event OperatorSet(address indexed owner, address indexed operator, bool approved);

    event Approval(address indexed owner, address indexed spender, Currency indexed currency, uint256 amount);

    event Transfer(address caller, address indexed from, address indexed to, Currency indexed currency, uint256 amount);

    /// @notice get the amount of owner's surplus token in vault
    /// @param owner The address you want to query the balance of
    /// @param currency The currency you want to query the balance of
    /// @return balance The balance of the specified address
    function balanceOf(address owner, Currency currency) external view returns (uint256 balance);

    /// @notice get the amount that owner has authorized for spender to use
    /// @param owner The address of the owner
    /// @param spender The address who is allowed to spend the owner's token
    /// @param currency The currency the spender is allowed to spend
    /// @return amount The amount of token the spender is allowed to spend
    function allowance(address owner, address spender, Currency currency) external view returns (uint256 amount);

    /// @notice approve spender for using user's token
    /// @param spender The address msg.sender is approving to spend the his token
    /// @param currency The currency the spender is allowed to spend
    /// @param amount The amount of token the spender is allowed to spend
    /// @return bool Whether the approval was successful or not
    function approve(address spender, Currency currency, uint256 amount) external returns (bool);

    /// @notice transfer msg.sender's token to someone else
    /// @param to The address to transfer the token to
    /// @param currency The currency to transfer
    /// @param amount The amount of token to transfer
    /// @return bool Whether the transfer was successful or not
    function transfer(address to, Currency currency, uint256 amount) external returns (bool);

    /// @notice transfer from address's token on behalf of him
    /// @param from The address to transfer the token from
    /// @param to The address to transfer the token to
    /// @param currency The currency to transfer
    /// @param amount The amount of token to transfer
    /// @return bool Whether the transfer was successful or not
    function transferFrom(address from, address to, Currency currency, uint256 amount) external returns (bool);
}
          

Compiler Settings

{"viaIR":true,"remappings":["ds-test/=lib/forge-std/lib/ds-test/src/","forge-gas-snapshot/=lib/forge-gas-snapshot/src/","forge-std/=lib/forge-std/src/","@openzeppelin/=lib/openzeppelin-contracts/","solmate/=lib/solmate/","pancake-create3-factory/=lib/pancake-create3-factory/","openzeppelin-contracts/=lib/openzeppelin-contracts/"],"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode"]}},"optimizer":{"runs":25666,"enabled":true},"metadata":{"useLiteralContent":false,"bytecodeHash":"none","appendCBOR":true},"libraries":{},"evmVersion":"shanghai"}
              

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[]},{"type":"error","name":"AppCurrencyNotFullyRepaid","inputs":[]},{"type":"error","name":"AppUnregistered","inputs":[]},{"type":"error","name":"CurrencyNotSettled","inputs":[]},{"type":"error","name":"FeeCurrencySynced","inputs":[]},{"type":"error","name":"LockerAlreadySet","inputs":[{"type":"address","name":"locker","internalType":"address"}]},{"type":"error","name":"MustClearExactPositiveDelta","inputs":[]},{"type":"error","name":"NoLocker","inputs":[]},{"type":"error","name":"OwnableInvalidOwner","inputs":[{"type":"address","name":"owner","internalType":"address"}]},{"type":"error","name":"OwnableUnauthorizedAccount","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"error","name":"SettleNonNativeCurrencyWithValue","inputs":[]},{"type":"error","name":"TransientValueUnrepresentable","inputs":[]},{"type":"event","name":"AppRegistered","inputs":[{"type":"address","name":"app","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Approval","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"spender","internalType":"address","indexed":true},{"type":"address","name":"currency","internalType":"Currency","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"OperatorSet","inputs":[{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"address","name":"operator","internalType":"address","indexed":true},{"type":"bool","name":"approved","internalType":"bool","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferStarted","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"Transfer","inputs":[{"type":"address","name":"caller","internalType":"address","indexed":false},{"type":"address","name":"from","internalType":"address","indexed":true},{"type":"address","name":"to","internalType":"address","indexed":true},{"type":"address","name":"currency","internalType":"Currency","indexed":true},{"type":"uint256","name":"amount","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"acceptOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"accountAppBalanceDelta","inputs":[{"type":"address","name":"currency0","internalType":"Currency"},{"type":"address","name":"currency1","internalType":"Currency"},{"type":"int256","name":"delta","internalType":"BalanceDelta"},{"type":"address","name":"settler","internalType":"address"},{"type":"int256","name":"hookDelta","internalType":"BalanceDelta"},{"type":"address","name":"hook","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"accountAppBalanceDelta","inputs":[{"type":"address","name":"currency","internalType":"Currency"},{"type":"int128","name":"delta","internalType":"int128"},{"type":"address","name":"settler","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"accountAppBalanceDelta","inputs":[{"type":"address","name":"currency0","internalType":"Currency"},{"type":"address","name":"currency1","internalType":"Currency"},{"type":"int256","name":"delta","internalType":"BalanceDelta"},{"type":"address","name":"settler","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"amount","internalType":"uint256"}],"name":"allowance","inputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"address","name":"spender","internalType":"address"},{"type":"address","name":"currency","internalType":"Currency"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"appCurrencyDeficit","inputs":[{"type":"address","name":"app","internalType":"address"},{"type":"address","name":"currency","internalType":"Currency"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"approve","inputs":[{"type":"address","name":"spender","internalType":"address"},{"type":"address","name":"currency","internalType":"Currency"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"balance","internalType":"uint256"}],"name":"balanceOf","inputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"address","name":"currency","internalType":"Currency"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"burn","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"currency","internalType":"Currency"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"clear","inputs":[{"type":"address","name":"currency","internalType":"Currency"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"collectFee","inputs":[{"type":"address","name":"currency","internalType":"Currency"},{"type":"uint256","name":"amount","internalType":"uint256"},{"type":"address","name":"recipient","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"int256","name":"","internalType":"int256"}],"name":"currencyDelta","inputs":[{"type":"address","name":"settler","internalType":"address"},{"type":"address","name":"currency","internalType":"Currency"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getAppDeficitCount","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getLocker","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getUnsettledDeltasCount","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"Currency"},{"type":"uint256","name":"","internalType":"uint256"}],"name":"getVaultReserve","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"isRegistered","internalType":"bool"}],"name":"isAppRegistered","inputs":[{"type":"address","name":"app","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"isOperator","internalType":"bool"}],"name":"isOperator","inputs":[{"type":"address","name":"owner","internalType":"address"},{"type":"address","name":"operator","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bytes","name":"result","internalType":"bytes"}],"name":"lock","inputs":[{"type":"bytes","name":"data","internalType":"bytes"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"mint","inputs":[{"type":"address","name":"to","internalType":"address"},{"type":"address","name":"currency","internalType":"Currency"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"pendingOwner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"registerApp","inputs":[{"type":"address","name":"app","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"reserve","internalType":"uint256"}],"name":"reservesOfApp","inputs":[{"type":"address","name":"app","internalType":"address"},{"type":"address","name":"currency","internalType":"Currency"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"setOperator","inputs":[{"type":"address","name":"operator","internalType":"address"},{"type":"bool","name":"approved","internalType":"bool"}]},{"type":"function","stateMutability":"payable","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"settle","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"settleFor","inputs":[{"type":"address","name":"recipient","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"supportsInterface","inputs":[{"type":"bytes4","name":"interfaceId","internalType":"bytes4"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"sync","inputs":[{"type":"address","name":"currency","internalType":"Currency"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"take","inputs":[{"type":"address","name":"currency","internalType":"Currency"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"transfer","inputs":[{"type":"address","name":"receiver","internalType":"address"},{"type":"address","name":"currency","internalType":"Currency"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"transferFrom","inputs":[{"type":"address","name":"sender","internalType":"address"},{"type":"address","name":"receiver","internalType":"address"},{"type":"address","name":"currency","internalType":"Currency"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]}]
              

Contract Creation Code

0x60808060405234607a573315606757600480546001600160a01b0319908116909155600380543392811683179091556001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3612833908161007f8239f35b631e4fbdf760e01b5f525f60045260245ffd5b5f80fdfe6080806040526004361015610012575f80fd5b5f3560e01c90816301ffc9a714611a8e575080630b0d9c09146119fa57806311da60b41461199657806315dacbea1461181357806317a1d80f1461178157806320d9cd95146116f1578063322c36201461168357806336223ce9146116475780633dd45adb146115da578063558a72971461152257806357bb1c06146114d65780635d4e0ced146114735780635d685a3c1461136c5780636d102799146112cb578063715018a61461122557806379ba50971461113957806380f0b44c1461107a5780638154831914610b9c5780638403be9114610b525780638da5cb5b14610b1f5780639073e5ca14610a5c578063927da105146109c6578063a54b28311461099a578063a58411941461087b578063b6363cf214610809578063beabacc814610723578063c6c3bbe614610650578063e1f21c67146105c7578063e30c397814610594578063eb78b4351461048a578063f2fde38b146103ea578063f6b911bc14610226578063f7888aec146101b85763fda4289214610192575f80fd5b346101b4575f6003193601126101b45760206101ac6124c0565b604051908152f35b5f80fd5b346101b45760406003193601126101b4576101d1611b2c565b73ffffffffffffffffffffffffffffffffffffffff6101ee611b4f565b91165f52600160205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052602060405f2054604051908152f35b346101b45761023436611bd9565b919073ffffffffffffffffffffffffffffffffffffffff7fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d7054806103df575b16156103b7577f5b21a3c624a398df3917a0a930f91e3837519b8eab3302b834746433065f295973ffffffffffffffffffffffffffffffffffffffff805f946102c86102be88611cfc565b600f0b8633611d27565b16928333141580610395575b610313575b8385526001602052604085208282168652602052604085206102fc878254611c2d565b9055604080513381526020810197909752911694a4005b83855260026020526040852082331686526020526040852082821686526020527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff604086205403156102d95783855260026020526040852082331686526020526040852082821686526020526040852061038e878254611c2d565b90556102d9565b508385528460205260408520823316865260205260ff604086205416156102d4565b7f05185ab0000000000000000000000000000000000000000000000000000000005f5260045ffd5b600160ff1b18610273565b346101b45760206003193601126101b45773ffffffffffffffffffffffffffffffffffffffff610418611b2c565b61042061225f565b16807fffffffffffffffffffffffff0000000000000000000000000000000000000000600454161760045573ffffffffffffffffffffffffffffffffffffffff600354167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e227005f80a3005b346101b45760606003193601126101b4576104a3611b2c565b6024356104ae611b72565b335f52600560205260ff60405f2054161561056c576104cb612280565b509273ffffffffffffffffffffffffffffffffffffffff81169384801515918261054c575b50506105245761052293335f52600660205260405f20905f5260205260405f2061051b848254611c2d565b9055611f53565b005b7ff22c9825000000000000000000000000000000000000000000000000000000005f5260045ffd5b73ffffffffffffffffffffffffffffffffffffffff1614905084866104f0565b7feb385691000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101b4575f6003193601126101b457602073ffffffffffffffffffffffffffffffffffffffff60045416604051908152f35b346101b45773ffffffffffffffffffffffffffffffffffffffff806105eb36611bd9565b92919390335f52600260205260405f208286165f5260205260405f208282165f526020528360405f2055604051938452169216907fa0175360a15bca328baf7ea85c7b784d58b222a50d0ce760b10dba336d226a6160203392a4602060405160018152f35b346101b45761065e36611bd9565b9173ffffffffffffffffffffffffffffffffffffffff7fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d705480610718575b16156103b7577f5b21a3c624a398df3917a0a930f91e3837519b8eab3302b834746433065f295973ffffffffffffffffffffffffffffffffffffffff805f936106f36106e788611cfc565b8603600f0b8733611d27565b16938484526001602052604084208282168552602052604084206102fc878254611c67565b600160ff1b1861069c565b346101b45773ffffffffffffffffffffffffffffffffffffffff61074636611bd9565b91929092335f52600160205260405f208285165f5260205260405f2061076d848254611c2d565b90551690815f52600160205260405f2073ffffffffffffffffffffffffffffffffffffffff84165f5260205260405f206107a8828254611c67565b90556040805133808252602082019390935273ffffffffffffffffffffffffffffffffffffffff94909416937f5b21a3c624a398df3917a0a930f91e3837519b8eab3302b834746433065f295991819081015b0390a4602060405160018152f35b346101b45760406003193601126101b457610822611b2c565b73ffffffffffffffffffffffffffffffffffffffff61083f611b4f565b91165f525f60205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052602060ff60405f2054166040519015158152f35b346101b45760206003193601126101b457610894611b2c565b73ffffffffffffffffffffffffffffffffffffffff81169081610900575050600160ff1b7f52a1be34b47478d7c75e2b6c3eea1e05dcb8dbb8c6a42c6482d0dca0df53cb278190557fb0879d96d58bcff08d1fd45590200072d5a8c380da0b5aa1052b48b84e11520755005b61090990612507565b90600160ff1b811461097257600160ff1b187f52a1be34b47478d7c75e2b6c3eea1e05dcb8dbb8c6a42c6482d0dca0df53cb2755600160ff1b811461097257600160ff1b187fb0879d96d58bcff08d1fd45590200072d5a8c380da0b5aa1052b48b84e11520755005b7f2d3bdf90000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101b45760406003193601126101b45760206101ac6109b8611b2c565b6109c0611b4f565b90612456565b346101b45760606003193601126101b4576109df611b2c565b6109e7611b4f565b73ffffffffffffffffffffffffffffffffffffffff610a04611b72565b92165f52600260205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f5260205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052602060405f2054604051908152f35b346101b45760806003193601126101b457610a75611b2c565b610a7d611b4f565b60443590610a89611b95565b73ffffffffffffffffffffffffffffffffffffffff7fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d705480610b14575b16156103b757335f52600560205260ff60405f2054161561056c57610b0f610522948460801d94600f0b94610afb81836122fd565b610b0586866122fd565b600f0b9083611d27565b611d27565b600160ff1b18610ac6565b346101b4575f6003193601126101b457602073ffffffffffffffffffffffffffffffffffffffff60035416604051908152f35b346101b45760206003193601126101b45773ffffffffffffffffffffffffffffffffffffffff610b80611b2c565b165f526005602052602060ff60405f2054166040519015158152f35b346101b45760206003193601126101b45760043567ffffffffffffffff81116101b457366023820112156101b457806004013567ffffffffffffffff81116101b45736602482840101116101b4577fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d70549173ffffffffffffffffffffffffffffffffffffffff838061106f575b1680151580611066575b61103b5750828061102d575b5073ffffffffffffffffffffffffffffffffffffffff927fffffffffffffffffffffffff000000000000000000000000000000000000000016331790600160ff1b8214610972576044602491600160ff1b5f94187fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d7055600160ff1b7f52a1be34b47478d7c75e2b6c3eea1e05dcb8dbb8c6a42c6482d0dca0df53cb2755600160ff1b7fb0879d96d58bcff08d1fd45590200072d5a8c380da0b5aa1052b48b84e115207557fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8660405197889687957fab6291fe0000000000000000000000000000000000000000000000000000000087526020600488015282828801520186860137868582860101520116810103018183335af1908115611022575f91610f4e575b50610d8c6124c0565b610f26577f8441ca20eb4e3f4809b32435cc73fbff7fb24d1abccd9553e242325f6e57cdb95480610f1b575b610ef3577fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d7054828180610ee8575b169283151580610ee1575b610eb5577fffffffffffffffffffffffff000000000000000000000000000000000000000091908180610ea7575b505016600160ff1b811461097257601f91600160ff1b604092187fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d70557fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0825193849260208452610e9e8151809281602088015260208888019101611bb8565b01168101030190f35b600160ff1b18915084610e1f565b837fc6742a3f000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b505f610df1565b600160ff1b18610de6565b7f132ebdab000000000000000000000000000000000000000000000000000000005f5260045ffd5b600160ff1b18610db8565b7f5212cba1000000000000000000000000000000000000000000000000000000005f5260045ffd5b90503d805f833e610f5f8183611cbb565b8101906020818303126101b45780519067ffffffffffffffff82116101b4570181601f820112156101b457805167ffffffffffffffff8111610ff55760405192610fd160207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501160185611cbb565b818452602082840101116101b457610fef9160208085019101611bb8565b82610d83565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6040513d5f823e3d90fd5b600160ff1b18925083610c3f565b7fc6742a3f000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b50331515610c33565b600160ff1b18610c29565b346101b45760406003193601126101b457611093611b2c565b73ffffffffffffffffffffffffffffffffffffffff7fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d70548061112e575b16156103b7576110e08133612456565b906110ec602435611cfc565b9182600f0b0361110657610522915f03600f0b9033611d27565b7fbda73abf000000000000000000000000000000000000000000000000000000005f5260045ffd5b600160ff1b186110d0565b346101b4575f6003193601126101b4573373ffffffffffffffffffffffffffffffffffffffff60045416036111f9577fffffffffffffffffffffffff000000000000000000000000000000000000000060045416600455600354337fffffffffffffffffffffffff000000000000000000000000000000000000000082161760035573ffffffffffffffffffffffffffffffffffffffff3391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3005b7f118cdaa7000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b346101b4575f6003193601126101b45761123d61225f565b7fffffffffffffffffffffffff0000000000000000000000000000000000000000600454166004555f73ffffffffffffffffffffffffffffffffffffffff6003547fffffffffffffffffffffffff00000000000000000000000000000000000000008116600355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b346101b45760606003193601126101b4576112e4611b2c565b6024359081600f0b908183036101b4576112fc611b72565b73ffffffffffffffffffffffffffffffffffffffff7fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d705480611361575b16156103b757335f52600560205260ff60405f2054161561056c57610b0f61052294836122fd565b600160ff1b18611339565b346101b45760c06003193601126101b457611385611b2c565b61138d611b4f565b60443590611399611b95565b926084359360a4359173ffffffffffffffffffffffffffffffffffffffff831683036101b45773ffffffffffffffffffffffffffffffffffffffff7fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d705480611468575b16156103b757335f52600560205260ff60405f2054161561056c5761052295610b05610b0f93868860801d98600f0b91610b0f8560801d95600f0b9a61144b6114458883611c74565b896122fd565b61145e6114588d87611c74565b856122fd565b600f0b8783611d27565b600160ff1b186113fc565b346101b4575f6003193601126101b45760207fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d7054806114cb575b73ffffffffffffffffffffffffffffffffffffffff60405191168152f35b600160ff1b186114ad565b346101b4575f6003193601126101b45760207f8441ca20eb4e3f4809b32435cc73fbff7fb24d1abccd9553e242325f6e57cdb9548061151757604051908152f35b600160ff1b186101ac565b346101b45760406003193601126101b45761153b611b2c565b602435908115158092036101b45773ffffffffffffffffffffffffffffffffffffffff90335f525f60205260405f208282165f5260205260405f207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0081541660ff851617905560405192835216907fceb576d9f15e4e200fdb5096d64d5dfd667e16def20c1eefd14256d8e3faa26760203392a3602060405160018152f35b60206003193601126101b4576115ee611b2c565b73ffffffffffffffffffffffffffffffffffffffff7fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d70548061163c575b16156103b7576101ac602091612188565b600160ff1b1861162b565b346101b4575f6003193601126101b4576040611661612280565b73ffffffffffffffffffffffffffffffffffffffff8351921682526020820152f35b346101b45760406003193601126101b45761169c611b2c565b73ffffffffffffffffffffffffffffffffffffffff6116b9611b4f565b91165f52600660205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052602060405f2054604051908152f35b346101b45760406003193601126101b457602061170c611b2c565b611714611b4f565b73ffffffffffffffffffffffffffffffffffffffff6040519181858401941684521660408201527fb15a985351e7fec20c5ab24bbbbeccb6443ba2a83f05cd1411825d064d91cf43606082015260608152611770608082611cbb565b519020548061151757604051908152f35b346101b45760206003193601126101b45773ffffffffffffffffffffffffffffffffffffffff6117af611b2c565b6117b761225f565b16805f52600560205260405f2060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff008254161790557f0d540ad8f39e07d19909687352b9fa017405d93c91a6760981fbae9cf28bfef75f80a2005b346101b45760806003193601126101b45761182c611b2c565b611834611b4f565b61183c611b72565b907f5b21a3c624a398df3917a0a930f91e3837519b8eab3302b834746433065f295973ffffffffffffffffffffffffffffffffffffffff80806064359616938433141580611974575b6118f2575b845f52600160205260405f208287165f5260205260405f206118ad888254611c2d565b90551693845f52600160205260405f208282165f5260205260405f206118d4878254611c67565b905560408051338152602081019790975291169490819081016107fb565b845f52600260205260405f208233165f5260205260405f208287165f526020527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60405f2054031561188a57845f52600260205260405f208233165f5260205260405f208287165f5260205260405f2061196d888254611c2d565b905561188a565b50845f525f60205260405f208233165f5260205260ff60405f20541615611885565b5f6003193601126101b45773ffffffffffffffffffffffffffffffffffffffff7fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d7054806119ef575b16156103b75760206101ac33612188565b600160ff1b186119de565b346101b45760606003193601126101b457611a13611b2c565b611a1b611b4f565b6044359073ffffffffffffffffffffffffffffffffffffffff7fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d705480611a83575b16156103b75761052292611a7e611a7284611cfc565b5f03600f0b8233611d27565b611f53565b600160ff1b18611a5c565b346101b45760206003193601126101b457600435907fffffffff0000000000000000000000000000000000000000000000000000000082168092036101b457817f01ffc9a70000000000000000000000000000000000000000000000000000000060209314908115611b02575b5015158152f35b7fb2e69f8a0000000000000000000000000000000000000000000000000000000091501483611afb565b6004359073ffffffffffffffffffffffffffffffffffffffff821682036101b457565b6024359073ffffffffffffffffffffffffffffffffffffffff821682036101b457565b6044359073ffffffffffffffffffffffffffffffffffffffff821682036101b457565b6064359073ffffffffffffffffffffffffffffffffffffffff821682036101b457565b5f5b838110611bc95750505f910152565b8181015183820152602001611bba565b60031960609101126101b45760043573ffffffffffffffffffffffffffffffffffffffff811681036101b4579060243573ffffffffffffffffffffffffffffffffffffffff811681036101b4579060443590565b91908203918211611c3a57565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b91908201809211611c3a57565b90600f0b90600f0b01907fffffffffffffffffffffffffffffffff8000000000000000000000000000000082126f7fffffffffffffffffffffffffffffff831317611c3a57565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff821117610ff557604052565b6f80000000000000000000000000000000811015611d1a57600f0b90565b6393dafdf15f526004601cfd5b9190918115611f4e57611d3a8382612456565b8281019283125f8212908015821691151617611c3a5782611e8c57507fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d705480611e81575b73ffffffffffffffffffffffffffffffffffffffff7f7fffffffffffffffffffffff00000000000000000000000000000000000000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8360a01c0160a01b1691161792600160ff1b841461097257600160ff1b611e7f94187fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d70555b73ffffffffffffffffffffffffffffffffffffffff604051918160208401941684521660408201527f6dc13502b9ba2a9e8e42c53a1856d632b29d5aab3bcb4a2476bfec06cbd9cf22606082015260608152611e77608082611cbb565b51902061259e565b565b600160ff1b18611d7e565b15611e9b575b611e7f92611e1a565b7fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d705480611f43575b73ffffffffffffffffffffffffffffffffffffffff7f7fffffffffffffffffffffff000000000000000000000000000000000000000060018360a01c0160a01b1691161792600160ff1b841461097257600160ff1b939093187fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d7055611e92565b600160ff1b18611ec3565b505050565b90919073ffffffffffffffffffffffffffffffffffffffff811690816120455750505f80808093855af115611f855750565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f3d011673ffffffffffffffffffffffffffffffffffffffff604051927f90bfb8650000000000000000000000000000000000000000000000000000000084521660048301525f6024830152608060448301528060a00160648301523d60848301523d5f60a484013e7ff4b3b1bc0000000000000000000000000000000000000000000000000000000060c4828401600460a4820152015260e40190fd5b60205f60448194968260409573ffffffffffffffffffffffffffffffffffffffff988751998a947fa9059cbb00000000000000000000000000000000000000000000000000000000865216600485015260248401525af13d15601f3d116001855114161716928281528260208201520152156120be5750565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f3d0116604051917f90bfb86500000000000000000000000000000000000000000000000000000000835260048301527fa9059cbb000000000000000000000000000000000000000000000000000000006024830152608060448301528060a00160648301523d60848301523d5f60a484013e7ff27f64e40000000000000000000000000000000000000000000000000000000060c4828401600460a4820152015260e40190fd5b90612191612280565b909273ffffffffffffffffffffffffffffffffffffffff841615612253573461222b576121c9611e7f926121c486612507565b611c2d565b93600160ff1b7f52a1be34b47478d7c75e2b6c3eea1e05dcb8dbb8c6a42c6482d0dca0df53cb2755600160ff1b7fb0879d96d58bcff08d1fd45590200072d5a8c380da0b5aa1052b48b84e115207555b61222285611cfc565b600f0b91611d27565b7f11e56171000000000000000000000000000000000000000000000000000000005f5260045ffd5b611e7f91503493612219565b73ffffffffffffffffffffffffffffffffffffffff6003541633036111f957565b73ffffffffffffffffffffffffffffffffffffffff7f52a1be34b47478d7c75e2b6c3eea1e05dcb8dbb8c6a42c6482d0dca0df53cb2754806122f2575b16907fb0879d96d58bcff08d1fd45590200072d5a8c380da0b5aa1052b48b84e11520754806122e95790565b600160ff1b1890565b600160ff1b186122bd565b81600f0b8015611f4e575f81126123c85750335f52600660205260405f2073ffffffffffffffffffffffffffffffffffffffff82165f526020526fffffffffffffffffffffffffffffffff60405f2054921690818310155f1461238c57335f52600660205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f5260205260405f2091039055565b9091611e7f92335f52600660205260405f2073ffffffffffffffffffffffffffffffffffffffff84165f526020525f604081205503903361271d565b9091507fffffffffffffffffffffffffffffffff800000000000000000000000000000008114611c3a576fffffffffffffffffffffffffffffffff612411915f031682336125b4565b908161241b575050565b335f52600660205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f5260205261245260405f20918254611c67565b9055565b9073ffffffffffffffffffffffffffffffffffffffff604051918160208401941684521660408201527f6dc13502b9ba2a9e8e42c53a1856d632b29d5aab3bcb4a2476bfec06cbd9cf226060820152606081526124b4608082611cbb565b51902054806122e95790565b7fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d7054806124fc575b60a01c6b7fffffffffffffffffffffff1690565b600160ff1b186124e8565b73ffffffffffffffffffffffffffffffffffffffff168061252757504790565b6020602491604051928380927f70a082310000000000000000000000000000000000000000000000000000000082523060048301525afa908115611022575f9161256f575090565b90506020813d602011612596575b8161258a60209383611cbb565b810103126101b4575190565b3d915061257d565b90600160ff1b811461097257600160ff1b189055565b9291925f917f8441ca20eb4e3f4809b32435cc73fbff7fb24d1abccd9553e242325f6e57cdb95480612712575b15611f4e5773ffffffffffffffffffffffffffffffffffffffff604051918160208401941684521660408201527fb15a985351e7fec20c5ab24bbbbeccb6443ba2a83f05cd1411825d064d91cf43606082015260608152612643608082611cbb565b5190209283549182612705575b82156126ff578282106126f2575090600160ff1b910392557fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f8441ca20eb4e3f4809b32435cc73fbff7fb24d1abccd9553e242325f6e57cdb954806126e7575b01600160ff1b811461097257600160ff1b187f8441ca20eb4e3f4809b32435cc73fbff7fb24d1abccd9553e242325f6e57cdb955565b600160ff1b186126b1565b9390611e7f92039061259e565b50925050565b91600160ff1b1891612650565b600160ff1b186125e1565b908215611f4e5773ffffffffffffffffffffffffffffffffffffffff604051918160208401941684521660408201527fb15a985351e7fec20c5ab24bbbbeccb6443ba2a83f05cd1411825d064d91cf43606082015260608152612781608082611cbb565b51902080549182612819575b82156127a7575b6127a190611e7f93611c67565b9061259e565b60017f8441ca20eb4e3f4809b32435cc73fbff7fb24d1abccd9553e242325f6e57cdb9548061280e575b0190600160ff1b821461097257600160ff1b919091187f8441ca20eb4e3f4809b32435cc73fbff7fb24d1abccd9553e242325f6e57cdb955612794565b600160ff1b186127d1565b91600160ff1b189161278d56fea164736f6c634300081a000a

Deployed ByteCode

0x6080806040526004361015610012575f80fd5b5f3560e01c90816301ffc9a714611a8e575080630b0d9c09146119fa57806311da60b41461199657806315dacbea1461181357806317a1d80f1461178157806320d9cd95146116f1578063322c36201461168357806336223ce9146116475780633dd45adb146115da578063558a72971461152257806357bb1c06146114d65780635d4e0ced146114735780635d685a3c1461136c5780636d102799146112cb578063715018a61461122557806379ba50971461113957806380f0b44c1461107a5780638154831914610b9c5780638403be9114610b525780638da5cb5b14610b1f5780639073e5ca14610a5c578063927da105146109c6578063a54b28311461099a578063a58411941461087b578063b6363cf214610809578063beabacc814610723578063c6c3bbe614610650578063e1f21c67146105c7578063e30c397814610594578063eb78b4351461048a578063f2fde38b146103ea578063f6b911bc14610226578063f7888aec146101b85763fda4289214610192575f80fd5b346101b4575f6003193601126101b45760206101ac6124c0565b604051908152f35b5f80fd5b346101b45760406003193601126101b4576101d1611b2c565b73ffffffffffffffffffffffffffffffffffffffff6101ee611b4f565b91165f52600160205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052602060405f2054604051908152f35b346101b45761023436611bd9565b919073ffffffffffffffffffffffffffffffffffffffff7fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d7054806103df575b16156103b7577f5b21a3c624a398df3917a0a930f91e3837519b8eab3302b834746433065f295973ffffffffffffffffffffffffffffffffffffffff805f946102c86102be88611cfc565b600f0b8633611d27565b16928333141580610395575b610313575b8385526001602052604085208282168652602052604085206102fc878254611c2d565b9055604080513381526020810197909752911694a4005b83855260026020526040852082331686526020526040852082821686526020527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff604086205403156102d95783855260026020526040852082331686526020526040852082821686526020526040852061038e878254611c2d565b90556102d9565b508385528460205260408520823316865260205260ff604086205416156102d4565b7f05185ab0000000000000000000000000000000000000000000000000000000005f5260045ffd5b600160ff1b18610273565b346101b45760206003193601126101b45773ffffffffffffffffffffffffffffffffffffffff610418611b2c565b61042061225f565b16807fffffffffffffffffffffffff0000000000000000000000000000000000000000600454161760045573ffffffffffffffffffffffffffffffffffffffff600354167f38d16b8cac22d99fc7c124b9cd0de2d3fa1faef420bfe791d8c362d765e227005f80a3005b346101b45760606003193601126101b4576104a3611b2c565b6024356104ae611b72565b335f52600560205260ff60405f2054161561056c576104cb612280565b509273ffffffffffffffffffffffffffffffffffffffff81169384801515918261054c575b50506105245761052293335f52600660205260405f20905f5260205260405f2061051b848254611c2d565b9055611f53565b005b7ff22c9825000000000000000000000000000000000000000000000000000000005f5260045ffd5b73ffffffffffffffffffffffffffffffffffffffff1614905084866104f0565b7feb385691000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101b4575f6003193601126101b457602073ffffffffffffffffffffffffffffffffffffffff60045416604051908152f35b346101b45773ffffffffffffffffffffffffffffffffffffffff806105eb36611bd9565b92919390335f52600260205260405f208286165f5260205260405f208282165f526020528360405f2055604051938452169216907fa0175360a15bca328baf7ea85c7b784d58b222a50d0ce760b10dba336d226a6160203392a4602060405160018152f35b346101b45761065e36611bd9565b9173ffffffffffffffffffffffffffffffffffffffff7fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d705480610718575b16156103b7577f5b21a3c624a398df3917a0a930f91e3837519b8eab3302b834746433065f295973ffffffffffffffffffffffffffffffffffffffff805f936106f36106e788611cfc565b8603600f0b8733611d27565b16938484526001602052604084208282168552602052604084206102fc878254611c67565b600160ff1b1861069c565b346101b45773ffffffffffffffffffffffffffffffffffffffff61074636611bd9565b91929092335f52600160205260405f208285165f5260205260405f2061076d848254611c2d565b90551690815f52600160205260405f2073ffffffffffffffffffffffffffffffffffffffff84165f5260205260405f206107a8828254611c67565b90556040805133808252602082019390935273ffffffffffffffffffffffffffffffffffffffff94909416937f5b21a3c624a398df3917a0a930f91e3837519b8eab3302b834746433065f295991819081015b0390a4602060405160018152f35b346101b45760406003193601126101b457610822611b2c565b73ffffffffffffffffffffffffffffffffffffffff61083f611b4f565b91165f525f60205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052602060ff60405f2054166040519015158152f35b346101b45760206003193601126101b457610894611b2c565b73ffffffffffffffffffffffffffffffffffffffff81169081610900575050600160ff1b7f52a1be34b47478d7c75e2b6c3eea1e05dcb8dbb8c6a42c6482d0dca0df53cb278190557fb0879d96d58bcff08d1fd45590200072d5a8c380da0b5aa1052b48b84e11520755005b61090990612507565b90600160ff1b811461097257600160ff1b187f52a1be34b47478d7c75e2b6c3eea1e05dcb8dbb8c6a42c6482d0dca0df53cb2755600160ff1b811461097257600160ff1b187fb0879d96d58bcff08d1fd45590200072d5a8c380da0b5aa1052b48b84e11520755005b7f2d3bdf90000000000000000000000000000000000000000000000000000000005f5260045ffd5b346101b45760406003193601126101b45760206101ac6109b8611b2c565b6109c0611b4f565b90612456565b346101b45760606003193601126101b4576109df611b2c565b6109e7611b4f565b73ffffffffffffffffffffffffffffffffffffffff610a04611b72565b92165f52600260205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f5260205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052602060405f2054604051908152f35b346101b45760806003193601126101b457610a75611b2c565b610a7d611b4f565b60443590610a89611b95565b73ffffffffffffffffffffffffffffffffffffffff7fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d705480610b14575b16156103b757335f52600560205260ff60405f2054161561056c57610b0f610522948460801d94600f0b94610afb81836122fd565b610b0586866122fd565b600f0b9083611d27565b611d27565b600160ff1b18610ac6565b346101b4575f6003193601126101b457602073ffffffffffffffffffffffffffffffffffffffff60035416604051908152f35b346101b45760206003193601126101b45773ffffffffffffffffffffffffffffffffffffffff610b80611b2c565b165f526005602052602060ff60405f2054166040519015158152f35b346101b45760206003193601126101b45760043567ffffffffffffffff81116101b457366023820112156101b457806004013567ffffffffffffffff81116101b45736602482840101116101b4577fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d70549173ffffffffffffffffffffffffffffffffffffffff838061106f575b1680151580611066575b61103b5750828061102d575b5073ffffffffffffffffffffffffffffffffffffffff927fffffffffffffffffffffffff000000000000000000000000000000000000000016331790600160ff1b8214610972576044602491600160ff1b5f94187fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d7055600160ff1b7f52a1be34b47478d7c75e2b6c3eea1e05dcb8dbb8c6a42c6482d0dca0df53cb2755600160ff1b7fb0879d96d58bcff08d1fd45590200072d5a8c380da0b5aa1052b48b84e115207557fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8660405197889687957fab6291fe0000000000000000000000000000000000000000000000000000000087526020600488015282828801520186860137868582860101520116810103018183335af1908115611022575f91610f4e575b50610d8c6124c0565b610f26577f8441ca20eb4e3f4809b32435cc73fbff7fb24d1abccd9553e242325f6e57cdb95480610f1b575b610ef3577fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d7054828180610ee8575b169283151580610ee1575b610eb5577fffffffffffffffffffffffff000000000000000000000000000000000000000091908180610ea7575b505016600160ff1b811461097257601f91600160ff1b604092187fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d70557fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0825193849260208452610e9e8151809281602088015260208888019101611bb8565b01168101030190f35b600160ff1b18915084610e1f565b837fc6742a3f000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b505f610df1565b600160ff1b18610de6565b7f132ebdab000000000000000000000000000000000000000000000000000000005f5260045ffd5b600160ff1b18610db8565b7f5212cba1000000000000000000000000000000000000000000000000000000005f5260045ffd5b90503d805f833e610f5f8183611cbb565b8101906020818303126101b45780519067ffffffffffffffff82116101b4570181601f820112156101b457805167ffffffffffffffff8111610ff55760405192610fd160207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f8501160185611cbb565b818452602082840101116101b457610fef9160208085019101611bb8565b82610d83565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52604160045260245ffd5b6040513d5f823e3d90fd5b600160ff1b18925083610c3f565b7fc6742a3f000000000000000000000000000000000000000000000000000000005f5260045260245ffd5b50331515610c33565b600160ff1b18610c29565b346101b45760406003193601126101b457611093611b2c565b73ffffffffffffffffffffffffffffffffffffffff7fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d70548061112e575b16156103b7576110e08133612456565b906110ec602435611cfc565b9182600f0b0361110657610522915f03600f0b9033611d27565b7fbda73abf000000000000000000000000000000000000000000000000000000005f5260045ffd5b600160ff1b186110d0565b346101b4575f6003193601126101b4573373ffffffffffffffffffffffffffffffffffffffff60045416036111f9577fffffffffffffffffffffffff000000000000000000000000000000000000000060045416600455600354337fffffffffffffffffffffffff000000000000000000000000000000000000000082161760035573ffffffffffffffffffffffffffffffffffffffff3391167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e05f80a3005b7f118cdaa7000000000000000000000000000000000000000000000000000000005f523360045260245ffd5b346101b4575f6003193601126101b45761123d61225f565b7fffffffffffffffffffffffff0000000000000000000000000000000000000000600454166004555f73ffffffffffffffffffffffffffffffffffffffff6003547fffffffffffffffffffffffff00000000000000000000000000000000000000008116600355167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08280a3005b346101b45760606003193601126101b4576112e4611b2c565b6024359081600f0b908183036101b4576112fc611b72565b73ffffffffffffffffffffffffffffffffffffffff7fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d705480611361575b16156103b757335f52600560205260ff60405f2054161561056c57610b0f61052294836122fd565b600160ff1b18611339565b346101b45760c06003193601126101b457611385611b2c565b61138d611b4f565b60443590611399611b95565b926084359360a4359173ffffffffffffffffffffffffffffffffffffffff831683036101b45773ffffffffffffffffffffffffffffffffffffffff7fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d705480611468575b16156103b757335f52600560205260ff60405f2054161561056c5761052295610b05610b0f93868860801d98600f0b91610b0f8560801d95600f0b9a61144b6114458883611c74565b896122fd565b61145e6114588d87611c74565b856122fd565b600f0b8783611d27565b600160ff1b186113fc565b346101b4575f6003193601126101b45760207fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d7054806114cb575b73ffffffffffffffffffffffffffffffffffffffff60405191168152f35b600160ff1b186114ad565b346101b4575f6003193601126101b45760207f8441ca20eb4e3f4809b32435cc73fbff7fb24d1abccd9553e242325f6e57cdb9548061151757604051908152f35b600160ff1b186101ac565b346101b45760406003193601126101b45761153b611b2c565b602435908115158092036101b45773ffffffffffffffffffffffffffffffffffffffff90335f525f60205260405f208282165f5260205260405f207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0081541660ff851617905560405192835216907fceb576d9f15e4e200fdb5096d64d5dfd667e16def20c1eefd14256d8e3faa26760203392a3602060405160018152f35b60206003193601126101b4576115ee611b2c565b73ffffffffffffffffffffffffffffffffffffffff7fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d70548061163c575b16156103b7576101ac602091612188565b600160ff1b1861162b565b346101b4575f6003193601126101b4576040611661612280565b73ffffffffffffffffffffffffffffffffffffffff8351921682526020820152f35b346101b45760406003193601126101b45761169c611b2c565b73ffffffffffffffffffffffffffffffffffffffff6116b9611b4f565b91165f52600660205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f52602052602060405f2054604051908152f35b346101b45760406003193601126101b457602061170c611b2c565b611714611b4f565b73ffffffffffffffffffffffffffffffffffffffff6040519181858401941684521660408201527fb15a985351e7fec20c5ab24bbbbeccb6443ba2a83f05cd1411825d064d91cf43606082015260608152611770608082611cbb565b519020548061151757604051908152f35b346101b45760206003193601126101b45773ffffffffffffffffffffffffffffffffffffffff6117af611b2c565b6117b761225f565b16805f52600560205260405f2060017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff008254161790557f0d540ad8f39e07d19909687352b9fa017405d93c91a6760981fbae9cf28bfef75f80a2005b346101b45760806003193601126101b45761182c611b2c565b611834611b4f565b61183c611b72565b907f5b21a3c624a398df3917a0a930f91e3837519b8eab3302b834746433065f295973ffffffffffffffffffffffffffffffffffffffff80806064359616938433141580611974575b6118f2575b845f52600160205260405f208287165f5260205260405f206118ad888254611c2d565b90551693845f52600160205260405f208282165f5260205260405f206118d4878254611c67565b905560408051338152602081019790975291169490819081016107fb565b845f52600260205260405f208233165f5260205260405f208287165f526020527fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff60405f2054031561188a57845f52600260205260405f208233165f5260205260405f208287165f5260205260405f2061196d888254611c2d565b905561188a565b50845f525f60205260405f208233165f5260205260ff60405f20541615611885565b5f6003193601126101b45773ffffffffffffffffffffffffffffffffffffffff7fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d7054806119ef575b16156103b75760206101ac33612188565b600160ff1b186119de565b346101b45760606003193601126101b457611a13611b2c565b611a1b611b4f565b6044359073ffffffffffffffffffffffffffffffffffffffff7fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d705480611a83575b16156103b75761052292611a7e611a7284611cfc565b5f03600f0b8233611d27565b611f53565b600160ff1b18611a5c565b346101b45760206003193601126101b457600435907fffffffff0000000000000000000000000000000000000000000000000000000082168092036101b457817f01ffc9a70000000000000000000000000000000000000000000000000000000060209314908115611b02575b5015158152f35b7fb2e69f8a0000000000000000000000000000000000000000000000000000000091501483611afb565b6004359073ffffffffffffffffffffffffffffffffffffffff821682036101b457565b6024359073ffffffffffffffffffffffffffffffffffffffff821682036101b457565b6044359073ffffffffffffffffffffffffffffffffffffffff821682036101b457565b6064359073ffffffffffffffffffffffffffffffffffffffff821682036101b457565b5f5b838110611bc95750505f910152565b8181015183820152602001611bba565b60031960609101126101b45760043573ffffffffffffffffffffffffffffffffffffffff811681036101b4579060243573ffffffffffffffffffffffffffffffffffffffff811681036101b4579060443590565b91908203918211611c3a57565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52601160045260245ffd5b91908201809211611c3a57565b90600f0b90600f0b01907fffffffffffffffffffffffffffffffff8000000000000000000000000000000082126f7fffffffffffffffffffffffffffffff831317611c3a57565b90601f7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0910116810190811067ffffffffffffffff821117610ff557604052565b6f80000000000000000000000000000000811015611d1a57600f0b90565b6393dafdf15f526004601cfd5b9190918115611f4e57611d3a8382612456565b8281019283125f8212908015821691151617611c3a5782611e8c57507fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d705480611e81575b73ffffffffffffffffffffffffffffffffffffffff7f7fffffffffffffffffffffff00000000000000000000000000000000000000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8360a01c0160a01b1691161792600160ff1b841461097257600160ff1b611e7f94187fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d70555b73ffffffffffffffffffffffffffffffffffffffff604051918160208401941684521660408201527f6dc13502b9ba2a9e8e42c53a1856d632b29d5aab3bcb4a2476bfec06cbd9cf22606082015260608152611e77608082611cbb565b51902061259e565b565b600160ff1b18611d7e565b15611e9b575b611e7f92611e1a565b7fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d705480611f43575b73ffffffffffffffffffffffffffffffffffffffff7f7fffffffffffffffffffffff000000000000000000000000000000000000000060018360a01c0160a01b1691161792600160ff1b841461097257600160ff1b939093187fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d7055611e92565b600160ff1b18611ec3565b505050565b90919073ffffffffffffffffffffffffffffffffffffffff811690816120455750505f80808093855af115611f855750565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f3d011673ffffffffffffffffffffffffffffffffffffffff604051927f90bfb8650000000000000000000000000000000000000000000000000000000084521660048301525f6024830152608060448301528060a00160648301523d60848301523d5f60a484013e7ff4b3b1bc0000000000000000000000000000000000000000000000000000000060c4828401600460a4820152015260e40190fd5b60205f60448194968260409573ffffffffffffffffffffffffffffffffffffffff988751998a947fa9059cbb00000000000000000000000000000000000000000000000000000000865216600485015260248401525af13d15601f3d116001855114161716928281528260208201520152156120be5750565b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f3d0116604051917f90bfb86500000000000000000000000000000000000000000000000000000000835260048301527fa9059cbb000000000000000000000000000000000000000000000000000000006024830152608060448301528060a00160648301523d60848301523d5f60a484013e7ff27f64e40000000000000000000000000000000000000000000000000000000060c4828401600460a4820152015260e40190fd5b90612191612280565b909273ffffffffffffffffffffffffffffffffffffffff841615612253573461222b576121c9611e7f926121c486612507565b611c2d565b93600160ff1b7f52a1be34b47478d7c75e2b6c3eea1e05dcb8dbb8c6a42c6482d0dca0df53cb2755600160ff1b7fb0879d96d58bcff08d1fd45590200072d5a8c380da0b5aa1052b48b84e115207555b61222285611cfc565b600f0b91611d27565b7f11e56171000000000000000000000000000000000000000000000000000000005f5260045ffd5b611e7f91503493612219565b73ffffffffffffffffffffffffffffffffffffffff6003541633036111f957565b73ffffffffffffffffffffffffffffffffffffffff7f52a1be34b47478d7c75e2b6c3eea1e05dcb8dbb8c6a42c6482d0dca0df53cb2754806122f2575b16907fb0879d96d58bcff08d1fd45590200072d5a8c380da0b5aa1052b48b84e11520754806122e95790565b600160ff1b1890565b600160ff1b186122bd565b81600f0b8015611f4e575f81126123c85750335f52600660205260405f2073ffffffffffffffffffffffffffffffffffffffff82165f526020526fffffffffffffffffffffffffffffffff60405f2054921690818310155f1461238c57335f52600660205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f5260205260405f2091039055565b9091611e7f92335f52600660205260405f2073ffffffffffffffffffffffffffffffffffffffff84165f526020525f604081205503903361271d565b9091507fffffffffffffffffffffffffffffffff800000000000000000000000000000008114611c3a576fffffffffffffffffffffffffffffffff612411915f031682336125b4565b908161241b575050565b335f52600660205273ffffffffffffffffffffffffffffffffffffffff60405f2091165f5260205261245260405f20918254611c67565b9055565b9073ffffffffffffffffffffffffffffffffffffffff604051918160208401941684521660408201527f6dc13502b9ba2a9e8e42c53a1856d632b29d5aab3bcb4a2476bfec06cbd9cf226060820152606081526124b4608082611cbb565b51902054806122e95790565b7fedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d7054806124fc575b60a01c6b7fffffffffffffffffffffff1690565b600160ff1b186124e8565b73ffffffffffffffffffffffffffffffffffffffff168061252757504790565b6020602491604051928380927f70a082310000000000000000000000000000000000000000000000000000000082523060048301525afa908115611022575f9161256f575090565b90506020813d602011612596575b8161258a60209383611cbb565b810103126101b4575190565b3d915061257d565b90600160ff1b811461097257600160ff1b189055565b9291925f917f8441ca20eb4e3f4809b32435cc73fbff7fb24d1abccd9553e242325f6e57cdb95480612712575b15611f4e5773ffffffffffffffffffffffffffffffffffffffff604051918160208401941684521660408201527fb15a985351e7fec20c5ab24bbbbeccb6443ba2a83f05cd1411825d064d91cf43606082015260608152612643608082611cbb565b5190209283549182612705575b82156126ff578282106126f2575090600160ff1b910392557fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff7f8441ca20eb4e3f4809b32435cc73fbff7fb24d1abccd9553e242325f6e57cdb954806126e7575b01600160ff1b811461097257600160ff1b187f8441ca20eb4e3f4809b32435cc73fbff7fb24d1abccd9553e242325f6e57cdb955565b600160ff1b186126b1565b9390611e7f92039061259e565b50925050565b91600160ff1b1891612650565b600160ff1b186125e1565b908215611f4e5773ffffffffffffffffffffffffffffffffffffffff604051918160208401941684521660408201527fb15a985351e7fec20c5ab24bbbbeccb6443ba2a83f05cd1411825d064d91cf43606082015260608152612781608082611cbb565b51902080549182612819575b82156127a7575b6127a190611e7f93611c67565b9061259e565b60017f8441ca20eb4e3f4809b32435cc73fbff7fb24d1abccd9553e242325f6e57cdb9548061280e575b0190600160ff1b821461097257600160ff1b919091187f8441ca20eb4e3f4809b32435cc73fbff7fb24d1abccd9553e242325f6e57cdb955612794565b600160ff1b186127d1565b91600160ff1b189161278d56fea164736f6c634300081a000a