ETH Price: $2,227.18 (-3.04%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

More Info

Private Name Tags

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

Advanced mode:
Parent Transaction Hash Method Block
From
To
View All Internal Transactions

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Validator Index Block Amount
View All Withdrawals

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

Contract Source Code Verified (Exact Match)

Contract Name:
ConvertiblesDVLens

Compiler Version
v0.8.13+commit.abaa5c0e

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.13;

import "../interfaces/IConvertiblesDVLens.sol";
import "../interfaces/IConvertibleBondBox.sol";
import "../../src/contracts/external/ERC20.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";

/**
 * @dev View functions only - for front-end use
 */

contract ConvertiblesDVLens is IConvertiblesDVLens {
    struct DecimalPair {
        uint256 tranche;
        uint256 stable;
    }

    struct CollateralBalance {
        uint256 safe;
        uint256 risk;
    }

    struct StagingBalances {
        uint256 safeTranche;
        uint256 riskTranche;
        uint256 safeSlip;
        uint256 riskSlip;
        uint256 stablesBorrow;
        uint256 stablesLend;
        uint256 stablesTotal;
    }

    function viewStagingStatsIBO(IStagingBox _stagingBox)
        external
        view
        returns (StagingDataIBO memory)
    {
        (
            IConvertibleBondBox convertibleBondBox,
            IBondController bond
        ) = fetchElasticStack(_stagingBox);
        CollateralBalance memory simTrancheCollateral = calcTrancheCollateral(
            convertibleBondBox,
            bond,
            _stagingBox.safeTranche().balanceOf(address(_stagingBox)),
            _stagingBox.riskTranche().balanceOf(address(_stagingBox))
        );
        uint256 stableBalance = _stagingBox.stableToken().balanceOf(
            address(_stagingBox)
        );

        DecimalPair memory decimals = DecimalPair(
            ERC20(address(_stagingBox.safeTranche())).decimals(),
            ERC20(address(_stagingBox.stableToken())).decimals()
        );

        StagingDataIBO memory data = StagingDataIBO(
            NumFixedPoint(
                _stagingBox.lendSlip().totalSupply(),
                decimals.stable
            ),
            NumFixedPoint(
                _stagingBox.borrowSlip().totalSupply(),
                decimals.stable
            ),
            NumFixedPoint(
                _stagingBox.safeTranche().balanceOf(address(_stagingBox)),
                decimals.tranche
            ),
            NumFixedPoint(
                _stagingBox.riskTranche().balanceOf(address(_stagingBox)),
                decimals.tranche
            ),
            NumFixedPoint(stableBalance, decimals.stable),
            NumFixedPoint(simTrancheCollateral.safe, decimals.tranche),
            NumFixedPoint(simTrancheCollateral.risk, decimals.tranche),
            NumFixedPoint(
                (simTrancheCollateral.safe + simTrancheCollateral.risk),
                decimals.tranche
            ),
            NumFixedPoint(stableBalance, decimals.stable)
        );

        return data;
    }

    function viewStagingStatsActive(IStagingBox _stagingBox)
        external
        view
        returns (StagingDataActive memory)
    {
        (
            IConvertibleBondBox convertibleBondBox,
            IBondController bond
        ) = fetchElasticStack(_stagingBox);
        CollateralBalance memory simTrancheCollateral = calcTrancheCollateral(
            convertibleBondBox,
            bond,
            _stagingBox.safeTranche().balanceOf(address(_stagingBox)),
            _stagingBox.riskTranche().balanceOf(address(_stagingBox))
        );
        CollateralBalance memory simSlipCollateral = calcTrancheCollateral(
            convertibleBondBox,
            bond,
            convertibleBondBox.safeSlip().balanceOf(address(_stagingBox)),
            convertibleBondBox.riskSlip().balanceOf(address(_stagingBox))
        );

        DecimalPair memory decimals = DecimalPair(
            ERC20(address(_stagingBox.safeTranche())).decimals(),
            ERC20(address(_stagingBox.stableToken())).decimals()
        );

        StagingBalances memory SB_Balances = StagingBalances(
            _stagingBox.safeTranche().balanceOf(address(_stagingBox)),
            _stagingBox.riskTranche().balanceOf(address(_stagingBox)),
            _stagingBox.convertibleBondBox().safeSlip().balanceOf(
                address(_stagingBox)
            ),
            _stagingBox.convertibleBondBox().riskSlip().balanceOf(
                address(_stagingBox)
            ),
            _stagingBox.s_reinitLendAmount(),
            _stagingBox.stableToken().balanceOf(address(_stagingBox)) -
                _stagingBox.s_reinitLendAmount(),
            _stagingBox.stableToken().balanceOf(address(_stagingBox))
        );

        StagingDataActive memory data = StagingDataActive(
            NumFixedPoint(
                _stagingBox.lendSlip().totalSupply(),
                decimals.stable
            ),
            NumFixedPoint(
                _stagingBox.borrowSlip().totalSupply(),
                decimals.stable
            ),
            NumFixedPoint(SB_Balances.safeTranche, decimals.tranche),
            NumFixedPoint(SB_Balances.riskTranche, decimals.tranche),
            NumFixedPoint(SB_Balances.safeSlip, decimals.tranche),
            NumFixedPoint(SB_Balances.riskSlip, decimals.tranche),
            NumFixedPoint(SB_Balances.stablesBorrow, decimals.stable),
            NumFixedPoint(SB_Balances.stablesLend, decimals.stable),
            NumFixedPoint(simTrancheCollateral.safe, decimals.tranche),
            NumFixedPoint(simTrancheCollateral.risk, decimals.tranche),
            NumFixedPoint(simSlipCollateral.safe, decimals.tranche),
            NumFixedPoint(simSlipCollateral.risk, decimals.tranche),
            NumFixedPoint(
                ((simTrancheCollateral.safe +
                    simTrancheCollateral.risk +
                    simSlipCollateral.risk) *
                    10**decimals.stable +
                    _stagingBox.s_reinitLendAmount() *
                    10**decimals.tranche),
                decimals.tranche + decimals.stable
            ),
            NumFixedPoint(
                (SB_Balances.stablesLend) +
                    (SB_Balances.safeSlip *
                        convertibleBondBox.currentPrice() *
                        (10**decimals.stable)) /
                    convertibleBondBox.s_priceGranularity() /
                    (10**decimals.tranche),
                decimals.stable
            )
        );
        return data;
    }

    function viewCBBStatsActive(IConvertibleBondBox _convertibleBondBox)
        external
        view
        returns (CBBDataActive memory)
    {
        CollateralBalance memory simTrancheCollateral = calcTrancheCollateral(
            _convertibleBondBox,
            _convertibleBondBox.bond(),
            _convertibleBondBox.safeTranche().balanceOf(
                address(_convertibleBondBox)
            ),
            _convertibleBondBox.riskTranche().balanceOf(
                address(_convertibleBondBox)
            )
        );
        uint256 stableBalance = _convertibleBondBox.stableToken().balanceOf(
            address(_convertibleBondBox)
        );

        DecimalPair memory decimals = DecimalPair(
            ERC20(address(_convertibleBondBox.safeTranche())).decimals(),
            ERC20(address(_convertibleBondBox.stableToken())).decimals()
        );

        CBBDataActive memory data = CBBDataActive(
            NumFixedPoint(
                _convertibleBondBox.safeSlip().totalSupply(),
                decimals.tranche
            ),
            NumFixedPoint(
                _convertibleBondBox.riskSlip().totalSupply(),
                decimals.tranche
            ),
            NumFixedPoint(
                _convertibleBondBox.s_repaidSafeSlips(),
                decimals.tranche
            ),
            NumFixedPoint(
                _convertibleBondBox.safeTranche().balanceOf(
                    address(_convertibleBondBox)
                ),
                decimals.tranche
            ),
            NumFixedPoint(
                _convertibleBondBox.riskTranche().balanceOf(
                    address(_convertibleBondBox)
                ),
                decimals.tranche
            ),
            NumFixedPoint(stableBalance, decimals.stable),
            NumFixedPoint(simTrancheCollateral.safe, decimals.tranche),
            NumFixedPoint(simTrancheCollateral.risk, decimals.tranche),
            NumFixedPoint(
                _convertibleBondBox.currentPrice(),
                _convertibleBondBox.s_priceGranularity()
            ),
            NumFixedPoint(simTrancheCollateral.risk, decimals.tranche),
            NumFixedPoint(
                (simTrancheCollateral.safe *
                    (10**decimals.stable) +
                    stableBalance *
                    (10**decimals.tranche)),
                decimals.tranche + decimals.stable
            )
        );

        return data;
    }

    function viewCBBStatsMature(IConvertibleBondBox _convertibleBondBox)
        external
        view
        returns (CBBDataMature memory)
    {
        CollateralBalance memory simTrancheCollateral = calcTrancheCollateral(
            _convertibleBondBox,
            _convertibleBondBox.bond(),
            _convertibleBondBox.safeTranche().balanceOf(
                address(_convertibleBondBox)
            ),
            _convertibleBondBox.riskTranche().balanceOf(
                address(_convertibleBondBox)
            )
        );
        uint256 stableBalance = _convertibleBondBox.stableToken().balanceOf(
            address(_convertibleBondBox)
        );

        uint256 riskTrancheBalance = _convertibleBondBox
            .riskTranche()
            .balanceOf(address(_convertibleBondBox));

        uint256 zPenaltyTrancheCollateral = ((riskTrancheBalance -
            _convertibleBondBox.riskSlip().totalSupply()) *
            simTrancheCollateral.risk) / riskTrancheBalance;

        DecimalPair memory decimals = DecimalPair(
            ERC20(address(_convertibleBondBox.safeTranche())).decimals(),
            ERC20(address(_convertibleBondBox.stableToken())).decimals()
        );

        CBBDataMature memory data = CBBDataMature(
            NumFixedPoint(
                _convertibleBondBox.safeSlip().totalSupply(),
                decimals.tranche
            ),
            NumFixedPoint(
                _convertibleBondBox.riskSlip().totalSupply(),
                decimals.tranche
            ),
            NumFixedPoint(
                _convertibleBondBox.s_repaidSafeSlips(),
                decimals.tranche
            ),
            NumFixedPoint(
                _convertibleBondBox.safeTranche().balanceOf(
                    address(_convertibleBondBox)
                ),
                decimals.tranche
            ),
            NumFixedPoint(
                _convertibleBondBox.riskSlip().totalSupply(),
                decimals.tranche
            ),
            NumFixedPoint(
                (riskTrancheBalance -
                    _convertibleBondBox.riskSlip().totalSupply()),
                decimals.tranche
            ),
            NumFixedPoint(stableBalance, decimals.stable),
            NumFixedPoint(simTrancheCollateral.safe, decimals.tranche),
            NumFixedPoint(
                (_convertibleBondBox.riskSlip().totalSupply() *
                    simTrancheCollateral.risk) / riskTrancheBalance,
                decimals.tranche
            ),
            NumFixedPoint(zPenaltyTrancheCollateral, decimals.tranche),
            NumFixedPoint(
                _convertibleBondBox.currentPrice(),
                _convertibleBondBox.s_priceGranularity()
            ),
            NumFixedPoint(
                simTrancheCollateral.risk - zPenaltyTrancheCollateral,
                decimals.tranche
            ),
            NumFixedPoint(
                (simTrancheCollateral.safe + zPenaltyTrancheCollateral) *
                    10**decimals.stable +
                    stableBalance *
                    10**decimals.tranche,
                decimals.stable + decimals.tranche
            )
        );

        return data;
    }

    function calcTrancheCollateral(
        IConvertibleBondBox convertibleBondBox,
        IBondController bond,
        uint256 safeTrancheAmount,
        uint256 riskTrancheAmount
    ) internal view returns (CollateralBalance memory) {
        uint256 riskTrancheCollateral = 0;
        uint256 safeTrancheCollateral = 0;

        uint256 collateralBalance = convertibleBondBox
            .collateralToken()
            .balanceOf(address(bond));

        if (collateralBalance > 0) {
            if (bond.isMature()) {
                riskTrancheCollateral = convertibleBondBox
                    .collateralToken()
                    .balanceOf(address(convertibleBondBox.riskTranche()));

                safeTrancheCollateral = convertibleBondBox
                    .collateralToken()
                    .balanceOf(address(convertibleBondBox.safeTranche()));
            } else {
                for (
                    uint256 i = 0;
                    i < bond.trancheCount() - 1 && collateralBalance > 0;
                    i++
                ) {
                    (ITranche tranche, ) = bond.tranches(i);
                    uint256 amount = Math.min(
                        tranche.totalSupply(),
                        collateralBalance
                    );
                    collateralBalance -= amount;

                    if (i == convertibleBondBox.trancheIndex()) {
                        safeTrancheCollateral = amount;
                    }
                }

                riskTrancheCollateral = collateralBalance;
            }

            safeTrancheCollateral =
                (safeTrancheCollateral * safeTrancheAmount) /
                convertibleBondBox.safeTranche().totalSupply();

            riskTrancheCollateral =
                (riskTrancheCollateral * riskTrancheAmount) /
                convertibleBondBox.riskTranche().totalSupply();
        }

        CollateralBalance memory collateral = CollateralBalance(
            safeTrancheCollateral,
            riskTrancheCollateral
        );

        return collateral;
    }

    function fetchElasticStack(IStagingBox _stagingBox)
        internal
        view
        returns (IConvertibleBondBox, IBondController)
    {
        IConvertibleBondBox convertibleBondBox = _stagingBox
            .convertibleBondBox();
        IBondController bond = convertibleBondBox.bond();
        return (convertibleBondBox, bond);
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;

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

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

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

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

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

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

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

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

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

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

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

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

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

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

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

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

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`.
        // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`.
        // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`.
        // Using an algorithm similar to the msb computation, we are able to compute `result = 2**(k/2)` which is a
        // good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1;
        uint256 x = a;
        if (x >> 128 > 0) {
            x >>= 128;
            result <<= 64;
        }
        if (x >> 64 > 0) {
            x >>= 64;
            result <<= 32;
        }
        if (x >> 32 > 0) {
            x >>= 32;
            result <<= 16;
        }
        if (x >> 16 > 0) {
            x >>= 16;
            result <<= 8;
        }
        if (x >> 8 > 0) {
            x >>= 8;
            result <<= 4;
        }
        if (x >> 4 > 0) {
            x >>= 4;
            result <<= 2;
        }
        if (x >> 2 > 0) {
            result <<= 1;
        }

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        uint256 result = sqrt(a);
        if (rounding == Rounding.Up && result * result < a) {
            result += 1;
        }
        return result;
    }
}

// SPDX-License-Identifier: GPL-3.0-or-later

pragma solidity >=0.6.0;

// helper methods for interacting with ERC20 tokens and sending ETH that do not consistently return true/false
library TransferHelper {
    function safeApprove(
        address token,
        address to,
        uint256 value
    ) internal {
        // bytes4(keccak256(bytes('approve(address,uint256)')));
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x095ea7b3, to, value));
        require(
            success && (data.length == 0 || abi.decode(data, (bool))),
            'TransferHelper::safeApprove: approve failed'
        );
    }

    function safeTransfer(
        address token,
        address to,
        uint256 value
    ) internal {
        // bytes4(keccak256(bytes('transfer(address,uint256)')));
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0xa9059cbb, to, value));
        require(
            success && (data.length == 0 || abi.decode(data, (bool))),
            'TransferHelper::safeTransfer: transfer failed'
        );
    }

    function safeTransferFrom(
        address token,
        address from,
        address to,
        uint256 value
    ) internal {
        // bytes4(keccak256(bytes('transferFrom(address,address,uint256)')));
        (bool success, bytes memory data) = token.call(abi.encodeWithSelector(0x23b872dd, from, to, value));
        require(
            success && (data.length == 0 || abi.decode(data, (bool))),
            'TransferHelper::transferFrom: transferFrom failed'
        );
    }

    function safeTransferETH(address to, uint256 value) internal {
        (bool success, ) = to.call{value: value}(new bytes(0));
        require(success, 'TransferHelper::safeTransferETH: ETH transfer failed');
    }
}

pragma solidity ^0.8.3;

import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@uniswap/lib/contracts/libraries/TransferHelper.sol";
import "./ITranche.sol";

struct TrancheData {
    ITranche token;
    uint256 ratio;
}

/**
 * @dev Controller for a ButtonTranche bond system
 */
interface IBondController {
    event Deposit(address from, uint256 amount, uint256 feeBps);
    event Mature(address caller);
    event RedeemMature(address user, address tranche, uint256 amount);
    event Redeem(address user, uint256[] amounts);
    event FeeUpdate(uint256 newFee);

    function collateralToken() external view returns (address);

    function tranches(uint256 i) external view returns (ITranche token, uint256 ratio);

    function trancheCount() external view returns (uint256 count);

    function feeBps() external view returns (uint256 fee);

    function maturityDate() external view returns (uint256 maturityDate);

    function isMature() external view returns (bool isMature);

    function creationDate() external view returns (uint256 creationDate);

    function totalDebt() external view returns (uint256 totalDebt);

    /**
     * @dev Deposit `amount` tokens from `msg.sender`, get tranche tokens in return
     * Requirements:
     *  - `msg.sender` must have `approved` `amount` collateral tokens to this contract
     */
    function deposit(uint256 amount) external;

    /**
     * @dev Matures the bond. Disables deposits,
     * fixes the redemption ratio, and distributes collateral to redemption pools
     * Redeems any fees collected from deposits, sending redeemed funds to the contract owner
     * Requirements:
     *  - The bond is not already mature
     *  - One of:
     *      - `msg.sender` is owner
     *      - `maturityDate` has passed
     */
    function mature() external;

    /**
     * @dev Redeems some tranche tokens
     * Requirements:
     *  - The bond is mature
     *  - `msg.sender` owns at least `amount` tranche tokens from address `tranche`
     *  - `tranche` must be a valid tranche token on this bond
     */
    function redeemMature(address tranche, uint256 amount) external;

    /**
     * @dev Redeems a slice of tranche tokens from all tranches.
     *  Returns collateral to the user proportionally to the amount of debt they are removing
     * Requirements
     *  - The bond is not mature
     *  - The number of `amounts` is the same as the number of tranches
     *  - The `amounts` are in equivalent ratio to the tranche order
     */
    function redeem(uint256[] memory amounts) external;

    /**
     * @dev Updates the fee taken on deposit to the given new fee
     *
     * Requirements
     * - `msg.sender` has admin role
     * - `newFeeBps` is in range [0, 50]
     */
    function setFee(uint256 newFeeBps) external;
}

pragma solidity ^0.8.3;

import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@uniswap/lib/contracts/libraries/TransferHelper.sol";

/**
 * @dev ERC20 token to represent a single tranche for a ButtonTranche bond
 *
 */
interface ITranche is IERC20 {
    /**
     * @dev returns the BondController address which owns this Tranche contract
     *  It should have admin permissions to call mint, burn, and redeem functions
     */
    function bond() external view returns (address);

    /**
     * @dev Mint `amount` tokens to `to`
     *  Only callable by the owner (bond controller). Used to
     *  manage bonds, specifically creating tokens upon deposit
     * @param to the address to mint tokens to
     * @param amount The amount of tokens to mint
     */
    function mint(address to, uint256 amount) external;

    /**
     * @dev Burn `amount` tokens from `from`'s balance
     *  Only callable by the owner (bond controller). Used to
     *  manage bonds, specifically burning tokens upon redemption
     * @param from The address to burn tokens from
     * @param amount The amount of tokens to burn
     */
    function burn(address from, uint256 amount) external;

    /**
     * @dev Burn `amount` tokens from `from` and return the proportional
     * value of the collateral token to `to`
     * @param from The address to burn tokens from
     * @param to The address to send collateral back to
     * @param amount The amount of tokens to burn
     */
    function redeem(
        address from,
        address to,
        uint256 amount
    ) external;
}

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/utils/Context.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin guidelines: functions revert instead
 * of returning `false` on failure. This behavior is nonetheless conventional
 * and does not conflict with the expectations of ERC20 applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20 is Context, IERC20 {
    mapping(address => uint256) private _balances;

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

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The defaut value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The defaut value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All three of these values are immutable: they can only be set once during
     * construction.
     */
    function init(string memory name_, string memory symbol_) public {
        _name = name_;
        _symbol = symbol_;
    }

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

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

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

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

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

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

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

    /**
     * @dev See {IERC20-approve}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address sender,
        address recipient,
        uint256 amount
    ) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);

        uint256 currentAllowance = _allowances[sender][_msgSender()];
        require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
        _approve(sender, _msgSender(), currentAllowance - amount);

        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][spender] + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        uint256 currentAllowance = _allowances[_msgSender()][spender];
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        _approve(_msgSender(), spender, currentAllowance - subtractedValue);

        return true;
    }

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(
        address sender,
        address recipient,
        uint256 amount
    ) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        uint256 senderBalance = _balances[sender];
        require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
        _balances[sender] = senderBalance - amount;
        _balances[recipient] += amount;

        emit Transfer(sender, recipient, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        _balances[account] += amount;
        emit Transfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        _balances[account] = accountBalance - amount;
        _totalSupply -= amount;

        emit Transfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be to transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}
}

//SPDX-License-Identifier: Unlicense
pragma solidity 0.8.13;

import "../../utils/ICBBImmutableArgs.sol";

/**
 * @dev Convertible Bond Box for a ButtonTranche bond
 */

interface IConvertibleBondBox is ICBBImmutableArgs {
    event Lend(
        address caller,
        address borrower,
        address lender,
        uint256 stableAmount,
        uint256 price
    );
    event Borrow(
        address caller,
        address borrower,
        address lender,
        uint256 stableAmount,
        uint256 price
    );
    event RedeemStable(address caller, uint256 safeSlipAmount, uint256 price);
    event RedeemSafeTranche(address caller, uint256 safeSlipAmount);
    event RedeemRiskTranche(address caller, uint256 riskSlipAmount);
    event Repay(
        address caller,
        uint256 stablesPaid,
        uint256 riskTranchePayout,
        uint256 price
    );
    event Initialized(address owner);
    event ReInitialized(uint256 initialPrice, uint256 timestamp);
    event FeeUpdate(uint256 newFee);

    error PenaltyTooHigh(uint256 given, uint256 maxPenalty);
    error BondIsMature(uint256 currentTime, uint256 maturity);
    error InitialPriceTooHigh(uint256 given, uint256 maxPrice);
    error InitialPriceIsZero(uint256 given, uint256 maxPrice);
    error ConvertibleBondBoxNotStarted(uint256 given, uint256 minStartDate);
    error BondNotMatureYet(uint256 maturityDate, uint256 currentTime);
    error MinimumInput(uint256 input, uint256 reqInput);
    error FeeTooLarge(uint256 input, uint256 maximum);

    //Need to add getters for state variables

    /**
     * @dev Sets startdate to be block.timestamp, sets initialPrice, and takes initial atomic deposit
     * @param _initialPrice the initialPrice for the CBB
     * Requirements:
     *  - `msg.sender` is owner
     */

    function reinitialize(uint256 _initialPrice) external;

    /**
     * @dev Lends StableTokens for SafeSlips when provided with matching borrow collateral
     * @param _borrower The address to send the RiskSlip and StableTokens to 
     * @param _lender The address to send the SafeSlips to 
     * @param _stableAmount The amount of StableTokens to lend
     * Requirements:
     *  - `msg.sender` must have `approved` `_stableAmount` stable tokens to this contract
        - CBB must be reinitialized
     */

    function lend(
        address _borrower,
        address _lender,
        uint256 _stableAmount
    ) external;

    /**
     * @dev Borrows with tranches of CollateralTokens when provided with a matching amount of StableTokens
     * Collateral tokens get tranched and any non-convertible bond box tranches get sent back to borrower 
     * @param _borrower The address to send the RiskSlip and StableTokens to 
     * @param _lender The address to send the SafeSlips to 
     * @param _safeTrancheAmount The amount of SafeTranche being borrowed against
     * Requirements:
     *  - `msg.sender` must have `approved` appropriate amount of tranches of tokens to this contract
        - CBB must be reinitialized
        - must be enough stable tokens inside convertible bond box to borrow 
     */

    function borrow(
        address _borrower,
        address _lender,
        uint256 _safeTrancheAmount
    ) external;

    /**
     * @dev returns time-weighted current price for SafeSlip, with final price as $1.00 at maturity
     */

    function currentPrice() external view returns (uint256);

    /**
     * @dev allows repayment of loan in exchange for proportional amount of SafeTranche and Z-tranche
     * @param _stableAmount The amount of stable-Tokens to repay with
     * Requirements:
     *  - `msg.sender` must have `approved` `stableAmount` of stable tokens to this contract
     */

    function repay(uint256 _stableAmount) external;

    /**
     * @dev allows repayment of loan in exchange for proportional amount of SafeTranche and Z-tranche
     * @param _riskSlipAmount The amount of riskSlips to be repaid
     * Requirements:
     *  - `msg.sender` must have `approved` appropriate amount of stable tokens to this contract
     */

    function repayMax(uint256 _riskSlipAmount) external;

    /**
     * @dev allows lender to redeem SafeSlips for SafeTranches
     * @param _safeSlipAmount The amount of safe-slips to redeem
     * Requirements:
     *  - can only be called after Bond is Mature
     *  - `msg.sender` must have `approved` `safeSlipAmount` of SafeSlip tokens to this contract
     */

    function redeemSafeTranche(uint256 _safeSlipAmount) external;

    /**
     * @dev allows borrower to redeem RiskSlips for tranches (i.e. default)
     * @param _riskSlipAmount The amount of RiskSlips to redeem
     * Requirements:
     *  - can only be called after Bond is Mature
     *  - `msg.sender` must have `approved` `_riskSlipAmount` of RiskSlip tokens to this contract
     */

    function redeemRiskTranche(uint256 _riskSlipAmount) external;

    /**
     * @dev allows lender to redeem SafeSlips for StableTokens
     * @param _safeSlipAmount The amount of SafeSlips to redeem
     * Requirements:
     *  - `msg.sender` must have `approved` `safeSlipAmount` of safe-Slip tokens to this contract
     *  - can only be called when StableTokens are present inside CBB
     */

    function redeemStable(uint256 _safeSlipAmount) external;

    /**
     * @dev Updates the fee taken on redeem/repay to the given new fee
     *
     * Requirements
     * - `msg.sender` has admin role
     * - `newFeeBps` is in range [0, 50]
     */

    function setFee(uint256 newFeeBps) external;

    /**
     * @dev Gets the start date
     */
    function s_startDate() external view returns (uint256);

    /**
     * @dev Gets the total repaid safe slips to date
     */
    function s_repaidSafeSlips() external view returns (uint256);

    /**
     * @dev Gets the tranche granularity constant
     */
    function s_trancheGranularity() external view returns (uint256);

    /**
     * @dev Gets the penalty granularity constant
     */
    function s_penaltyGranularity() external view returns (uint256);

    /**
     * @dev Gets the price granularity constant
     */
    function s_priceGranularity() external view returns (uint256);

    /**
     * @dev Gets the fee basis points
     */
    function feeBps() external view returns (uint256);

    /**
     * @dev Gets the basis points denominator constant. AKA a fee granularity constant
     */
    function BPS() external view returns (uint256);

    /**
     * @dev Gets the max fee basis points constant.
     */
    function maxFeeBPS() external view returns (uint256);

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) external;

    /**
     * @dev Gets the initialPrice of SafeSlip.
     */
    function s_initialPrice() external view returns (uint256);
}

// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.13;

import "../interfaces/IStagingBox.sol";
import "../interfaces/IConvertibleBondBox.sol";

struct NumFixedPoint {
    uint256 value;
    uint256 decimals;
}

struct StagingDataIBO {
    NumFixedPoint lendSlipSupply;
    NumFixedPoint borrowSlipSupply;
    NumFixedPoint safeTrancheBalance;
    NumFixedPoint riskTrancheBalance;
    NumFixedPoint stableTokenBalance;
    NumFixedPoint safeTrancheCollateral;
    NumFixedPoint riskTrancheCollateral;
    NumFixedPoint tvlBorrow;
    NumFixedPoint tvlLend;
}

struct StagingDataActive {
    NumFixedPoint lendSlipSupply;
    NumFixedPoint borrowSlipSupply;
    NumFixedPoint safeTrancheBalance;
    NumFixedPoint riskTrancheBalance;
    NumFixedPoint safeSlipBalance;
    NumFixedPoint riskSlipBalance;
    NumFixedPoint stableTokenBalanceBorrow;
    NumFixedPoint stableTokenBalanceLend;
    NumFixedPoint safeTrancheCollateral;
    NumFixedPoint riskTrancheCollateral;
    NumFixedPoint safeSlipCollateral;
    NumFixedPoint riskSlipCollateral;
    NumFixedPoint tvlBorrow;
    NumFixedPoint tvlLend;
}

struct CBBDataActive {
    NumFixedPoint safeSlipSupply;
    NumFixedPoint riskSlipSupply;
    NumFixedPoint repaidSafeSlips;
    NumFixedPoint safeTrancheBalance;
    NumFixedPoint riskTrancheBalance;
    NumFixedPoint stableTokenBalance;
    NumFixedPoint safeTrancheCollateral;
    NumFixedPoint riskTrancheCollateral;
    NumFixedPoint currentPrice;
    NumFixedPoint tvlBorrow;
    NumFixedPoint tvlLend;
}

struct CBBDataMature {
    NumFixedPoint safeSlipSupply;
    NumFixedPoint riskSlipSupply;
    NumFixedPoint repaidSafeSlips;
    NumFixedPoint safeTrancheBalance;
    NumFixedPoint riskTrancheBalance;
    NumFixedPoint zPenaltyTrancheBalance;
    NumFixedPoint stableTokenBalance;
    NumFixedPoint safeTrancheCollateral;
    NumFixedPoint riskTrancheCollateral;
    NumFixedPoint zPenaltyTrancheCollateral;
    NumFixedPoint currentPrice;
    NumFixedPoint tvlBorrow;
    NumFixedPoint tvlLend;
}

interface IConvertiblesDVLens {
    /**
     * @dev provides the stats for Staging Box in IBO period
     * @param _stagingBox The staging box tied to the Convertible Bond
     * Requirements:
     */

    function viewStagingStatsIBO(IStagingBox _stagingBox)
        external
        view
        returns (StagingDataIBO memory);

    /**
     * @dev provides the stats for StagingBox after the IBO is completed
     * @param _stagingBox The staging box tied to the Convertible Bond
     * Requirements:
     */

    function viewStagingStatsActive(IStagingBox _stagingBox)
        external
        view
        returns (StagingDataActive memory);

    /**
     * @dev provides the stats for CBB after IBO
     * @param _convertibleBondBox The CBB being queried
     * Requirements:
     */

    function viewCBBStatsActive(IConvertibleBondBox _convertibleBondBox)
        external
        view
        returns (CBBDataActive memory);

    /**
     * @dev provides the stats for CBB after maturity
     * @param _convertibleBondBox The CBB being queried
     * Requirements:
     */

    function viewCBBStatsMature(IConvertibleBondBox _convertibleBondBox)
        external
        view
        returns (CBBDataMature memory);
}

pragma solidity 0.8.13;

import "@openzeppelin/contracts/utils/Context.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

/**
 * @dev ERC20 token to represent a single slip for a bond box
 *
 */
interface ISlip is IERC20 {

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

    /**
     * @dev returns the bond box address which owns this slip contract
     *  It should have admin permissions to call mint, burn, and redeem functions
     */
    function boxOwner() external view returns (address);

    /**
     * @dev Mint `amount` tokens to `to`
     *  Only callable by the owner.
     * @param to the address to mint tokens to
     * @param amount The amount of tokens to mint
     */
    function mint(address to, uint256 amount) external;

    /**
     * @dev Burn `amount` tokens from `from`'s balance
     *  Only callable by the owner.
     * @param from The address to burn tokens from
     * @param amount The amount of tokens to burn
     */
    function burn(address from, uint256 amount) external;

    /**
     * @dev allows owner to transfer ownership to a new owner. Implemented so that factory can transfer minting/burning ability to CBB after deployment
     * @param newOwner The address of the CBB
     */
    function changeOwner(address newOwner) external;
}

// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.13;

import "../../utils/ISBImmutableArgs.sol";

interface IStagingBox is ISBImmutableArgs {
    event LendDeposit(address lender, uint256 lendAmount);
    event BorrowDeposit(address borrower, uint256 safeTrancheAmount);
    event LendWithdrawal(address lender, uint256 lendSlipAmount);
    event BorrowWithdrawal(address borrower, uint256 borrowSlipAmount);
    event RedeemBorrowSlip(address caller, uint256 borrowSlipAmount);
    event RedeemLendSlip(address caller, uint256 lendSlipAmount);
    event Initialized(address owner);

    error InitialPriceTooHigh(uint256 given, uint256 maxPrice);
    error InitialPriceIsZero(uint256 given, uint256 maxPrice);
    error WithdrawAmountTooHigh(uint256 requestAmount, uint256 maxAmount);
    error CBBReinitialized(bool state, bool requiredState);

    function s_reinitLendAmount() external view returns (uint256);

    /**
     * @dev Deposits collateral for BorrowSlips
     * @param _borrower The recipent address of the BorrowSlips
     * @param _borrowAmount The amount of stableTokens to be borrowed
     * Requirements:
     *  - `msg.sender` must have `approved` `stableAmount` stable tokens to this contract
     */

    function depositBorrow(address _borrower, uint256 _borrowAmount) external;

    /**
     * @dev deposit _lendAmount of stable-tokens for LendSlips
     * @param _lender The recipent address of the LenderSlips
     * @param _lendAmount The amount of stable tokens to deposit
     * Requirements:
     *  - `msg.sender` must have `approved` `stableAmount` stable tokens to this contract
     */

    function depositLend(address _lender, uint256 _lendAmount) external;

    /**
     * @dev Burns BorrowSlips for Collateral
     * @param _borrowSlipAmount The amount of borrowSlips to withdraw
     * Requirements:
     */

    function withdrawBorrow(uint256 _borrowSlipAmount) external;

    /**
     * @dev burns LendSlips for Stables
     * @param _lendSlipAmount The amount of stable tokens to withdraw
     * Requirements:
     * - Cannot withdraw more than s_reinitLendAmount after reinitialization
     */

    function withdrawLend(uint256 _lendSlipAmount) external;

    /**
     * @dev Exchanges BorrowSlips for RiskSlips + Stablecoin loan
     * @param _borrowSlipAmount amount of BorrowSlips to redeem RiskSlips and USDT with
     * Requirements:
     */

    function redeemBorrowSlip(uint256 _borrowSlipAmount) external;

    /**
     * @dev Exchanges lendSlips for safeSlips
     * @param _lendSlipAmount amount of LendSlips to redeem SafeSlips with
     * Requirements:
     */

    function redeemLendSlip(uint256 _lendSlipAmount) external;

    /**
     * @dev Transmits the the Reinitialization to the CBB
     * @param _lendOrBorrow boolean to indicate whether to initial deposit should be a 'borrow' or a 'lend'
     * Requirements:
     * - StagingBox must be the owner of the CBB to call this function
     * - Change owner of CBB to be the SB prior to calling this function if not already done
     */

    function transmitReInit(bool _lendOrBorrow) external;

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) external;

    /**
     * @dev Transfers ownership of the CBB contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferCBBOwnership(address newOwner) external;
}

// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.13;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../src/interfaces/ISlip.sol";
import "@buttonwood-protocol/tranche/contracts/interfaces/IBondController.sol";

interface ICBBImmutableArgs {
    /**
     * @notice The bond that holds the tranches
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The underlying buttonwood bond
     */
    function bond() external pure returns (IBondController);

    /**
     * @notice The safeSlip object
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The safeSlip Slip object
     */
    function safeSlip() external pure returns (ISlip);

    /**
     * @notice The riskSlip object
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The riskSlip Slip object
     */
    function riskSlip() external pure returns (ISlip);

    /**
     * @notice penalty for zslips
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The penalty ratio
     */
    function penalty() external pure returns (uint256);

    /**
     * @notice The rebasing collateral token used to make bonds
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The rebasing collateral token object
     */
    function collateralToken() external pure returns (IERC20);

    /**
     * @notice The stable token used to buy bonds
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The stable token object
     */
    function stableToken() external pure returns (IERC20);

    /**
     * @notice The tranche index used to pick a safe tranche
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The index representing the tranche
     */
    function trancheIndex() external pure returns (uint256);

    /**
     * @notice The maturity date of the underlying buttonwood bond
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The timestamp for the bond maturity
     */

    function maturityDate() external pure returns (uint256);

    /**
     * @notice The safeTranche of the Convertible Bond Box
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The safeTranche tranche object
     */

    function safeTranche() external pure returns (ITranche);

    /**
     * @notice The tranche ratio of the safeTranche
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The tranche ratio of the safeTranche
     */

    function safeRatio() external pure returns (uint256);

    /**
     * @notice The riskTranche of the Convertible Bond Box
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The riskTranche tranche object
     */

    function riskTranche() external pure returns (ITranche);

    /**
     * @notice The tranche ratio of the riskTranche
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The tranche ratio of the riskTranche
     */

    function riskRatio() external pure returns (uint256);

    /**
     * @notice The decimals of tranche-tokens
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The decimals of tranche-tokens
     */

    function trancheDecimals() external pure returns (uint256);

    /**
     * @notice The decimals of stable-tokens
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The decimals of stable-tokens
     */

    function stableDecimals() external pure returns (uint256);
}

// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.13;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "../src/interfaces/IConvertibleBondBox.sol";

interface ISBImmutableArgs {
    /**
     * @notice the lend slip object
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The lend slip object
     */
    function lendSlip() external pure returns (ISlip);

    /**
     * @notice the borrow slip object
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The borrowSlip object
     */
    function borrowSlip() external pure returns (ISlip);

    /**
     * @notice The convertible bond box object
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The convertible bond box object
     */
    function convertibleBondBox() external pure returns (IConvertibleBondBox);

    /**
     * @notice The cnnvertible bond box object
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The convertible bond box object
     */
    function initialPrice() external pure returns (uint256);

    /**
     * @notice The stable token used to buy bonds
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The stable token object
     */

    function stableToken() external pure returns (IERC20);

    /**
     * @notice The safeTranche of the CBB
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The safeTranche object
     */

    function safeTranche() external pure returns (ITranche);

    /**
     * @notice The address of the safeslip of the CBB
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The address of the safeslip of the CBB
     */

    function safeSlipAddress() external pure returns (address);

    /**
     * @notice The tranche ratio of the safeTranche
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The tranche ratio of the safeTranche of the CBB
     */

    function safeRatio() external pure returns (uint256);

    /**
     * @notice The riskTranche of the CBB
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The riskTranche tranche object
     */

    function riskTranche() external pure returns (ITranche);

    /**
     * @notice The address of the riskSlip of the CBB
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The address of the riskSlip of the CBB
     */

    function riskSlipAddress() external pure returns (address);

    /**
     * @notice The tranche ratio of the riskTranche
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The tranche ratio of the riskTranche of the CBB
     */

    function riskRatio() external pure returns (uint256);

    /**
     * @notice The price granularity on the CBB
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The price granularity on the CBB
     */

    function priceGranularity() external pure returns (uint256);

    /**
     * @notice The decimals of tranche-tokens
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The decimals of tranche-tokens
     */

    function trancheDecimals() external pure returns (uint256);

    /**
     * @notice The decimals of stable-tokens
     * @dev using ClonesWithImmutableArgs pattern here to save gas
     * @dev https://github.com/wighawag/clones-with-immutable-args
     * @return The decimals of stable-tokens
     */

    function stableDecimals() external pure returns (uint256);
}

Settings
{
  "remappings": [
    "@buttonwood-protocol/button-wrappers/=lib/button-wrappers/",
    "@buttonwood-protocol/tranche/=lib/tranche/",
    "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "@uniswap/lib/=lib/solidity-lib/",
    "button-wrappers/=lib/button-wrappers/contracts/",
    "clones-with-immutable-args/=lib/clones-with-immutable-args/src/",
    "ds-test/=lib/clones-with-immutable-args/lib/ds-test/src/",
    "forge-std/=lib/forge-std/src/",
    "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "solidity-lib/=lib/solidity-lib/contracts/",
    "solmate/=lib/solmate/src/",
    "tranche/=lib/tranche/contracts/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "london",
  "libraries": {}
}

Contract Security Audit

Contract ABI

API
[{"inputs":[{"internalType":"contract IConvertibleBondBox","name":"_convertibleBondBox","type":"address"}],"name":"viewCBBStatsActive","outputs":[{"components":[{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"safeSlipSupply","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"riskSlipSupply","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"repaidSafeSlips","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"safeTrancheBalance","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"riskTrancheBalance","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"stableTokenBalance","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"safeTrancheCollateral","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"riskTrancheCollateral","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"currentPrice","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"tvlBorrow","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"tvlLend","type":"tuple"}],"internalType":"struct CBBDataActive","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IConvertibleBondBox","name":"_convertibleBondBox","type":"address"}],"name":"viewCBBStatsMature","outputs":[{"components":[{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"safeSlipSupply","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"riskSlipSupply","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"repaidSafeSlips","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"safeTrancheBalance","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"riskTrancheBalance","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"zPenaltyTrancheBalance","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"stableTokenBalance","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"safeTrancheCollateral","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"riskTrancheCollateral","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"zPenaltyTrancheCollateral","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"currentPrice","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"tvlBorrow","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"tvlLend","type":"tuple"}],"internalType":"struct CBBDataMature","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IStagingBox","name":"_stagingBox","type":"address"}],"name":"viewStagingStatsActive","outputs":[{"components":[{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"lendSlipSupply","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"borrowSlipSupply","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"safeTrancheBalance","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"riskTrancheBalance","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"safeSlipBalance","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"riskSlipBalance","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"stableTokenBalanceBorrow","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"stableTokenBalanceLend","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"safeTrancheCollateral","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"riskTrancheCollateral","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"safeSlipCollateral","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"riskSlipCollateral","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"tvlBorrow","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"tvlLend","type":"tuple"}],"internalType":"struct StagingDataActive","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IStagingBox","name":"_stagingBox","type":"address"}],"name":"viewStagingStatsIBO","outputs":[{"components":[{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"lendSlipSupply","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"borrowSlipSupply","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"safeTrancheBalance","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"riskTrancheBalance","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"stableTokenBalance","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"safeTrancheCollateral","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"riskTrancheCollateral","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"tvlBorrow","type":"tuple"},{"components":[{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"decimals","type":"uint256"}],"internalType":"struct NumFixedPoint","name":"tvlLend","type":"tuple"}],"internalType":"struct StagingDataIBO","name":"","type":"tuple"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b506140e0806100206000396000f3fe608060405234801561001057600080fd5b506004361061004b5760003560e01c8062977d5e146100505780634cca2294146100795780638c864a6214610099578063f6bfa1ab146100b9575b600080fd5b61006361005e3660046139c1565b6100d9565b60405161007091906139e5565b60405180910390f35b61008c6100873660046139c1565b611147565b6040516100709190613b44565b6100ac6100a73660046139c1565b611b5d565b6040516100709190613c53565b6100cc6100c73660046139c1565b612269565b6040516100709190613d2d565b6100e1613757565b6000806100ed84612ecc565b91509150600061029a8383876001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015610136573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061015a9190613e72565b6040516370a0823160e01b81526001600160a01b038a8116600483015291909116906370a0823190602401602060405180830381865afa1580156101a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101c69190613e8f565b886001600160a01b0316633d13f81a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610204573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102289190613e72565b6040516370a0823160e01b81526001600160a01b038b8116600483015291909116906370a08231906024015b602060405180830381865afa158015610271573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102959190613e8f565b612fa5565b905060006104038484866001600160a01b031663197daa3c6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156102e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103059190613e72565b6040516370a0823160e01b81526001600160a01b038b8116600483015291909116906370a0823190602401602060405180830381865afa15801561034d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103719190613e8f565b876001600160a01b0316636fce86ec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156103af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103d39190613e72565b6040516370a0823160e01b81526001600160a01b038c8116600483015291909116906370a0823190602401610254565b905060006040518060400160405280886001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015610450573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104749190613e72565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156104b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d59190613ea8565b60ff168152602001886001600160a01b031663a9d75b2b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561051b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061053f9190613e72565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561057c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105a09190613ea8565b60ff16815250905060006040518060e00160405280896001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa1580156105f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106179190613e72565b6040516370a0823160e01b81526001600160a01b038c8116600483015291909116906370a0823190602401602060405180830381865afa15801561065f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106839190613e8f565b8152602001896001600160a01b0316633d13f81a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156106c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106ea9190613e72565b6040516370a0823160e01b81526001600160a01b038c8116600483015291909116906370a0823190602401602060405180830381865afa158015610732573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107569190613e8f565b8152602001896001600160a01b031663c34b2a356040518163ffffffff1660e01b8152600401602060405180830381865afa158015610799573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107bd9190613e72565b6001600160a01b031663197daa3c6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156107fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061081e9190613e72565b6040516370a0823160e01b81526001600160a01b038c8116600483015291909116906370a0823190602401602060405180830381865afa158015610866573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061088a9190613e8f565b8152602001896001600160a01b031663c34b2a356040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108f19190613e72565b6001600160a01b0316636fce86ec6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561092e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109529190613e72565b6040516370a0823160e01b81526001600160a01b038c8116600483015291909116906370a0823190602401602060405180830381865afa15801561099a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109be9190613e8f565b8152602001896001600160a01b031663ea13e6536040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a259190613e8f565b8152602001896001600160a01b031663ea13e6536040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a8c9190613e8f565b8a6001600160a01b031663a9d75b2b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610aca573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aee9190613e72565b6040516370a0823160e01b81526001600160a01b038d8116600483015291909116906370a0823190602401602060405180830381865afa158015610b36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b5a9190613e8f565b610b649190613ee1565b8152602001896001600160a01b031663a9d75b2b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ba7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bcb9190613e72565b6040516370a0823160e01b81526001600160a01b038c8116600483015291909116906370a0823190602401602060405180830381865afa158015610c13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c379190613e8f565b81525090506000604051806101c0016040528060405180604001604052808c6001600160a01b031663b57f808a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cb79190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610cf4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d189190613e8f565b81526020018660200151815250815260200160405180604001604052808c6001600160a01b0316633f8c59ee6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d979190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610dd4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610df89190613e8f565b815260208781018051928201929092529183526040805180820182528751815288518185015284840152805180820182528784015181528851818501528185015280518082018252878201518152885181850152606080860191909152815180830183529088015181528851818501526080808601919091528151808301835290880151815282518185015260a0808601919091528151808301835290880151815291518284015260c0840191909152805180820182528951815287518184015260e08401528051808201825289830151815287518184015261010084015280518082018252885181528751818401526101208401528051808201825288830151815287519281019290925261014083019190915280518082019091528551610160909201918190610f2b90600a613fdc565b8d6001600160a01b031663ea13e6536040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f8d9190613e8f565b610f979190613fe8565b6020880151610fa790600a613fdc565b6020808b0151908c01518c51610fbd9190614007565b610fc79190614007565b610fd19190613fe8565b610fdb9190614007565b815260200186602001518760000151610ff49190614007565b815250815260200160405180604001604052808660000151600a6110189190613fdc565b8b6001600160a01b031663af259a3d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611056573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107a9190613e8f565b602089015161108a90600a613fdc565b8d6001600160a01b0316639d1b464a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156110c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ec9190613e8f565b89604001516110fb9190613fe8565b6111059190613fe8565b61110f919061401f565b611119919061401f565b8660a001516111289190614007565b8152602096870151960195909552939093525090979650505050505050565b61114f613937565b600061131783846001600160a01b03166364c9ec6f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611193573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111b79190613e72565b856001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112199190613e72565b6040516370a0823160e01b81526001600160a01b03888116600483015291909116906370a0823190602401602060405180830381865afa158015611261573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112859190613e8f565b866001600160a01b0316633d13f81a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156112c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112e79190613e72565b6040516370a0823160e01b81526001600160a01b03898116600483015291909116906370a0823190602401610254565b90506000836001600160a01b031663a9d75b2b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611359573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061137d9190613e72565b6040516370a0823160e01b81526001600160a01b03868116600483015291909116906370a0823190602401602060405180830381865afa1580156113c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113e99190613e8f565b905060006040518060400160405280866001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015611436573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061145a9190613e72565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611497573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114bb9190613ea8565b60ff168152602001866001600160a01b031663a9d75b2b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611501573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115259190613e72565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611562573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115869190613ea8565b60ff16815250905060006040518061016001604052806040518060400160405280896001600160a01b031663197daa3c6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116099190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611646573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061166a9190613e8f565b8152602001856000015181525081526020016040518060400160405280896001600160a01b0316636fce86ec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156116c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116e99190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611726573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061174a9190613e8f565b8152602001856000015181525081526020016040518060400160405280896001600160a01b0316634499739f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117c99190613e8f565b8152602001856000015181525081526020016040518060400160405280896001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015611824573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118489190613e72565b6040516370a0823160e01b81526001600160a01b038c8116600483015291909116906370a0823190602401602060405180830381865afa158015611890573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118b49190613e8f565b8152602001856000015181525081526020016040518060400160405280896001600160a01b0316633d13f81a6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561190f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119339190613e72565b6040516370a0823160e01b81526001600160a01b038c8116600483015291909116906370a0823190602401602060405180830381865afa15801561197b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061199f9190613e8f565b815285516020918201529082526040805180820182528781528683015181840152838301528051808201825288518152865181840152818401528051808201825288830151815286518184015260608401528051808201808352634e8da32560e11b90529051608090930192909182916001600160a01b038c1691639d1b464a9160448086019291908187030181865afa158015611a41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a659190613e8f565b8152602001896001600160a01b031663af259a3d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611aa8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611acc9190613e8f565b9052815260408051808201825260208881015182528651828201528301528051808201825285519190920191908190611b0690600a613fdc565b611b109088613fe8565b6020870151611b2090600a613fdc565b8951611b2c9190613fe8565b611b369190614007565b815260200185602001518660000151611b4f9190614007565b905290529695505050505050565b611b6561395d565b600080611b7184612ecc565b915091506000611bba8383876001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015610136573d6000803e3d6000fd5b90506000856001600160a01b031663a9d75b2b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611bfc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c209190613e72565b6040516370a0823160e01b81526001600160a01b03888116600483015291909116906370a0823190602401602060405180830381865afa158015611c68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c8c9190613e8f565b905060006040518060400160405280886001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015611cd9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cfd9190613e72565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d5e9190613ea8565b60ff168152602001886001600160a01b031663a9d75b2b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611da4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dc89190613e72565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e299190613ea8565b60ff168152509050600060405180610120016040528060405180604001604052808b6001600160a01b031663b57f808a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eac9190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ee9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f0d9190613e8f565b81526020018560200151815250815260200160405180604001604052808b6001600160a01b0316633f8c59ee6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f8c9190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611fc9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fed9190613e8f565b81526020018560200151815250815260200160405180604001604052808b6001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612048573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061206c9190613e72565b6040516370a0823160e01b81526001600160a01b038e8116600483015291909116906370a0823190602401602060405180830381865afa1580156120b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120d89190613e8f565b81526020018560000151815250815260200160405180604001604052808b6001600160a01b0316633d13f81a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612133573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121579190613e72565b6040516370a0823160e01b81526001600160a01b038e8116600483015291909116906370a0823190602401602060405180830381865afa15801561219f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121c39190613e8f565b8152855160209182015290825260408051808201825287815286830151818401528383015280518082018252885181528651818401528184015280518082018252888301805182528751938201939093526060840152805180820190915290518751608090930192829161223691614007565b81528551602091820152908252604080518082019091529586529384015185850152909201929092529695505050505050565b612271613983565b60006122b583846001600160a01b03166364c9ec6f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611193573d6000803e3d6000fd5b90506000836001600160a01b031663a9d75b2b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156122f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061231b9190613e72565b6040516370a0823160e01b81526001600160a01b03868116600483015291909116906370a0823190602401602060405180830381865afa158015612363573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123879190613e8f565b90506000846001600160a01b0316633d13f81a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156123c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123ed9190613e72565b6040516370a0823160e01b81526001600160a01b03878116600483015291909116906370a0823190602401602060405180830381865afa158015612435573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124599190613e8f565b90506000818460200151876001600160a01b0316636fce86ec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124c59190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612502573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125269190613e8f565b6125309085613ee1565b61253a9190613fe8565b612544919061401f565b905060006040518060400160405280886001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612591573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125b59190613e72565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156125f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126169190613ea8565b60ff168152602001886001600160a01b031663a9d75b2b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561265c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126809190613e72565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156126bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126e19190613ea8565b60ff1681525090506000604051806101a0016040528060405180604001604052808b6001600160a01b031663197daa3c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612740573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127649190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156127a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127c59190613e8f565b81526020018560000151815250815260200160405180604001604052808b6001600160a01b0316636fce86ec6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612820573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128449190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612881573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128a59190613e8f565b81526020018560000151815250815260200160405180604001604052808b6001600160a01b0316634499739f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612900573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129249190613e8f565b81526020018560000151815250815260200160405180604001604052808b6001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa15801561297f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129a39190613e72565b6040516370a0823160e01b81526001600160a01b038e8116600483015291909116906370a0823190602401602060405180830381865afa1580156129eb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a0f9190613e8f565b81526020018560000151815250815260200160405180604001604052808b6001600160a01b0316636fce86ec6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a8e9190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612acb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612aef9190613e8f565b81526020018560000151815250815260200160405180604001604052808b6001600160a01b0316636fce86ec6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b4a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b6e9190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bcf9190613e8f565b612bd99089613ee1565b815260200185600001518152508152602001604051806040016040528088815260200185602001518152508152602001604051806040016040528089600001518152602001856000015181525081526020016040518060400160405280878a602001518d6001600160a01b0316636fce86ec6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c9e9190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612cdb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cff9190613e8f565b612d099190613fe8565b612d13919061401f565b81526020018560000151815250815260200160405180604001604052808681526020018560000151815250815260200160405180604001604052808b6001600160a01b0316639d1b464a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612db09190613e8f565b81526020018b6001600160a01b031663af259a3d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612df3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e179190613e8f565b81525081526020016040518060400160405280868a60200151612e3a9190613ee1565b81526020018560000151815250815260200160405180604001604052808560000151600a612e689190613fdc565b612e72908a613fe8565b6020870151612e8290600a613fdc565b8b51612e8f908a90614007565b612e999190613fe8565b612ea39190614007565b815260200185600001518660200151612ebc9190614007565b9052905298975050505050505050565b6000806000836001600160a01b031663c34b2a356040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f339190613e72565b90506000816001600160a01b03166364c9ec6f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f999190613e72565b91959194509092505050565b60408051808201909152600080825260208201526000806000876001600160a01b031663b2016bd46040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ffc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130209190613e72565b6040516370a0823160e01b81526001600160a01b03898116600483015291909116906370a0823190602401602060405180830381865afa158015613068573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061308c9190613e8f565b9050801561371e57866001600160a01b031663ae4e7fdf6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156130d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130f69190614041565b1561337857876001600160a01b031663b2016bd46040518163ffffffff1660e01b8152600401602060405180830381865afa158015613139573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061315d9190613e72565b6001600160a01b03166370a08231896001600160a01b0316633d13f81a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156131a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131cd9190613e72565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015613211573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132359190613e8f565b9250876001600160a01b031663b2016bd46040518163ffffffff1660e01b8152600401602060405180830381865afa158015613275573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132999190613e72565b6001600160a01b03166370a08231896001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa1580156132e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133099190613e72565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa15801561334d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133719190613e8f565b915061356b565b60005b6001886001600160a01b03166359eb82246040518163ffffffff1660e01b8152600401602060405180830381865afa1580156133bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133df9190613e8f565b6133e99190613ee1565b811080156133f75750600082115b15613566576040516313612cb160e11b8152600481018290526000906001600160a01b038a16906326c25962906024016040805180830381865afa158015613443573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134679190614063565b50905060006134d7826001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156134ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134d19190613e8f565b8561373d565b90506134e38185613ee1565b93508a6001600160a01b031663d0ab79fc6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613523573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135479190613e8f565b8303613551578094505b5050808061355e90614091565b91505061337b565b508092505b876001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa1580156135a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135cd9190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561360a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061362e9190613e8f565b6136388784613fe8565b613642919061401f565b9150876001600160a01b0316633d13f81a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613682573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136a69190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156136e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137079190613e8f565b6137118685613fe8565b61371b919061401f565b92505b5060408051808201909152908152602081019190915295945050505050565b600081831061374c578161374e565b825b90505b92915050565b60408051610200810190915260006101c082018181526101e08301919091528190815260200161379a604051806040016040528060008152602001600081525090565b81526020016137bc604051806040016040528060008152602001600081525090565b81526020016137de604051806040016040528060008152602001600081525090565b8152602001613800604051806040016040528060008152602001600081525090565b8152602001613822604051806040016040528060008152602001600081525090565b8152602001613844604051806040016040528060008152602001600081525090565b8152602001613866604051806040016040528060008152602001600081525090565b8152602001613888604051806040016040528060008152602001600081525090565b81526020016138aa604051806040016040528060008152602001600081525090565b81526020016138cc604051806040016040528060008152602001600081525090565b81526020016138ee604051806040016040528060008152602001600081525090565b8152602001613910604051806040016040528060008152602001600081525090565b8152602001613932604051806040016040528060008152602001600081525090565b905290565b604080516101a081019091526000610160820181815261018083019190915281906137de565b604080516101608101909152600061012082018181526101408301919091528190613822565b604080516101e0810190915260006101a082018181526101c0830191909152819061379a565b6001600160a01b03811681146139be57600080fd5b50565b6000602082840312156139d357600080fd5b81356139de816139a9565b9392505050565b8151805182526020908101519082015261038081016020838101518051604085015290810151606084015250604083015180516080840152602081015160a0840152506060830151805160c0840152602081015160e0840152506080830151610100613a5d8185018380518252602090810151910152565b60a08501519150610140613a7d8186018480518252602090810151910152565b60c08601519250610180613a9d8187018580518252602090810151910152565b60e087015180516101c08801526020908101516101e088015292870151805161020088015283015161022087015261012087015180516102408801528301516102608701529086015180516102808701528201516102a086015261016086015180516102c08701528201516102e086015285015180516103008601528101516103208501526101a085015180516103408601529081015161036085015290505b5092915050565b815180518252602090810151908201526102c081016020838101518051604085015290810151606084015250604083015180516080840152602081015160a0840152506060830151805160c0840152602081015160e0840152506080830151610100613bbc8185018380518252602090810151910152565b60a08501519150610140613bdc8186018480518252602090810151910152565b60c086015180516101808701526020908101516101a087015260e087015180516101c08801528101516101e087015291860151805161020087015282015161022086015261012086015180516102408701528201516102608601528501518051610280860152908101516102a08501529050613b3d565b8151805182526020908101519082015261024081016020838101518051604085015290810151606084015250604083015180516080840152602081015160a0840152506060830151805160c0840152602081015160e0840152506080830151610100613ccb8185018380518252602090810151910152565b60a0850151805161014086015260209081015161016086015260c086015180516101808701528101516101a086015260e086015180516101c08701528101516101e0860152908501518051610200860152908101516102208501529050613b3d565b8151805182526020908101519082015261034081016020838101518051604085015290810151606084015250604083015180516080840152602081015160a0840152506060830151805160c0840152602081015160e0840152506080830151610100613da58185018380518252602090810151910152565b60a08501519150610140613dc58186018480518252602090810151910152565b60c08601519250610180613de58187018580518252602090810151910152565b60e087015180516101c08801526020908101516101e088015292870151805161020088015283015161022087015261012087015180516102408801528301516102608701529086015180516102808701528201516102a086015261016086015180516102c08701528201516102e08601528501518051610300860152908101516103208501529050613b3d565b600060208284031215613e8457600080fd5b81516139de816139a9565b600060208284031215613ea157600080fd5b5051919050565b600060208284031215613eba57600080fd5b815160ff811681146139de57600080fd5b634e487b7160e01b600052601160045260246000fd5b600082821015613ef357613ef3613ecb565b500390565b600181815b80851115613f33578160001904821115613f1957613f19613ecb565b80851615613f2657918102915b93841c9390800290613efd565b509250929050565b600082613f4a57506001613751565b81613f5757506000613751565b8160018114613f6d5760028114613f7757613f93565b6001915050613751565b60ff841115613f8857613f88613ecb565b50506001821b613751565b5060208310610133831016604e8410600b8410161715613fb6575081810a613751565b613fc08383613ef8565b8060001904821115613fd457613fd4613ecb565b029392505050565b600061374e8383613f3b565b600081600019048311821515161561400257614002613ecb565b500290565b6000821982111561401a5761401a613ecb565b500190565b60008261403c57634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561405357600080fd5b815180151581146139de57600080fd5b6000806040838503121561407657600080fd5b8251614081816139a9565b6020939093015192949293505050565b6000600182016140a3576140a3613ecb565b506001019056fea264697066735822122017e7ecb9c0093ecd33b365d04fcc54dab5ed2a55e43f416915b1377612674ebc64736f6c634300080d0033

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061004b5760003560e01c8062977d5e146100505780634cca2294146100795780638c864a6214610099578063f6bfa1ab146100b9575b600080fd5b61006361005e3660046139c1565b6100d9565b60405161007091906139e5565b60405180910390f35b61008c6100873660046139c1565b611147565b6040516100709190613b44565b6100ac6100a73660046139c1565b611b5d565b6040516100709190613c53565b6100cc6100c73660046139c1565b612269565b6040516100709190613d2d565b6100e1613757565b6000806100ed84612ecc565b91509150600061029a8383876001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015610136573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061015a9190613e72565b6040516370a0823160e01b81526001600160a01b038a8116600483015291909116906370a0823190602401602060405180830381865afa1580156101a2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906101c69190613e8f565b886001600160a01b0316633d13f81a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610204573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102289190613e72565b6040516370a0823160e01b81526001600160a01b038b8116600483015291909116906370a08231906024015b602060405180830381865afa158015610271573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102959190613e8f565b612fa5565b905060006104038484866001600160a01b031663197daa3c6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156102e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103059190613e72565b6040516370a0823160e01b81526001600160a01b038b8116600483015291909116906370a0823190602401602060405180830381865afa15801561034d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103719190613e8f565b876001600160a01b0316636fce86ec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156103af573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103d39190613e72565b6040516370a0823160e01b81526001600160a01b038c8116600483015291909116906370a0823190602401610254565b905060006040518060400160405280886001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015610450573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104749190613e72565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156104b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104d59190613ea8565b60ff168152602001886001600160a01b031663a9d75b2b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561051b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061053f9190613e72565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa15801561057c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105a09190613ea8565b60ff16815250905060006040518060e00160405280896001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa1580156105f3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106179190613e72565b6040516370a0823160e01b81526001600160a01b038c8116600483015291909116906370a0823190602401602060405180830381865afa15801561065f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106839190613e8f565b8152602001896001600160a01b0316633d13f81a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156106c6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106ea9190613e72565b6040516370a0823160e01b81526001600160a01b038c8116600483015291909116906370a0823190602401602060405180830381865afa158015610732573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107569190613e8f565b8152602001896001600160a01b031663c34b2a356040518163ffffffff1660e01b8152600401602060405180830381865afa158015610799573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107bd9190613e72565b6001600160a01b031663197daa3c6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156107fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061081e9190613e72565b6040516370a0823160e01b81526001600160a01b038c8116600483015291909116906370a0823190602401602060405180830381865afa158015610866573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061088a9190613e8f565b8152602001896001600160a01b031663c34b2a356040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108cd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108f19190613e72565b6001600160a01b0316636fce86ec6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561092e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109529190613e72565b6040516370a0823160e01b81526001600160a01b038c8116600483015291909116906370a0823190602401602060405180830381865afa15801561099a573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906109be9190613e8f565b8152602001896001600160a01b031663ea13e6536040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a01573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a259190613e8f565b8152602001896001600160a01b031663ea13e6536040518163ffffffff1660e01b8152600401602060405180830381865afa158015610a68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a8c9190613e8f565b8a6001600160a01b031663a9d75b2b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610aca573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aee9190613e72565b6040516370a0823160e01b81526001600160a01b038d8116600483015291909116906370a0823190602401602060405180830381865afa158015610b36573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b5a9190613e8f565b610b649190613ee1565b8152602001896001600160a01b031663a9d75b2b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610ba7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610bcb9190613e72565b6040516370a0823160e01b81526001600160a01b038c8116600483015291909116906370a0823190602401602060405180830381865afa158015610c13573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c379190613e8f565b81525090506000604051806101c0016040528060405180604001604052808c6001600160a01b031663b57f808a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610c93573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cb79190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610cf4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d189190613e8f565b81526020018660200151815250815260200160405180604001604052808c6001600160a01b0316633f8c59ee6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610d73573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d979190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015610dd4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610df89190613e8f565b815260208781018051928201929092529183526040805180820182528751815288518185015284840152805180820182528784015181528851818501528185015280518082018252878201518152885181850152606080860191909152815180830183529088015181528851818501526080808601919091528151808301835290880151815282518185015260a0808601919091528151808301835290880151815291518284015260c0840191909152805180820182528951815287518184015260e08401528051808201825289830151815287518184015261010084015280518082018252885181528751818401526101208401528051808201825288830151815287519281019290925261014083019190915280518082019091528551610160909201918190610f2b90600a613fdc565b8d6001600160a01b031663ea13e6536040518163ffffffff1660e01b8152600401602060405180830381865afa158015610f69573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f8d9190613e8f565b610f979190613fe8565b6020880151610fa790600a613fdc565b6020808b0151908c01518c51610fbd9190614007565b610fc79190614007565b610fd19190613fe8565b610fdb9190614007565b815260200186602001518760000151610ff49190614007565b815250815260200160405180604001604052808660000151600a6110189190613fdc565b8b6001600160a01b031663af259a3d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611056573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061107a9190613e8f565b602089015161108a90600a613fdc565b8d6001600160a01b0316639d1b464a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156110c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110ec9190613e8f565b89604001516110fb9190613fe8565b6111059190613fe8565b61110f919061401f565b611119919061401f565b8660a001516111289190614007565b8152602096870151960195909552939093525090979650505050505050565b61114f613937565b600061131783846001600160a01b03166364c9ec6f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611193573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111b79190613e72565b856001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112199190613e72565b6040516370a0823160e01b81526001600160a01b03888116600483015291909116906370a0823190602401602060405180830381865afa158015611261573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112859190613e8f565b866001600160a01b0316633d13f81a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156112c3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112e79190613e72565b6040516370a0823160e01b81526001600160a01b03898116600483015291909116906370a0823190602401610254565b90506000836001600160a01b031663a9d75b2b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611359573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061137d9190613e72565b6040516370a0823160e01b81526001600160a01b03868116600483015291909116906370a0823190602401602060405180830381865afa1580156113c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113e99190613e8f565b905060006040518060400160405280866001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015611436573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061145a9190613e72565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611497573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114bb9190613ea8565b60ff168152602001866001600160a01b031663a9d75b2b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611501573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115259190613e72565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611562573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115869190613ea8565b60ff16815250905060006040518061016001604052806040518060400160405280896001600160a01b031663197daa3c6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116099190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611646573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061166a9190613e8f565b8152602001856000015181525081526020016040518060400160405280896001600160a01b0316636fce86ec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156116c5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116e99190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611726573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061174a9190613e8f565b8152602001856000015181525081526020016040518060400160405280896001600160a01b0316634499739f6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156117a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117c99190613e8f565b8152602001856000015181525081526020016040518060400160405280896001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015611824573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118489190613e72565b6040516370a0823160e01b81526001600160a01b038c8116600483015291909116906370a0823190602401602060405180830381865afa158015611890573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906118b49190613e8f565b8152602001856000015181525081526020016040518060400160405280896001600160a01b0316633d13f81a6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561190f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906119339190613e72565b6040516370a0823160e01b81526001600160a01b038c8116600483015291909116906370a0823190602401602060405180830381865afa15801561197b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061199f9190613e8f565b815285516020918201529082526040805180820182528781528683015181840152838301528051808201825288518152865181840152818401528051808201825288830151815286518184015260608401528051808201808352634e8da32560e11b90529051608090930192909182916001600160a01b038c1691639d1b464a9160448086019291908187030181865afa158015611a41573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a659190613e8f565b8152602001896001600160a01b031663af259a3d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611aa8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611acc9190613e8f565b9052815260408051808201825260208881015182528651828201528301528051808201825285519190920191908190611b0690600a613fdc565b611b109088613fe8565b6020870151611b2090600a613fdc565b8951611b2c9190613fe8565b611b369190614007565b815260200185602001518660000151611b4f9190614007565b905290529695505050505050565b611b6561395d565b600080611b7184612ecc565b915091506000611bba8383876001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015610136573d6000803e3d6000fd5b90506000856001600160a01b031663a9d75b2b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611bfc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c209190613e72565b6040516370a0823160e01b81526001600160a01b03888116600483015291909116906370a0823190602401602060405180830381865afa158015611c68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c8c9190613e8f565b905060006040518060400160405280886001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015611cd9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cfd9190613e72565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611d3a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611d5e9190613ea8565b60ff168152602001886001600160a01b031663a9d75b2b6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611da4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611dc89190613e72565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e299190613ea8565b60ff168152509050600060405180610120016040528060405180604001604052808b6001600160a01b031663b57f808a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611e88573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611eac9190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611ee9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f0d9190613e8f565b81526020018560200151815250815260200160405180604001604052808b6001600160a01b0316633f8c59ee6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611f68573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f8c9190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611fc9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611fed9190613e8f565b81526020018560200151815250815260200160405180604001604052808b6001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612048573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061206c9190613e72565b6040516370a0823160e01b81526001600160a01b038e8116600483015291909116906370a0823190602401602060405180830381865afa1580156120b4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120d89190613e8f565b81526020018560000151815250815260200160405180604001604052808b6001600160a01b0316633d13f81a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612133573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121579190613e72565b6040516370a0823160e01b81526001600160a01b038e8116600483015291909116906370a0823190602401602060405180830381865afa15801561219f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121c39190613e8f565b8152855160209182015290825260408051808201825287815286830151818401528383015280518082018252885181528651818401528184015280518082018252888301805182528751938201939093526060840152805180820190915290518751608090930192829161223691614007565b81528551602091820152908252604080518082019091529586529384015185850152909201929092529695505050505050565b612271613983565b60006122b583846001600160a01b03166364c9ec6f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015611193573d6000803e3d6000fd5b90506000836001600160a01b031663a9d75b2b6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156122f7573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061231b9190613e72565b6040516370a0823160e01b81526001600160a01b03868116600483015291909116906370a0823190602401602060405180830381865afa158015612363573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123879190613e8f565b90506000846001600160a01b0316633d13f81a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156123c9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906123ed9190613e72565b6040516370a0823160e01b81526001600160a01b03878116600483015291909116906370a0823190602401602060405180830381865afa158015612435573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124599190613e8f565b90506000818460200151876001600160a01b0316636fce86ec6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156124a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124c59190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612502573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125269190613e8f565b6125309085613ee1565b61253a9190613fe8565b612544919061401f565b905060006040518060400160405280886001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa158015612591573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125b59190613e72565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156125f2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126169190613ea8565b60ff168152602001886001600160a01b031663a9d75b2b6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561265c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126809190613e72565b6001600160a01b031663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156126bd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126e19190613ea8565b60ff1681525090506000604051806101a0016040528060405180604001604052808b6001600160a01b031663197daa3c6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612740573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127649190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156127a1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127c59190613e8f565b81526020018560000151815250815260200160405180604001604052808b6001600160a01b0316636fce86ec6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612820573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128449190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612881573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128a59190613e8f565b81526020018560000151815250815260200160405180604001604052808b6001600160a01b0316634499739f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612900573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129249190613e8f565b81526020018560000151815250815260200160405180604001604052808b6001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa15801561297f573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129a39190613e72565b6040516370a0823160e01b81526001600160a01b038e8116600483015291909116906370a0823190602401602060405180830381865afa1580156129eb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a0f9190613e8f565b81526020018560000151815250815260200160405180604001604052808b6001600160a01b0316636fce86ec6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612a6a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a8e9190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612acb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612aef9190613e8f565b81526020018560000151815250815260200160405180604001604052808b6001600160a01b0316636fce86ec6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612b4a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612b6e9190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612bab573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612bcf9190613e8f565b612bd99089613ee1565b815260200185600001518152508152602001604051806040016040528088815260200185602001518152508152602001604051806040016040528089600001518152602001856000015181525081526020016040518060400160405280878a602001518d6001600160a01b0316636fce86ec6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612c7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c9e9190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612cdb573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612cff9190613e8f565b612d099190613fe8565b612d13919061401f565b81526020018560000151815250815260200160405180604001604052808681526020018560000151815250815260200160405180604001604052808b6001600160a01b0316639d1b464a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612d8c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612db09190613e8f565b81526020018b6001600160a01b031663af259a3d6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612df3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612e179190613e8f565b81525081526020016040518060400160405280868a60200151612e3a9190613ee1565b81526020018560000151815250815260200160405180604001604052808560000151600a612e689190613fdc565b612e72908a613fe8565b6020870151612e8290600a613fdc565b8b51612e8f908a90614007565b612e999190613fe8565b612ea39190614007565b815260200185600001518660200151612ebc9190614007565b9052905298975050505050505050565b6000806000836001600160a01b031663c34b2a356040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f0f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f339190613e72565b90506000816001600160a01b03166364c9ec6f6040518163ffffffff1660e01b8152600401602060405180830381865afa158015612f75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f999190613e72565b91959194509092505050565b60408051808201909152600080825260208201526000806000876001600160a01b031663b2016bd46040518163ffffffff1660e01b8152600401602060405180830381865afa158015612ffc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130209190613e72565b6040516370a0823160e01b81526001600160a01b03898116600483015291909116906370a0823190602401602060405180830381865afa158015613068573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061308c9190613e8f565b9050801561371e57866001600160a01b031663ae4e7fdf6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156130d2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130f69190614041565b1561337857876001600160a01b031663b2016bd46040518163ffffffff1660e01b8152600401602060405180830381865afa158015613139573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061315d9190613e72565b6001600160a01b03166370a08231896001600160a01b0316633d13f81a6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156131a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906131cd9190613e72565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa158015613211573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132359190613e8f565b9250876001600160a01b031663b2016bd46040518163ffffffff1660e01b8152600401602060405180830381865afa158015613275573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906132999190613e72565b6001600160a01b03166370a08231896001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa1580156132e5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133099190613e72565b6040516001600160e01b031960e084901b1681526001600160a01b039091166004820152602401602060405180830381865afa15801561334d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133719190613e8f565b915061356b565b60005b6001886001600160a01b03166359eb82246040518163ffffffff1660e01b8152600401602060405180830381865afa1580156133bb573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133df9190613e8f565b6133e99190613ee1565b811080156133f75750600082115b15613566576040516313612cb160e11b8152600481018290526000906001600160a01b038a16906326c25962906024016040805180830381865afa158015613443573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134679190614063565b50905060006134d7826001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156134ad573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906134d19190613e8f565b8561373d565b90506134e38185613ee1565b93508a6001600160a01b031663d0ab79fc6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613523573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135479190613e8f565b8303613551578094505b5050808061355e90614091565b91505061337b565b508092505b876001600160a01b0316634f95d4a66040518163ffffffff1660e01b8152600401602060405180830381865afa1580156135a9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906135cd9190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa15801561360a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061362e9190613e8f565b6136388784613fe8565b613642919061401f565b9150876001600160a01b0316633d13f81a6040518163ffffffff1660e01b8152600401602060405180830381865afa158015613682573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906136a69190613e72565b6001600160a01b03166318160ddd6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156136e3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906137079190613e8f565b6137118685613fe8565b61371b919061401f565b92505b5060408051808201909152908152602081019190915295945050505050565b600081831061374c578161374e565b825b90505b92915050565b60408051610200810190915260006101c082018181526101e08301919091528190815260200161379a604051806040016040528060008152602001600081525090565b81526020016137bc604051806040016040528060008152602001600081525090565b81526020016137de604051806040016040528060008152602001600081525090565b8152602001613800604051806040016040528060008152602001600081525090565b8152602001613822604051806040016040528060008152602001600081525090565b8152602001613844604051806040016040528060008152602001600081525090565b8152602001613866604051806040016040528060008152602001600081525090565b8152602001613888604051806040016040528060008152602001600081525090565b81526020016138aa604051806040016040528060008152602001600081525090565b81526020016138cc604051806040016040528060008152602001600081525090565b81526020016138ee604051806040016040528060008152602001600081525090565b8152602001613910604051806040016040528060008152602001600081525090565b8152602001613932604051806040016040528060008152602001600081525090565b905290565b604080516101a081019091526000610160820181815261018083019190915281906137de565b604080516101608101909152600061012082018181526101408301919091528190613822565b604080516101e0810190915260006101a082018181526101c0830191909152819061379a565b6001600160a01b03811681146139be57600080fd5b50565b6000602082840312156139d357600080fd5b81356139de816139a9565b9392505050565b8151805182526020908101519082015261038081016020838101518051604085015290810151606084015250604083015180516080840152602081015160a0840152506060830151805160c0840152602081015160e0840152506080830151610100613a5d8185018380518252602090810151910152565b60a08501519150610140613a7d8186018480518252602090810151910152565b60c08601519250610180613a9d8187018580518252602090810151910152565b60e087015180516101c08801526020908101516101e088015292870151805161020088015283015161022087015261012087015180516102408801528301516102608701529086015180516102808701528201516102a086015261016086015180516102c08701528201516102e086015285015180516103008601528101516103208501526101a085015180516103408601529081015161036085015290505b5092915050565b815180518252602090810151908201526102c081016020838101518051604085015290810151606084015250604083015180516080840152602081015160a0840152506060830151805160c0840152602081015160e0840152506080830151610100613bbc8185018380518252602090810151910152565b60a08501519150610140613bdc8186018480518252602090810151910152565b60c086015180516101808701526020908101516101a087015260e087015180516101c08801528101516101e087015291860151805161020087015282015161022086015261012086015180516102408701528201516102608601528501518051610280860152908101516102a08501529050613b3d565b8151805182526020908101519082015261024081016020838101518051604085015290810151606084015250604083015180516080840152602081015160a0840152506060830151805160c0840152602081015160e0840152506080830151610100613ccb8185018380518252602090810151910152565b60a0850151805161014086015260209081015161016086015260c086015180516101808701528101516101a086015260e086015180516101c08701528101516101e0860152908501518051610200860152908101516102208501529050613b3d565b8151805182526020908101519082015261034081016020838101518051604085015290810151606084015250604083015180516080840152602081015160a0840152506060830151805160c0840152602081015160e0840152506080830151610100613da58185018380518252602090810151910152565b60a08501519150610140613dc58186018480518252602090810151910152565b60c08601519250610180613de58187018580518252602090810151910152565b60e087015180516101c08801526020908101516101e088015292870151805161020088015283015161022087015261012087015180516102408801528301516102608701529086015180516102808701528201516102a086015261016086015180516102c08701528201516102e08601528501518051610300860152908101516103208501529050613b3d565b600060208284031215613e8457600080fd5b81516139de816139a9565b600060208284031215613ea157600080fd5b5051919050565b600060208284031215613eba57600080fd5b815160ff811681146139de57600080fd5b634e487b7160e01b600052601160045260246000fd5b600082821015613ef357613ef3613ecb565b500390565b600181815b80851115613f33578160001904821115613f1957613f19613ecb565b80851615613f2657918102915b93841c9390800290613efd565b509250929050565b600082613f4a57506001613751565b81613f5757506000613751565b8160018114613f6d5760028114613f7757613f93565b6001915050613751565b60ff841115613f8857613f88613ecb565b50506001821b613751565b5060208310610133831016604e8410600b8410161715613fb6575081810a613751565b613fc08383613ef8565b8060001904821115613fd457613fd4613ecb565b029392505050565b600061374e8383613f3b565b600081600019048311821515161561400257614002613ecb565b500290565b6000821982111561401a5761401a613ecb565b500190565b60008261403c57634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561405357600080fd5b815180151581146139de57600080fd5b6000806040838503121561407657600080fd5b8251614081816139a9565b6020939093015192949293505050565b6000600182016140a3576140a3613ecb565b506001019056fea264697066735822122017e7ecb9c0093ecd33b365d04fcc54dab5ed2a55e43f416915b1377612674ebc64736f6c634300080d0033

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

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