Contract 0xf75da09c8538b7afe8b9d3adc1d626da5d33467f 9

Txn Hash Method
Block
From
To
Value [Txn Fee]
0xc4288b61a24c2a881aba71b203b52cbb15c6790fb01925c7857d5508bac463e3Create Market512633922023-10-27 15:16:4937 days 22 hrs ago0x19518e4d4e542f4b0fc27366c23fac7a0ba491da IN  0xf75da09c8538b7afe8b9d3adc1d626da5d33467f0 ETH0.00004955 0.1
0xc00e7d27d55fb8c8899bcc5bbe5b55bfcc694b8d0ad990dcca0acc6e73f5b971Create Market502087022023-10-23 15:31:5641 days 22 hrs ago0x62a665d3f9fc9a968dc35a789122981d9109349a IN  0xf75da09c8538b7afe8b9d3adc1d626da5d33467f0 ETH0.00005267 0.1
0x8737304bd98b17817447d8555367a3268f77d2cf1d9805c221ccddebbd9467a5Create Market490933642023-10-19 10:56:4646 days 3 hrs ago0x62a665d3f9fc9a968dc35a789122981d9109349a IN  0xf75da09c8538b7afe8b9d3adc1d626da5d33467f0 ETH0.00004955 0.1
0x294b84fae39bbafb96945be39ecbeb8768a1fecdf210b442aca6b930e3ccb60dCreate Market474020232023-10-12 18:19:0052 days 19 hrs ago0x19518e4d4e542f4b0fc27366c23fac7a0ba491da IN  0xf75da09c8538b7afe8b9d3adc1d626da5d33467f0 ETH0.00004954 0.1
0xe172a7615d376296b89158025a82781196ee00727c6c7d8eba5841f67353db63Create Market465633482023-10-09 15:39:1855 days 22 hrs ago0x19518e4d4e542f4b0fc27366c23fac7a0ba491da IN  0xf75da09c8538b7afe8b9d3adc1d626da5d33467f0 ETH0.00004955 0.1
0x3cb829b1692dbf67d2eb3e2a9033c50333f2d736aed128d6a76544b3f69c59ebCreate Market458632432023-10-06 18:58:2558 days 19 hrs ago0x19518e4d4e542f4b0fc27366c23fac7a0ba491da IN  0xf75da09c8538b7afe8b9d3adc1d626da5d33467f0 ETH0.00004955 0.1
0xaea131fd421450b8005a6b7e2e29134e7cf2c0a3992aea5e2adcb6b02252c839Create Market281533792023-06-25 12:10:08162 days 1 hr ago0x19518e4d4e542f4b0fc27366c23fac7a0ba491da IN  0xf75da09c8538b7afe8b9d3adc1d626da5d33467f0 ETH0.00004956 0.1
0x0f726d48c9a03dc05fa986e15a4e2a68ae2ba7ef9a14dab465fa41148cb64b16Create Market278258142023-06-24 1:49:19163 days 12 hrs ago0x19518e4d4e542f4b0fc27366c23fac7a0ba491da IN  0xf75da09c8538b7afe8b9d3adc1d626da5d33467f0 ETH0.00004956 0.1
[ Download CSV Export 
Latest 19 internal transactions
Parent Txn Hash Block From To Value
0x294b84fae39bbafb96945be39ecbeb8768a1fecdf210b442aca6b930e3ccb60d474020232023-10-12 18:19:0052 days 19 hrs ago 0xf75da09c8538b7afe8b9d3adc1d626da5d33467f 0x007a66a2a13415db3613c1a4dd1c942a285902d10 ETH
0x294b84fae39bbafb96945be39ecbeb8768a1fecdf210b442aca6b930e3ccb60d474020232023-10-12 18:19:0052 days 19 hrs ago 0xf75da09c8538b7afe8b9d3adc1d626da5d33467f 0x6cec0ba158fd0c8bc48eafa11f8560318b32258d0 ETH
0x294b84fae39bbafb96945be39ecbeb8768a1fecdf210b442aca6b930e3ccb60d474020232023-10-12 18:19:0052 days 19 hrs ago 0xf75da09c8538b7afe8b9d3adc1d626da5d33467f 0xca93c9bfac39efc5b069066a0970c3036c3029c90 ETH
0xe172a7615d376296b89158025a82781196ee00727c6c7d8eba5841f67353db63465633482023-10-09 15:39:1855 days 22 hrs ago 0xf75da09c8538b7afe8b9d3adc1d626da5d33467f 0x007a66a2a13415db3613c1a4dd1c942a285902d10 ETH
0xe172a7615d376296b89158025a82781196ee00727c6c7d8eba5841f67353db63465633482023-10-09 15:39:1855 days 22 hrs ago 0xf75da09c8538b7afe8b9d3adc1d626da5d33467f 0xca93c9bfac39efc5b069066a0970c3036c3029c90 ETH
0xe172a7615d376296b89158025a82781196ee00727c6c7d8eba5841f67353db63465633482023-10-09 15:39:1855 days 22 hrs ago 0xf75da09c8538b7afe8b9d3adc1d626da5d33467f 0x6cec0ba158fd0c8bc48eafa11f8560318b32258d0 ETH
0x3cb829b1692dbf67d2eb3e2a9033c50333f2d736aed128d6a76544b3f69c59eb458632432023-10-06 18:58:2558 days 19 hrs ago 0xf75da09c8538b7afe8b9d3adc1d626da5d33467f 0x007a66a2a13415db3613c1a4dd1c942a285902d10 ETH
0x3cb829b1692dbf67d2eb3e2a9033c50333f2d736aed128d6a76544b3f69c59eb458632432023-10-06 18:58:2558 days 19 hrs ago 0xf75da09c8538b7afe8b9d3adc1d626da5d33467f 0xca93c9bfac39efc5b069066a0970c3036c3029c90 ETH
0x3cb829b1692dbf67d2eb3e2a9033c50333f2d736aed128d6a76544b3f69c59eb458632432023-10-06 18:58:2558 days 19 hrs ago 0xf75da09c8538b7afe8b9d3adc1d626da5d33467f 0x6cec0ba158fd0c8bc48eafa11f8560318b32258d0 ETH
0xc35aec4cba8cb13836d3814ea0432ba2b962efa818dd3dd176be2bb6adaa2c0f281559672023-06-25 12:26:46162 days 1 hr ago 0x007f7735baf391e207e3aa380bb53c4bd9a5fed6 0xf75da09c8538b7afe8b9d3adc1d626da5d33467f0 ETH
0xc35aec4cba8cb13836d3814ea0432ba2b962efa818dd3dd176be2bb6adaa2c0f281559672023-06-25 12:26:46162 days 1 hr ago 0x007f7735baf391e207e3aa380bb53c4bd9a5fed6 0xf75da09c8538b7afe8b9d3adc1d626da5d33467f0 ETH
0xc35aec4cba8cb13836d3814ea0432ba2b962efa818dd3dd176be2bb6adaa2c0f281559672023-06-25 12:26:46162 days 1 hr ago 0x007f7735baf391e207e3aa380bb53c4bd9a5fed6 0xf75da09c8538b7afe8b9d3adc1d626da5d33467f0 ETH
0xaea131fd421450b8005a6b7e2e29134e7cf2c0a3992aea5e2adcb6b02252c839281533792023-06-25 12:10:08162 days 1 hr ago 0xf75da09c8538b7afe8b9d3adc1d626da5d33467f 0x007a66a2a13415db3613c1a4dd1c942a285902d10 ETH
0xaea131fd421450b8005a6b7e2e29134e7cf2c0a3992aea5e2adcb6b02252c839281533792023-06-25 12:10:08162 days 1 hr ago 0xf75da09c8538b7afe8b9d3adc1d626da5d33467f 0xca93c9bfac39efc5b069066a0970c3036c3029c90 ETH
0xaea131fd421450b8005a6b7e2e29134e7cf2c0a3992aea5e2adcb6b02252c839281533792023-06-25 12:10:08162 days 1 hr ago 0xf75da09c8538b7afe8b9d3adc1d626da5d33467f 0x6cec0ba158fd0c8bc48eafa11f8560318b32258d0 ETH
0x0f726d48c9a03dc05fa986e15a4e2a68ae2ba7ef9a14dab465fa41148cb64b16278258142023-06-24 1:49:19163 days 12 hrs ago 0xf75da09c8538b7afe8b9d3adc1d626da5d33467f 0x007a66a2a13415db3613c1a4dd1c942a285902d10 ETH
0x0f726d48c9a03dc05fa986e15a4e2a68ae2ba7ef9a14dab465fa41148cb64b16278258142023-06-24 1:49:19163 days 12 hrs ago 0xf75da09c8538b7afe8b9d3adc1d626da5d33467f 0xca93c9bfac39efc5b069066a0970c3036c3029c90 ETH
0x0f726d48c9a03dc05fa986e15a4e2a68ae2ba7ef9a14dab465fa41148cb64b16278258142023-06-24 1:49:19163 days 12 hrs ago 0xf75da09c8538b7afe8b9d3adc1d626da5d33467f 0x6cec0ba158fd0c8bc48eafa11f8560318b32258d0 ETH
0xde4ff131f752dfdbffa9f7f8a9588c15d49acdfb31f9ba178a877c393771e357278255452023-06-24 1:47:00163 days 12 hrs ago 0x4e59b44847b379578588920ca78fbf26c0b4956c  Contract Creation0 ETH
[ Download CSV Export 
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
BondFixedTermSDA

Compiler Version
v0.8.15+commit.e14f2714

Optimization Enabled:
Yes with 100000 runs

Other Settings:
default evmVersion
File 1 of 12 : BondFixedTermSDA.sol
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity 0.8.15;

import {BondBaseSDA, IBondAggregator, Authority} from "./bases/BondBaseSDA.sol";
import {IBondTeller} from "./interfaces/IBondTeller.sol";

/// @title Bond Fixed-Term Sequential Dutch Auctioneer
/// @notice Bond Fixed-Term Sequential Dutch Auctioneer Contract
/// @dev Bond Protocol is a permissionless system to create Olympus-style bond markets
///      for any token pair. The markets do not require maintenance and will manage
///      bond prices based on activity. Bond issuers create BondMarkets that pay out
///      a Payout Token in exchange for deposited Quote Tokens. Users can purchase
///      future-dated Payout Tokens with Quote Tokens at the current market price and
///      receive Bond Tokens to represent their position while their bond vests.
///      Once the Bond Tokens vest, they can redeem it for the Quote Tokens.
///
/// @dev The Fixed-Term Auctioneer is an implementation of the
///      Bond Base Auctioneer contract specific to creating bond markets where
///      purchases vest in a fixed amount of time after purchased (rounded to the day).
///
/// @author Oighty, Zeus, Potted Meat, indigo
contract BondFixedTermSDA is BondBaseSDA {
    /* ========== CONSTRUCTOR ========== */
    constructor(
        IBondTeller teller_,
        IBondAggregator aggregator_,
        address guardian_,
        Authority authority_
    ) BondBaseSDA(teller_, aggregator_, guardian_, authority_) {}

    /* ========== MARKET FUNCTIONS ========== */
    /// @inheritdoc BondBaseSDA
    function createMarket(bytes calldata params_) external override returns (uint256) {
        // Decode params into the struct type expected by this auctioneer
        MarketParams memory params = abi.decode(params_, (MarketParams));

        // Check that the vesting parameter is valid for a fixed-term market
        if (params.vesting != 0 && (params.vesting < 1 days || params.vesting > MAX_FIXED_TERM))
            revert Auctioneer_InvalidParams();

        // Create market and return market ID
        return _createMarket(params);
    }
}

File 2 of 12 : BondBaseSDA.sol
// SPDX-License-Identifier: AGPL-3.0-or-later
pragma solidity 0.8.15;

import {ERC20} from "solmate/tokens/ERC20.sol";
import {ReentrancyGuard} from "solmate/utils/ReentrancyGuard.sol";
import {Auth, Authority} from "solmate/auth/Auth.sol";

import {IBondSDA, IBondAuctioneer} from "../interfaces/IBondSDA.sol";
import {IBondTeller} from "../interfaces/IBondTeller.sol";
import {IBondCallback} from "../interfaces/IBondCallback.sol";
import {IBondAggregator} from "../interfaces/IBondAggregator.sol";

import {TransferHelper} from "../lib/TransferHelper.sol";
import {FullMath} from "../lib/FullMath.sol";

/// @title Bond Sequential Dutch Auctioneer (SDA) v1.1
/// @notice Bond Sequential Dutch Auctioneer Base Contract
/// @dev Bond Protocol is a system to create Olympus-style bond markets
///      for any token pair. The markets do not require maintenance and will manage
///      bond prices based on activity. Bond issuers create BondMarkets that pay out
///      a Payout Token in exchange for deposited Quote Tokens. Users can purchase
///      future-dated Payout Tokens with Quote Tokens at the current market price and
///      receive Bond Tokens to represent their position while their bond vests.
///      Once the Bond Tokens vest, they can redeem it for the Quote Tokens.
///
/// @dev The Auctioneer contract allows users to create and manage bond markets.
///      All bond pricing logic and market data is stored in the Auctioneer.
///      A Auctioneer is dependent on a Teller to serve external users and
///      an Aggregator to register new markets. This implementation of the Auctioneer
///      uses a Sequential Dutch Auction pricing system to buy a target amount of quote
///      tokens or sell a target amount of payout tokens over the duration of a market.
///
/// @author Oighty, Zeus, Potted Meat, indigo
abstract contract BondBaseSDA is IBondSDA, Auth {
    using TransferHelper for ERC20;
    using FullMath for uint256;

    /* ========== ERRORS ========== */

    error Auctioneer_OnlyMarketOwner();
    error Auctioneer_InitialPriceLessThanMin();
    error Auctioneer_MarketNotActive();
    error Auctioneer_MaxPayoutExceeded();
    error Auctioneer_AmountLessThanMinimum();
    error Auctioneer_NotEnoughCapacity();
    error Auctioneer_InvalidCallback();
    error Auctioneer_BadExpiry();
    error Auctioneer_InvalidParams();
    error Auctioneer_NotAuthorized();
    error Auctioneer_NewMarketsNotAllowed();

    /* ========== EVENTS ========== */

    event MarketCreated(
        uint256 indexed id,
        address indexed payoutToken,
        address indexed quoteToken,
        uint48 vesting,
        uint256 initialPrice
    );
    event MarketClosed(uint256 indexed id);
    event Tuned(uint256 indexed id, uint256 oldControlVariable, uint256 newControlVariable);
    event DefaultsUpdated(
        uint32 defaultTuneInterval,
        uint32 defaultTuneAdjustment,
        uint32 minDebtDecayInterval,
        uint32 minDepositInterval,
        uint32 minMarketDuration,
        uint32 minDebtBuffer
    );

    /* ========== STATE VARIABLES ========== */

    /// @notice Main information pertaining to bond market
    mapping(uint256 => BondMarket) public markets;

    /// @notice Information used to control how a bond market changes
    mapping(uint256 => BondTerms) public terms;

    /// @notice Data needed for tuning bond market
    mapping(uint256 => BondMetadata) public metadata;

    /// @notice Control variable changes
    mapping(uint256 => Adjustment) public adjustments;

    /// @notice New address to designate as market owner. They must accept ownership to transfer permissions.
    mapping(uint256 => address) public newOwners;

    /// @notice Whether or not the auctioneer allows new markets to be created
    /// @dev    Changing to false will sunset the auctioneer after all active markets end
    bool public allowNewMarkets;

    /// @notice Whether or not the market creator is authorized to use a callback address
    mapping(address => bool) public callbackAuthorized;

    /// Sane defaults for tuning. Can be adjusted for a specific market via setters.
    uint32 public defaultTuneInterval;
    uint32 public defaultTuneAdjustment;
    /// Minimum values for decay, deposit interval, market duration and debt buffer.
    uint32 public minDebtDecayInterval;
    uint32 public minDepositInterval;
    uint32 public minMarketDuration;
    uint32 public minDebtBuffer;

    // A 'vesting' param longer than 50 years is considered a timestamp for fixed expiry.
    uint48 internal constant MAX_FIXED_TERM = 52 weeks * 50;
    uint48 internal constant FEE_DECIMALS = 1e5; // one percent equals 1000.

    // BondAggregator contract with utility functions
    IBondAggregator internal immutable _aggregator;

    // BondTeller contract that handles interactions with users and issues tokens
    IBondTeller internal immutable _teller;

    constructor(
        IBondTeller teller_,
        IBondAggregator aggregator_,
        address guardian_,
        Authority authority_
    ) Auth(guardian_, authority_) {
        _aggregator = aggregator_;
        _teller = teller_;

        defaultTuneInterval = 24 hours;
        defaultTuneAdjustment = 6 hours;
        minDebtDecayInterval = 3 days;
        minDepositInterval = 1 hours;
        minMarketDuration = 1 days;
        minDebtBuffer = 10000; // 10%

        allowNewMarkets = true;
    }

    /* ========== MARKET FUNCTIONS ========== */

    /// @inheritdoc IBondAuctioneer
    function createMarket(bytes calldata params_) external virtual returns (uint256);

    /// @notice core market creation logic, see IBondSDA.MarketParams documentation
    function _createMarket(MarketParams memory params_) internal returns (uint256) {
        {
            // Check that the auctioneer is allowing new markets to be created
            if (!allowNewMarkets) revert Auctioneer_NewMarketsNotAllowed();

            // Ensure params are in bounds
            uint8 payoutTokenDecimals = params_.payoutToken.decimals();
            uint8 quoteTokenDecimals = params_.quoteToken.decimals();

            if (payoutTokenDecimals < 6 || payoutTokenDecimals > 18)
                revert Auctioneer_InvalidParams();
            if (quoteTokenDecimals < 6 || quoteTokenDecimals > 18)
                revert Auctioneer_InvalidParams();
            if (params_.scaleAdjustment < -24 || params_.scaleAdjustment > 24)
                revert Auctioneer_InvalidParams();

            // Restrict the use of a callback address unless allowed
            if (!callbackAuthorized[msg.sender] && params_.callbackAddr != address(0))
                revert Auctioneer_NotAuthorized();

            // Start time must be zero or in the future
            if (params_.start > 0 && params_.start < block.timestamp)
                revert Auctioneer_InvalidParams();
        }

        // Unit to scale calculation for this market by to ensure reasonable values
        // for price, debt, and control variable without under/overflows.
        // See IBondSDA for more details.
        //
        // scaleAdjustment should be equal to (payoutDecimals - quoteDecimals) - ((payoutPriceDecimals - quotePriceDecimals) / 2)
        uint256 scale;
        unchecked {
            scale = 10**uint8(36 + params_.scaleAdjustment);
        }

        if (params_.formattedInitialPrice < params_.formattedMinimumPrice)
            revert Auctioneer_InitialPriceLessThanMin();

        // Register new market on aggregator and get marketId
        uint256 marketId = _aggregator.registerMarket(params_.payoutToken, params_.quoteToken);

        uint32 debtDecayInterval;
        {
            // Check time bounds
            if (
                params_.duration < minMarketDuration ||
                params_.depositInterval < minDepositInterval ||
                params_.depositInterval > params_.duration
            ) revert Auctioneer_InvalidParams();

            // The debt decay interval is how long it takes for price to drop to 0 from the last decay timestamp.
            // In reality, a 50% drop is likely a guaranteed bond sale. Therefore, debt decay interval needs to be
            // long enough to allow a bond to adjust if oversold. It also needs to be some multiple of deposit interval
            // because you don't want to go from 100 to 0 during the time frame you expected to sell a single bond.
            // A multiple of 5 is a sane default observed from running OP v1 bond markets.
            uint32 userDebtDecay = params_.depositInterval * 5;
            debtDecayInterval = minDebtDecayInterval > userDebtDecay
                ? minDebtDecayInterval
                : userDebtDecay;

            uint256 tuneIntervalCapacity = params_.capacity.mulDiv(
                uint256(
                    params_.depositInterval > defaultTuneInterval
                        ? params_.depositInterval
                        : defaultTuneInterval
                ),
                uint256(params_.duration)
            );

            uint48 start = params_.start == 0 ? uint48(block.timestamp) : params_.start;
            metadata[marketId] = BondMetadata({
                lastTune: start,
                lastDecay: start,
                depositInterval: params_.depositInterval,
                tuneInterval: params_.depositInterval > defaultTuneInterval
                    ? params_.depositInterval
                    : defaultTuneInterval,
                tuneAdjustmentDelay: defaultTuneAdjustment,
                debtDecayInterval: debtDecayInterval,
                tuneIntervalCapacity: tuneIntervalCapacity,
                tuneBelowCapacity: params_.capacity - tuneIntervalCapacity,
                lastTuneDebt: (
                    params_.capacityInQuote
                        ? params_.capacity.mulDiv(scale, params_.formattedInitialPrice)
                        : params_.capacity
                ).mulDiv(uint256(debtDecayInterval), uint256(params_.duration))
            });
        }

        // Initial target debt is equal to capacity scaled by the ratio of the debt decay interval and the length of the market.
        // This is the amount of debt that should be decayed over the decay interval if no purchases are made.
        // Note price should be passed in a specific format:
        // price = (payoutPriceCoefficient / quotePriceCoefficient)
        //         * 10**(36 + scaleAdjustment + quoteDecimals - payoutDecimals + payoutPriceDecimals - quotePriceDecimals)
        // See IBondSDA for more details and variable definitions.
        uint256 targetDebt;
        uint256 _maxPayout;
        {
            uint256 capacity = params_.capacityInQuote
                ? params_.capacity.mulDiv(scale, params_.formattedInitialPrice)
                : params_.capacity;

            targetDebt = capacity.mulDiv(uint256(debtDecayInterval), uint256(params_.duration));

            // Max payout is the amount of capacity that should be utilized in a deposit
            // interval. for example, if capacity is 1,000 TOKEN, there are 10 days to conclusion,
            // and the preferred deposit interval is 1 day, max payout would be 100 TOKEN.
            // Additionally, max payout is the maximum amount that a user can receive from a single
            // purchase at that moment in time.
            _maxPayout = capacity.mulDiv(
                uint256(params_.depositInterval),
                uint256(params_.duration)
            );
        }

        markets[marketId] = BondMarket({
            owner: msg.sender,
            payoutToken: params_.payoutToken,
            quoteToken: params_.quoteToken,
            callbackAddr: params_.callbackAddr,
            capacityInQuote: params_.capacityInQuote,
            capacity: params_.capacity,
            totalDebt: targetDebt,
            minPrice: params_.formattedMinimumPrice,
            maxPayout: _maxPayout,
            purchased: 0,
            sold: 0,
            scale: scale
        });

        // Max debt serves as a circuit breaker for the market. let's say the quote token is a stablecoin,
        // and that stablecoin depegs. without max debt, the market would continue to buy until it runs
        // out of capacity. this is configurable with a 3 decimal buffer (1000 = 1% above initial price).
        // Note that its likely advisable to keep this buffer wide.
        // Note that the buffer is above 100%. i.e. 10% buffer = initial debt * 1.1
        // 1e5 = 100,000. 10,000 / 100,000 = 10%.
        // See IBondSDA.MarketParams for more information on determining a reasonable debt buffer.
        uint256 minDebtBuffer_ = _maxPayout.mulDiv(FEE_DECIMALS, targetDebt) > minDebtBuffer
            ? _maxPayout.mulDiv(FEE_DECIMALS, targetDebt)
            : minDebtBuffer;
        uint256 maxDebt = targetDebt +
            targetDebt.mulDiv(
                uint256(params_.debtBuffer > minDebtBuffer_ ? params_.debtBuffer : minDebtBuffer_),
                1e5
            );

        // The control variable is set as the ratio of price to the initial targetDebt, scaled to prevent under/overflows.
        // It determines the price of the market as the debt decays and is tuned by the market based on user activity.
        // See _tune() for more information.
        //
        // price = control variable * debt / scale
        // therefore, control variable = price * scale / debt
        uint256 controlVariable = params_.formattedInitialPrice.mulDiv(scale, targetDebt);
        uint48 start = params_.start == 0 ? uint48(block.timestamp) : params_.start;
        terms[marketId] = BondTerms({
            controlVariable: controlVariable,
            maxDebt: maxDebt,
            start: start,
            conclusion: start + uint48(params_.duration),
            vesting: params_.vesting
        });

        emit MarketCreated(
            marketId,
            address(params_.payoutToken),
            address(params_.quoteToken),
            params_.vesting,
            params_.formattedInitialPrice
        );

        return marketId;
    }

    /// @inheritdoc IBondAuctioneer
    function setIntervals(uint256 id_, uint32[3] calldata intervals_) external override {
        // Check that the market is live
        if (!isLive(id_)) revert Auctioneer_InvalidParams();

        // Check that the intervals are non-zero
        if (intervals_[0] == 0 || intervals_[1] == 0 || intervals_[2] == 0)
            revert Auctioneer_InvalidParams();

        // Check that tuneInterval >= tuneAdjustmentDelay
        if (intervals_[0] < intervals_[1]) revert Auctioneer_InvalidParams();

        BondMetadata storage meta = metadata[id_];
        // Check that tuneInterval >= depositInterval
        if (intervals_[0] < meta.depositInterval) revert Auctioneer_InvalidParams();

        // Check that debtDecayInterval >= minDebtDecayInterval
        if (intervals_[2] < minDebtDecayInterval) revert Auctioneer_InvalidParams();

        // Check that sender is market owner
        BondMarket memory market = markets[id_];
        if (msg.sender != market.owner) revert Auctioneer_OnlyMarketOwner();

        // Update intervals
        meta.tuneInterval = intervals_[0];
        meta.tuneIntervalCapacity = market.capacity.mulDiv(
            uint256(intervals_[0]),
            uint256(terms[id_].conclusion) - block.timestamp
        ); // this will update tuneIntervalCapacity based on time remaining
        meta.tuneBelowCapacity = market.capacity > meta.tuneIntervalCapacity
            ? market.capacity - meta.tuneIntervalCapacity
            : 0;
        meta.tuneAdjustmentDelay = intervals_[1];
        meta.debtDecayInterval = intervals_[2];
    }

    /// @inheritdoc IBondAuctioneer
    function pushOwnership(uint256 id_, address newOwner_) external override {
        if (msg.sender != markets[id_].owner) revert Auctioneer_OnlyMarketOwner();
        newOwners[id_] = newOwner_;
    }

    /// @inheritdoc IBondAuctioneer
    function pullOwnership(uint256 id_) external override {
        if (msg.sender != newOwners[id_]) revert Auctioneer_NotAuthorized();
        markets[id_].owner = newOwners[id_];
    }

    /// @inheritdoc IBondAuctioneer
    function setDefaults(uint32[6] memory defaults_) external override requiresAuth {
        // Restricted to authorized addresses

        // Validate inputs
        // Check that defaultTuneInterval >= defaultTuneAdjustment
        if (defaults_[0] < defaults_[1]) revert Auctioneer_InvalidParams();

        // Check that defaultTuneInterval >= minDepositInterval
        if (defaults_[0] < defaults_[3]) revert Auctioneer_InvalidParams();

        // Check that minDepositInterval <= minMarketDuration
        if (defaults_[3] > defaults_[4]) revert Auctioneer_InvalidParams();

        // Check that minDebtDecayInterval >= 5 * minDepositInterval
        if (defaults_[2] < defaults_[3] * 5) revert Auctioneer_InvalidParams();

        // Update defaults
        defaultTuneInterval = defaults_[0];
        defaultTuneAdjustment = defaults_[1];
        minDebtDecayInterval = defaults_[2];
        minDepositInterval = defaults_[3];
        minMarketDuration = defaults_[4];
        minDebtBuffer = defaults_[5];

        emit DefaultsUpdated(
            defaultTuneInterval,
            defaultTuneAdjustment,
            minDebtDecayInterval,
            minDepositInterval,
            minMarketDuration,
            minDebtBuffer
        );
    }

    /// @inheritdoc IBondAuctioneer
    function setAllowNewMarkets(bool status_) external override requiresAuth {
        // Restricted to authorized addresses
        allowNewMarkets = status_;
    }

    /// @inheritdoc IBondAuctioneer
    function setCallbackAuthStatus(address creator_, bool status_) external override requiresAuth {
        // Restricted to authorized addresses
        callbackAuthorized[creator_] = status_;
    }

    /// @inheritdoc IBondAuctioneer
    function closeMarket(uint256 id_) external override {
        if (msg.sender != markets[id_].owner) revert Auctioneer_OnlyMarketOwner();
        _close(id_);
    }

    /* ========== TELLER FUNCTIONS ========== */

    /// @inheritdoc IBondAuctioneer
    function purchaseBond(
        uint256 id_,
        uint256 amount_,
        uint256 minAmountOut_
    ) external override returns (uint256 payout) {
        if (msg.sender != address(_teller)) revert Auctioneer_NotAuthorized();

        BondMarket storage market = markets[id_];
        BondTerms memory term = terms[id_];

        // If market uses a callback, check that owner is still callback authorized
        if (market.callbackAddr != address(0) && !callbackAuthorized[market.owner])
            revert Auctioneer_NotAuthorized();

        // Check if market is live, if not revert
        if (!isLive(id_)) revert Auctioneer_MarketNotActive();

        uint256 price;
        (price, payout) = _decayAndGetPrice(id_, amount_, uint48(block.timestamp)); // Debt and the control variable decay over time

        // Payout must be greater than user inputted minimum
        if (payout < minAmountOut_) revert Auctioneer_AmountLessThanMinimum();

        // Markets have a max payout amount, capping size because deposits
        // do not experience slippage. max payout is recalculated upon tuning
        if (payout > market.maxPayout) revert Auctioneer_MaxPayoutExceeded();

        // Update Capacity and Debt values

        // Capacity is either the number of payout tokens that the market can sell
        // (if capacity in quote is false),
        //
        // or the number of quote tokens that the market can buy
        // (if capacity in quote is true)

        // If amount/payout is greater than capacity remaining, revert
        if (market.capacityInQuote ? amount_ > market.capacity : payout > market.capacity)
            revert Auctioneer_NotEnoughCapacity();
        // Capacity is decreased by the deposited or paid amount
        market.capacity -= market.capacityInQuote ? amount_ : payout;

        // Markets keep track of how many quote tokens have been
        // purchased, and how many payout tokens have been sold
        market.purchased += amount_;
        market.sold += payout;

        // Circuit breaker. If max debt is breached, the market is closed
        if (term.maxDebt < market.totalDebt) {
            _close(id_);
        } else {
            // If market will continue, the control variable is tuned to to expend remaining capacity over remaining market duration
            _tune(id_, uint48(block.timestamp), price);
        }
    }

    /* ========== INTERNAL DEPO FUNCTIONS ========== */

    /// @notice          Close a market
    /// @dev             Closing a market sets capacity to 0 and immediately stops bonding
    function _close(uint256 id_) internal {
        terms[id_].conclusion = uint48(block.timestamp);
        markets[id_].capacity = 0;

        emit MarketClosed(id_);
    }

    /// @notice                 Decay debt, and adjust control variable if there is an active change
    /// @param id_              ID of market
    /// @param amount_          Amount of quote tokens being purchased
    /// @param time_            Current timestamp (saves gas when passed in)
    /// @return marketPrice_    Current market price of bond, accounting for decay
    /// @return payout_         Amount of payout tokens received at current price
    function _decayAndGetPrice(
        uint256 id_,
        uint256 amount_,
        uint48 time_
    ) internal returns (uint256 marketPrice_, uint256 payout_) {
        BondMarket memory market = markets[id_];

        // Debt is a time-decayed sum of tokens spent in a market
        // Debt is added when deposits occur and removed over time
        // |
        // |    debt falls with
        // |   / \  inactivity        / \
        // | /     \              /\ /   \
        // |         \           /        \ / \
        // |           \      /\/
        // |             \  /  and rises
        // |                with deposits
        // |
        // |------------------------------------| t

        // Decay debt by the amount of time since the last decay
        uint256 decayedDebt = currentDebt(id_);
        markets[id_].totalDebt = decayedDebt;

        // Control variable decay

        // The bond control variable is continually tuned. When it is lowered (which
        // lowers the market price), the change is carried out smoothly over time.
        if (adjustments[id_].active) {
            Adjustment storage adjustment = adjustments[id_];

            (uint256 adjustBy, uint48 secondsSince, bool stillActive) = _controlDecay(id_);
            terms[id_].controlVariable -= adjustBy;

            if (stillActive) {
                adjustment.change -= adjustBy;
                adjustment.timeToAdjusted -= secondsSince;
                adjustment.lastAdjustment = time_;
            } else {
                adjustment.active = false;
            }
        }

        // Price is not allowed to be lower than the minimum price
        marketPrice_ = _currentMarketPrice(id_);
        uint256 minPrice = market.minPrice;
        if (marketPrice_ < minPrice) marketPrice_ = minPrice;

        // Payout for the deposit = amount / price
        //
        // where:
        // payout = payout tokens out
        // amount = quote tokens in
        // price = quote tokens : payout token (i.e. 200 QUOTE : BASE), adjusted for scaling
        payout_ = amount_.mulDiv(market.scale, marketPrice_);

        // Cache storage variables to memory
        uint256 debtDecayInterval = uint256(metadata[id_].debtDecayInterval);
        uint256 lastTuneDebt = metadata[id_].lastTuneDebt;
        uint256 lastDecay = uint256(metadata[id_].lastDecay);

        // Set last decay timestamp based on size of purchase to linearize decay
        uint256 lastDecayIncrement = debtDecayInterval.mulDivUp(payout_, lastTuneDebt);
        metadata[id_].lastDecay += uint48(lastDecayIncrement);

        // Update total debt following the purchase
        // Goal is to have the same decayed debt post-purchase as pre-purchase so that price is the same as before purchase and then add new debt to increase price
        // 1. Adjust total debt so that decayed debt is equal to the current debt after updating the last decay timestamp.
        //    This is the currentDebt function solved for totalDebt and adding lastDecayIncrement (the number of seconds lastDecay moves forward in time)
        //    to the number of seconds used to calculate the previous currentDebt.
        // 2. Add the payout to the total debt to increase the price.
        uint256 decayOffset = time_ > lastDecay
            ? (
                debtDecayInterval > (time_ - lastDecay)
                    ? debtDecayInterval - (time_ - lastDecay)
                    : 0
            )
            : debtDecayInterval + (lastDecay - time_);
        markets[id_].totalDebt =
            decayedDebt.mulDiv(debtDecayInterval, decayOffset + lastDecayIncrement) +
            payout_ +
            1; // add 1 to satisfy price inequality
    }

    /// @notice             Auto-adjust control variable to hit capacity/spend target
    /// @param id_          ID of market
    /// @param time_        Timestamp (saves gas when passed in)
    /// @param price_       Current price of the market
    function _tune(
        uint256 id_,
        uint48 time_,
        uint256 price_
    ) internal {
        BondMetadata memory meta = metadata[id_];
        BondMarket memory market = markets[id_];
        BondTerms memory term = terms[id_];

        // Market tunes in 2 situations:
        // 1. If capacity has exceeded target since last tune adjustment and the market is oversold
        // 2. If a tune interval has passed since last tune adjustment and the market is undersold
        //
        // Markets are created with a target capacity with the expectation that capacity will
        // be utilized evenly over the duration of the market.
        // The intuition with tuning is:
        // - When the market is ahead of target capacity, we should tune based on capacity.
        // - When the market is behind target capacity, we should tune based on time.

        // Compute seconds remaining until market will conclude and total duration of market
        uint256 timeRemaining = uint256(term.conclusion - time_);
        uint256 duration = uint256(term.conclusion - term.start);

        // Standardize capacity into an payout token amount
        uint256 capacity = market.capacityInQuote
            ? market.capacity.mulDiv(market.scale, price_)
            : market.capacity;
        // Calculate initial capacity based on remaining capacity and amount sold/purchased up to this point
        uint256 initialCapacity = capacity +
            (market.capacityInQuote ? market.purchased.mulDiv(market.scale, price_) : market.sold);

        // Calculate timeNeutralCapacity as the capacity expected to be sold up to this point and the current capacity
        // Higher than initial capacity means the market is undersold, lower than initial capacity means the market is oversold
        uint256 timeNeutralCapacity = initialCapacity.mulDiv(duration - timeRemaining, duration) +
            capacity;

        if (
            (market.capacity < meta.tuneBelowCapacity && timeNeutralCapacity < initialCapacity) ||
            (time_ >= meta.lastTune + meta.tuneInterval && timeNeutralCapacity > initialCapacity)
        ) {
            // Calculate the correct payout to complete on time assuming each bond
            // will be max size in the desired deposit interval for the remaining time
            //
            // i.e. market has 10 days remaining. deposit interval is 1 day. capacity
            // is 10,000 TOKEN. max payout would be 1,000 TOKEN (10,000 * 1 / 10).
            markets[id_].maxPayout = capacity.mulDiv(uint256(meta.depositInterval), timeRemaining);

            // Calculate ideal target debt to satisty capacity in the remaining time
            // The target debt is based on whether the market is under or oversold at this point in time
            // This target debt will ensure price is reactive while ensuring the magnitude of being over/undersold
            // doesn't cause larger fluctuations towards the end of the market.
            //
            // Calculate target debt from the timeNeutralCapacity and the ratio of debt decay interval and the length of the market
            uint256 targetDebt = timeNeutralCapacity.mulDiv(
                uint256(meta.debtDecayInterval),
                duration
            );

            // Derive a new control variable from the target debt
            uint256 newControlVariable = price_.mulDivUp(market.scale, targetDebt);

            emit Tuned(id_, term.controlVariable, newControlVariable);

            if (newControlVariable < term.controlVariable) {
                // If decrease, control variable change will be carried out over the tune adjustment delay
                // this is because price will be lowered
                adjustments[id_] = Adjustment(
                    term.controlVariable - newControlVariable,
                    time_,
                    meta.tuneAdjustmentDelay,
                    true
                );
            } else {
                // Tune up immediately
                terms[id_].controlVariable = newControlVariable;
                // Set current adjustment to inactive (e.g. if we are re-tuning early)
                adjustments[id_].active = false;
            }

            metadata[id_].lastTune = time_;
            metadata[id_].tuneBelowCapacity = market.capacity > meta.tuneIntervalCapacity
                ? market.capacity - meta.tuneIntervalCapacity
                : 0;
            metadata[id_].lastTuneDebt = targetDebt;
        }
    }

    /* ========== INTERNAL VIEW FUNCTIONS ========== */

    /// @notice             Calculate current market price of payout token in quote tokens
    /// @dev                See marketPrice() in IBondSDA for explanation of price computation
    /// @dev                Uses info from storage because data has been updated before call (vs marketPrice())
    /// @param id_          Market ID
    /// @return             Price for market in payout token decimals
    function _currentMarketPrice(uint256 id_) internal view returns (uint256) {
        BondMarket memory market = markets[id_];
        return terms[id_].controlVariable.mulDivUp(market.totalDebt, market.scale);
    }

    /// @notice                 Amount to decay control variable by
    /// @param id_              ID of market
    /// @return decay           change in control variable
    /// @return secondsSince    seconds since last change in control variable
    /// @return active          whether or not change remains active
    function _controlDecay(uint256 id_)
        internal
        view
        returns (
            uint256 decay,
            uint48 secondsSince,
            bool active
        )
    {
        Adjustment memory info = adjustments[id_];
        if (!info.active) return (0, 0, false);

        secondsSince = uint48(block.timestamp) - info.lastAdjustment;
        active = secondsSince < info.timeToAdjusted;
        decay = active
            ? info.change.mulDiv(uint256(secondsSince), uint256(info.timeToAdjusted))
            : info.change;
    }

    /* ========== EXTERNAL VIEW FUNCTIONS ========== */

    /// @inheritdoc IBondAuctioneer
    function getMarketInfoForPurchase(uint256 id_)
        external
        view
        returns (
            address owner,
            address callbackAddr,
            ERC20 payoutToken,
            ERC20 quoteToken,
            uint48 vesting,
            uint256 maxPayout_
        )
    {
        BondMarket memory market = markets[id_];
        return (
            market.owner,
            market.callbackAddr,
            market.payoutToken,
            market.quoteToken,
            terms[id_].vesting,
            maxPayout(id_)
        );
    }

    /// @inheritdoc IBondSDA
    function marketPrice(uint256 id_) public view override returns (uint256) {
        uint256 price = currentControlVariable(id_).mulDivUp(currentDebt(id_), markets[id_].scale);

        return (price > markets[id_].minPrice) ? price : markets[id_].minPrice;
    }

    /// @inheritdoc IBondAuctioneer
    function marketScale(uint256 id_) external view override returns (uint256) {
        return markets[id_].scale;
    }

    /// @inheritdoc IBondAuctioneer
    function payoutFor(
        uint256 amount_,
        uint256 id_,
        address referrer_
    ) public view override returns (uint256) {
        // Calculate the payout for the given amount of tokens
        uint256 fee = amount_.mulDiv(_teller.getFee(referrer_), 1e5);
        uint256 payout = (amount_ - fee).mulDiv(markets[id_].scale, marketPrice(id_));

        // Check that the payout is less than or equal to the maximum payout,
        // Revert if not, otherwise return the payout
        if (payout > maxPayout(id_)) {
            revert Auctioneer_MaxPayoutExceeded();
        } else {
            return payout;
        }
    }

    /// @inheritdoc IBondSDA
    function maxPayout(uint256 id_) public view override returns (uint256) {
        // Get current price
        uint256 price = marketPrice(id_);

        BondMarket memory market = markets[id_];

        // Convert capacity to payout token units for comparison with max payout
        uint256 capacity = market.capacityInQuote
            ? market.capacity.mulDiv(market.scale, price)
            : market.capacity;

        // Cap max payout at the remaining capacity
        return market.maxPayout > capacity ? capacity : market.maxPayout;
    }

    /// @inheritdoc IBondAuctioneer
    function maxAmountAccepted(uint256 id_, address referrer_) external view returns (uint256) {
        // Calculate maximum amount of quote tokens that correspond to max bond size
        // Maximum of the maxPayout and the remaining capacity converted to quote tokens
        BondMarket memory market = markets[id_];
        uint256 price = marketPrice(id_);
        uint256 quoteCapacity = market.capacityInQuote
            ? market.capacity
            : market.capacity.mulDiv(price, market.scale);
        uint256 maxQuote = market.maxPayout.mulDiv(price, market.scale);
        uint256 amountAccepted = quoteCapacity < maxQuote ? quoteCapacity : maxQuote;

        // Take into account teller fees and return
        // Estimate fee based on amountAccepted. Fee taken will be slightly larger than
        // this given it will be taken off the larger amount, but this avoids rounding
        // errors with trying to calculate the exact amount.
        // Therefore, the maxAmountAccepted is slightly conservative.
        uint256 estimatedFee = amountAccepted.mulDiv(_teller.getFee(referrer_), 1e5);

        return amountAccepted + estimatedFee;
    }

    /// @inheritdoc IBondSDA
    function currentDebt(uint256 id_) public view override returns (uint256) {
        uint256 currentTime = block.timestamp;

        // Don't decay debt prior to start time
        if (currentTime < uint256(terms[id_].start)) return markets[id_].totalDebt;

        BondMetadata memory meta = metadata[id_];
        uint256 lastDecay = uint256(meta.lastDecay);

        // Determine if decay should increase or decrease debt based on last decay time
        // If last decay time is in the future, then debt should be increased
        // If last decay time is in the past, then debt should be decreased
        if (lastDecay > currentTime) {
            uint256 secondsUntil;
            unchecked {
                secondsUntil = lastDecay - currentTime;
            }
            return
                markets[id_].totalDebt.mulDiv(
                    uint256(meta.debtDecayInterval) + secondsUntil,
                    uint256(meta.debtDecayInterval)
                );
        } else {
            uint256 secondsSince;
            unchecked {
                secondsSince = currentTime - lastDecay;
            }
            return
                secondsSince > meta.debtDecayInterval
                    ? 0
                    : markets[id_].totalDebt.mulDiv(
                        uint256(meta.debtDecayInterval) - secondsSince,
                        uint256(meta.debtDecayInterval)
                    );
        }
    }

    /// @inheritdoc IBondSDA
    function currentControlVariable(uint256 id_) public view override returns (uint256) {
        (uint256 decay, , ) = _controlDecay(id_);
        return terms[id_].controlVariable - decay;
    }

    /// @inheritdoc IBondAuctioneer
    function isInstantSwap(uint256 id_) public view returns (bool) {
        uint256 vesting = terms[id_].vesting;
        return (vesting <= MAX_FIXED_TERM) ? vesting == 0 : vesting <= block.timestamp;
    }

    /// @inheritdoc IBondAuctioneer
    function isLive(uint256 id_) public view override returns (bool) {
        return (markets[id_].capacity != 0 &&
            terms[id_].conclusion > uint48(block.timestamp) &&
            terms[id_].start <= uint48(block.timestamp));
    }

    /// @inheritdoc IBondAuctioneer
    function ownerOf(uint256 id_) external view override returns (address) {
        return markets[id_].owner;
    }

    /// @inheritdoc IBondAuctioneer
    function getTeller() external view override returns (IBondTeller) {
        return _teller;
    }

    /// @inheritdoc IBondAuctioneer
    function getAggregator() external view override returns (IBondAggregator) {
        return _aggregator;
    }

    /// @inheritdoc IBondAuctioneer
    function currentCapacity(uint256 id_) external view override returns (uint256) {
        return markets[id_].capacity;
    }
}

File 3 of 12 : IBondTeller.sol
// SPDX-License-Identifier: AGPL-3.0
pragma solidity >=0.8.0;

import {ERC20} from "solmate/tokens/ERC20.sol";

interface IBondTeller {
    /// @notice                 Exchange quote tokens for a bond in a specified market
    /// @param recipient_       Address of recipient of bond. Allows deposits for other addresses
    /// @param referrer_        Address of referrer who will receive referral fee. For frontends to fill.
    ///                         Direct calls can use the zero address for no referrer fee.
    /// @param id_              ID of the Market the bond is being purchased from
    /// @param amount_          Amount to deposit in exchange for bond
    /// @param minAmountOut_    Minimum acceptable amount of bond to receive. Prevents frontrunning
    /// @return                 Amount of payout token to be received from the bond
    /// @return                 Timestamp at which the bond token can be redeemed for the underlying token
    function purchase(
        address recipient_,
        address referrer_,
        uint256 id_,
        uint256 amount_,
        uint256 minAmountOut_
    ) external returns (uint256, uint48);

    /// @notice          Get current fee charged by the teller based on the combined protocol and referrer fee
    /// @param referrer_ Address of the referrer
    /// @return          Fee in basis points (3 decimal places)
    function getFee(address referrer_) external view returns (uint48);

    /// @notice         Set protocol fee
    /// @notice         Must be guardian
    /// @param fee_     Protocol fee in basis points (3 decimal places)
    function setProtocolFee(uint48 fee_) external;

    /// @notice          Set the discount for creating bond tokens from the base protocol fee
    /// @dev             The discount is subtracted from the protocol fee to determine the fee
    ///                  when using create() to mint bond tokens without using an Auctioneer
    /// @param discount_ Create Fee Discount in basis points (3 decimal places)
    function setCreateFeeDiscount(uint48 discount_) external;

    /// @notice         Set your fee as a referrer to the protocol
    /// @notice         Fee is set for sending address
    /// @param fee_     Referrer fee in basis points (3 decimal places)
    function setReferrerFee(uint48 fee_) external;

    /// @notice         Claim fees accrued by sender in the input tokens and sends them to the provided address
    /// @param tokens_  Array of tokens to claim fees for
    /// @param to_      Address to send fees to
    function claimFees(ERC20[] memory tokens_, address to_) external;
}

File 4 of 12 : ERC20.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

/// @notice Modern and gas efficient ERC20 + EIP-2612 implementation.
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC20.sol)
/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v2-core/blob/master/contracts/UniswapV2ERC20.sol)
/// @dev Do not manually set balances without updating totalSupply, as the sum of all user balances must not exceed it.
abstract contract ERC20 {
    /*///////////////////////////////////////////////////////////////
                                  EVENTS
    //////////////////////////////////////////////////////////////*/

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

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

    /*///////////////////////////////////////////////////////////////
                             METADATA STORAGE
    //////////////////////////////////////////////////////////////*/

    string public name;

    string public symbol;

    uint8 public immutable decimals;

    /*///////////////////////////////////////////////////////////////
                              ERC20 STORAGE
    //////////////////////////////////////////////////////////////*/

    uint256 public totalSupply;

    mapping(address => uint256) public balanceOf;

    mapping(address => mapping(address => uint256)) public allowance;

    /*///////////////////////////////////////////////////////////////
                             EIP-2612 STORAGE
    //////////////////////////////////////////////////////////////*/

    bytes32 public constant PERMIT_TYPEHASH =
        keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");

    uint256 internal immutable INITIAL_CHAIN_ID;

    bytes32 internal immutable INITIAL_DOMAIN_SEPARATOR;

    mapping(address => uint256) public nonces;

    /*///////////////////////////////////////////////////////////////
                               CONSTRUCTOR
    //////////////////////////////////////////////////////////////*/

    constructor(
        string memory _name,
        string memory _symbol,
        uint8 _decimals
    ) {
        name = _name;
        symbol = _symbol;
        decimals = _decimals;

        INITIAL_CHAIN_ID = block.chainid;
        INITIAL_DOMAIN_SEPARATOR = computeDomainSeparator();
    }

    /*///////////////////////////////////////////////////////////////
                              ERC20 LOGIC
    //////////////////////////////////////////////////////////////*/

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

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

        return true;
    }

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

        // Cannot overflow because the sum of all user
        // balances can't exceed the max uint256 value.
        unchecked {
            balanceOf[to] += amount;
        }

        emit Transfer(msg.sender, to, amount);

        return true;
    }

    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) public virtual returns (bool) {
        uint256 allowed = allowance[from][msg.sender]; // Saves gas for limited approvals.

        if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - amount;

        balanceOf[from] -= amount;

        // Cannot overflow because the sum of all user
        // balances can't exceed the max uint256 value.
        unchecked {
            balanceOf[to] += amount;
        }

        emit Transfer(from, to, amount);

        return true;
    }

    /*///////////////////////////////////////////////////////////////
                              EIP-2612 LOGIC
    //////////////////////////////////////////////////////////////*/

    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) public virtual {
        require(deadline >= block.timestamp, "PERMIT_DEADLINE_EXPIRED");

        // Unchecked because the only math done is incrementing
        // the owner's nonce which cannot realistically overflow.
        unchecked {
            bytes32 digest = keccak256(
                abi.encodePacked(
                    "\x19\x01",
                    DOMAIN_SEPARATOR(),
                    keccak256(abi.encode(PERMIT_TYPEHASH, owner, spender, value, nonces[owner]++, deadline))
                )
            );

            address recoveredAddress = ecrecover(digest, v, r, s);

            require(recoveredAddress != address(0) && recoveredAddress == owner, "INVALID_SIGNER");

            allowance[recoveredAddress][spender] = value;
        }

        emit Approval(owner, spender, value);
    }

    function DOMAIN_SEPARATOR() public view virtual returns (bytes32) {
        return block.chainid == INITIAL_CHAIN_ID ? INITIAL_DOMAIN_SEPARATOR : computeDomainSeparator();
    }

    function computeDomainSeparator() internal view virtual returns (bytes32) {
        return
            keccak256(
                abi.encode(
                    keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"),
                    keccak256(bytes(name)),
                    keccak256("1"),
                    block.chainid,
                    address(this)
                )
            );
    }

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

    function _mint(address to, uint256 amount) internal virtual {
        totalSupply += amount;

        // Cannot overflow because the sum of all user
        // balances can't exceed the max uint256 value.
        unchecked {
            balanceOf[to] += amount;
        }

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

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

        // Cannot underflow because a user's balance
        // will never be larger than the total supply.
        unchecked {
            totalSupply -= amount;
        }

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

File 5 of 12 : ReentrancyGuard.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

/// @notice Gas optimized reentrancy protection for smart contracts.
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/ReentrancyGuard.sol)
/// @author Modified from OpenZeppelin (https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/security/ReentrancyGuard.sol)
abstract contract ReentrancyGuard {
    uint256 private locked = 1;

    modifier nonReentrant() {
        require(locked == 1, "REENTRANCY");

        locked = 2;

        _;

        locked = 1;
    }
}

File 6 of 12 : Auth.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

/// @notice Provides a flexible and updatable auth pattern which is completely separate from application logic.
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/auth/Auth.sol)
/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)
abstract contract Auth {
    event OwnerUpdated(address indexed user, address indexed newOwner);

    event AuthorityUpdated(address indexed user, Authority indexed newAuthority);

    address public owner;

    Authority public authority;

    constructor(address _owner, Authority _authority) {
        owner = _owner;
        authority = _authority;

        emit OwnerUpdated(msg.sender, _owner);
        emit AuthorityUpdated(msg.sender, _authority);
    }

    modifier requiresAuth() {
        require(isAuthorized(msg.sender, msg.sig), "UNAUTHORIZED");

        _;
    }

    function isAuthorized(address user, bytes4 functionSig) internal view virtual returns (bool) {
        Authority auth = authority; // Memoizing authority saves us a warm SLOAD, around 100 gas.

        // Checking if the caller is the owner only after calling the authority saves gas in most cases, but be
        // aware that this makes protected functions uncallable even to the owner if the authority is out of order.
        return (address(auth) != address(0) && auth.canCall(user, address(this), functionSig)) || user == owner;
    }

    function setAuthority(Authority newAuthority) public virtual {
        // We check if the caller is the owner first because we want to ensure they can
        // always swap out the authority even if it's reverting or using up a lot of gas.
        require(msg.sender == owner || authority.canCall(msg.sender, address(this), msg.sig));

        authority = newAuthority;

        emit AuthorityUpdated(msg.sender, newAuthority);
    }

    function setOwner(address newOwner) public virtual requiresAuth {
        owner = newOwner;

        emit OwnerUpdated(msg.sender, newOwner);
    }
}

/// @notice A generic interface for a contract which provides authorization data to an Auth instance.
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/auth/Auth.sol)
/// @author Modified from Dappsys (https://github.com/dapphub/ds-auth/blob/master/src/auth.sol)
interface Authority {
    function canCall(
        address user,
        address target,
        bytes4 functionSig
    ) external view returns (bool);
}

File 7 of 12 : IBondSDA.sol
// SPDX-License-Identifier: AGPL-3.0
pragma solidity >=0.8.0;

import {ERC20} from "solmate/tokens/ERC20.sol";
import {IBondAuctioneer} from "../interfaces/IBondAuctioneer.sol";

interface IBondSDA is IBondAuctioneer {
    /// @notice Main information pertaining to bond market
    struct BondMarket {
        address owner; // market owner. sends payout tokens, receives quote tokens (defaults to creator)
        ERC20 payoutToken; // token to pay depositors with
        ERC20 quoteToken; // token to accept as payment
        address callbackAddr; // address to call for any operations on bond purchase. Must inherit to IBondCallback.
        bool capacityInQuote; // capacity limit is in payment token (true) or in payout (false, default)
        uint256 capacity; // capacity remaining
        uint256 totalDebt; // total payout token debt from market
        uint256 minPrice; // minimum price (hard floor for the market)
        uint256 maxPayout; // max payout tokens out in one order
        uint256 sold; // payout tokens out
        uint256 purchased; // quote tokens in
        uint256 scale; // scaling factor for the market (see MarketParams struct)
    }

    /// @notice Information used to control how a bond market changes
    struct BondTerms {
        uint256 controlVariable; // scaling variable for price
        uint256 maxDebt; // max payout token debt accrued
        uint48 start; // timestamp when market starts
        uint48 conclusion; // timestamp when market no longer offered
        uint48 vesting; // length of time from deposit to expiry if fixed-term, vesting timestamp if fixed-expiry
    }

    /// @notice Data needed for tuning bond market
    /// @dev Durations are stored in uint32 (not int32) and timestamps are stored in uint48, so is not subject to Y2K38 overflow
    struct BondMetadata {
        uint48 lastTune; // last timestamp when control variable was tuned
        uint48 lastDecay; // last timestamp when market was created and debt was decayed
        uint32 depositInterval; // target frequency of deposits
        uint32 tuneInterval; // frequency of tuning
        uint32 tuneAdjustmentDelay; // time to implement downward tuning adjustments
        uint32 debtDecayInterval; // interval over which debt should decay completely
        uint256 tuneIntervalCapacity; // capacity expected to be used during a tuning interval
        uint256 tuneBelowCapacity; // capacity that the next tuning will occur at
        uint256 lastTuneDebt; // target debt calculated at last tuning
    }

    /// @notice Control variable adjustment data
    struct Adjustment {
        uint256 change;
        uint48 lastAdjustment;
        uint48 timeToAdjusted; // how long until adjustment happens
        bool active;
    }

    /// @notice             Parameters to create a new bond market
    /// @dev                Note price should be passed in a specific format:
    ///                     formatted price = (payoutPriceCoefficient / quotePriceCoefficient)
    ///                             * 10**(36 + scaleAdjustment + quoteDecimals - payoutDecimals + payoutPriceDecimals - quotePriceDecimals)
    ///                     where:
    ///                         payoutDecimals - Number of decimals defined for the payoutToken in its ERC20 contract
    ///                         quoteDecimals - Number of decimals defined for the quoteToken in its ERC20 contract
    ///                         payoutPriceCoefficient - The coefficient of the payoutToken price in scientific notation (also known as the significant digits)
    ///                         payoutPriceDecimals - The significand of the payoutToken price in scientific notation (also known as the base ten exponent)
    ///                         quotePriceCoefficient - The coefficient of the quoteToken price in scientific notation (also known as the significant digits)
    ///                         quotePriceDecimals - The significand of the quoteToken price in scientific notation (also known as the base ten exponent)
    ///                         scaleAdjustment - see below
    ///                         * In the above definitions, the "prices" need to have the same unit of account (i.e. both in OHM, $, ETH, etc.)
    ///                         If price is not provided in this format, the market will not behave as intended.
    /// @param params_      Encoded bytes array, with the following elements
    /// @dev                    0. Payout Token (token paid out)
    /// @dev                    1. Quote Token (token to be received)
    /// @dev                    2. Callback contract address, should conform to IBondCallback. If 0x00, tokens will be transferred from market.owner
    /// @dev                    3. Is Capacity in Quote Token?
    /// @dev                    4. Capacity (amount in quoteDecimals or amount in payoutDecimals)
    /// @dev                    5. Formatted initial price (see note above)
    /// @dev                    6. Formatted minimum price (see note above)
    /// @dev                    7. Debt buffer. Percent with 3 decimals. Percentage over the initial debt to allow the market to accumulate at anyone time.
    /// @dev                       Works as a circuit breaker for the market in case external conditions incentivize massive buying (e.g. stablecoin depeg).
    /// @dev                       Minimum is the greater of 10% or initial max payout as a percentage of capacity.
    /// @dev                       If the value is too small, the market will not be able function normally and close prematurely.
    /// @dev                       If the value is too large, the market will not circuit break when intended. The value must be > 10% but can exceed 100% if desired.
    /// @dev                       A good heuristic to calculate a debtBuffer with is to determine the amount of capacity that you think is reasonable to be expended
    /// @dev                       in a short duration as a percent, e.g. 25%. Then a reasonable debtBuffer would be: 0.25 * 1e3 * decayInterval / marketDuration
    /// @dev                       where decayInterval = max(3 days, 5 * depositInterval) and marketDuration = conclusion - creation time.
    /// @dev                    8. Is fixed term ? Vesting length (seconds) : Vesting expiry (timestamp).
    /// @dev                        A 'vesting' param longer than 50 years is considered a timestamp for fixed expiry.
    /// @dev                    9. Start Time of the Market (timestamp) - Allows starting a market in the future.
    /// @dev                        If a start time is provided, the txn must be sent prior to the start time (functions as a deadline).
    /// @dev                        If start time is not provided (i.e. 0), the market will start immediately.
    /// @dev                    10. Market Duration (seconds) - Duration of the market in seconds.
    /// @dev                    11. Deposit interval (seconds)
    /// @dev                    12. Market scaling factor adjustment, ranges from -24 to +24 within the configured market bounds.
    /// @dev                        Should be calculated as: (payoutDecimals - quoteDecimals) - ((payoutPriceDecimals - quotePriceDecimals) / 2)
    /// @dev                        Providing a scaling factor adjustment that doesn't follow this formula could lead to under or overflow errors in the market.
    /// @return                 ID of new bond market
    struct MarketParams {
        ERC20 payoutToken;
        ERC20 quoteToken;
        address callbackAddr;
        bool capacityInQuote;
        uint256 capacity;
        uint256 formattedInitialPrice;
        uint256 formattedMinimumPrice;
        uint32 debtBuffer;
        uint48 vesting;
        uint48 start;
        uint32 duration;
        uint32 depositInterval;
        int8 scaleAdjustment;
    }

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

    /// @notice             Calculate current market price of payout token in quote tokens
    /// @dev                Accounts for debt and control variable decay since last deposit (vs _marketPrice())
    /// @param id_          ID of market
    /// @return             Price for market in configured decimals (see MarketParams)
    //
    // price is derived from the equation
    //
    // p = c * d
    //
    // where
    // p = price
    // c = control variable
    // d = debt
    //
    // d -= ( d * (dt / l) )
    //
    // where
    // dt = change in time
    // l = length of program
    //
    // if price is below minimum price, minimum price is returned
    // this is enforced on deposits by manipulating total debt (see _decay())
    function marketPrice(uint256 id_) external view override returns (uint256);

    /// @notice             Calculate debt factoring in decay
    /// @dev                Accounts for debt decay since last deposit
    /// @param id_          ID of market
    /// @return             Current debt for market in payout token decimals
    function currentDebt(uint256 id_) external view returns (uint256);

    /// @notice             Up to date control variable
    /// @dev                Accounts for control variable adjustment
    /// @param id_          ID of market
    /// @return             Control variable for market in payout token decimals
    function currentControlVariable(uint256 id_) external view returns (uint256);

    /// @notice             Calculate max payout of the market in payout tokens
    /// @dev                Returns a dynamically calculated payout or the maximum set by the creator, whichever is less.
    /// @param id_          ID of market
    /// @return             Current max payout for the market in payout tokens
    function maxPayout(uint256 id_) external view returns (uint256);
}

File 8 of 12 : IBondCallback.sol
// SPDX-License-Identifier: AGPL-3.0
pragma solidity >=0.8.0;

import {ERC20} from "solmate/tokens/ERC20.sol";

interface IBondCallback {
    /// @notice                 Send payout tokens to Teller while allowing market owners to perform custom logic on received or paid out tokens
    /// @notice                 Market ID on Teller must be whitelisted
    /// @param id_              ID of the market
    /// @param inputAmount_     Amount of quote tokens bonded to the market
    /// @param outputAmount_    Amount of payout tokens to be paid out to the market
    /// @dev Must transfer the output amount of payout tokens back to the Teller
    /// @dev Should check that the quote tokens have been transferred to the contract in the _callback function
    function callback(
        uint256 id_,
        uint256 inputAmount_,
        uint256 outputAmount_
    ) external;

    /// @notice         Returns the number of quote tokens received and payout tokens paid out for a market
    /// @param id_      ID of the market
    /// @return in_     Amount of quote tokens bonded to the market
    /// @return out_    Amount of payout tokens paid out to the market
    function amountsForMarket(uint256 id_) external view returns (uint256 in_, uint256 out_);

    /// @notice         Whitelist a teller and market ID combination
    /// @notice         Must be callback owner
    /// @param teller_  Address of the Teller contract which serves the market
    /// @param id_      ID of the market
    function whitelist(address teller_, uint256 id_) external;

    /// @notice Remove a market ID on a teller from the whitelist
    /// @dev    Shutdown function in case there's an issue with the teller
    /// @param  teller_ Address of the Teller contract which serves the market
    /// @param  id_     ID of the market to remove from whitelist
    function blacklist(address teller_, uint256 id_) external;

    /// @notice         Withdraw tokens from the callback and update balances
    /// @notice         Only callback owner
    /// @param to_      Address of the recipient
    /// @param token_   Address of the token to withdraw
    /// @param amount_  Amount of tokens to withdraw
    function withdraw(
        address to_,
        ERC20 token_,
        uint256 amount_
    ) external;

    /// @notice         Deposit tokens to the callback and update balances
    /// @notice         Only callback owner
    /// @param token_   Address of the token to deposit
    /// @param amount_  Amount of tokens to deposit
    function deposit(ERC20 token_, uint256 amount_) external;
}

File 9 of 12 : IBondAggregator.sol
// SPDX-License-Identifier: AGPL-3.0
pragma solidity >=0.8.0;

import {ERC20} from "solmate/tokens/ERC20.sol";
import {IBondAuctioneer} from "../interfaces/IBondAuctioneer.sol";
import {IBondTeller} from "../interfaces/IBondTeller.sol";

interface IBondAggregator {
    /// @notice             Register a auctioneer with the aggregator
    /// @notice             Only Guardian
    /// @param auctioneer_  Address of the Auctioneer to register
    /// @dev                A auctioneer must be registered with an aggregator to create markets
    function registerAuctioneer(IBondAuctioneer auctioneer_) external;

    /// @notice             Register a new market with the aggregator
    /// @notice             Only registered depositories
    /// @param payoutToken_ Token to be paid out by the market
    /// @param quoteToken_  Token to be accepted by the market
    /// @param marketId     ID of the market being created
    function registerMarket(ERC20 payoutToken_, ERC20 quoteToken_)
        external
        returns (uint256 marketId);

    /// @notice     Get the auctioneer for the provided market ID
    /// @param id_  ID of Market
    function getAuctioneer(uint256 id_) external view returns (IBondAuctioneer);

    /// @notice             Calculate current market price of payout token in quote tokens
    /// @dev                Accounts for debt and control variable decay since last deposit (vs _marketPrice())
    /// @param id_          ID of market
    /// @return             Price for market (see the specific auctioneer for units)
    //
    // if price is below minimum price, minimum price is returned
    // this is enforced on deposits by manipulating total debt (see _decay())
    function marketPrice(uint256 id_) external view returns (uint256);

    /// @notice             Scale value to use when converting between quote token and payout token amounts with marketPrice()
    /// @param id_          ID of market
    /// @return             Scaling factor for market in configured decimals
    function marketScale(uint256 id_) external view returns (uint256);

    /// @notice             Payout due for amount of quote tokens
    /// @dev                Accounts for debt and control variable decay so it is up to date
    /// @param amount_      Amount of quote tokens to spend
    /// @param id_          ID of market
    /// @param referrer_    Address of referrer, used to get fees to calculate accurate payout amount.
    ///                     Inputting the zero address will take into account just the protocol fee.
    /// @return             amount of payout tokens to be paid
    function payoutFor(
        uint256 amount_,
        uint256 id_,
        address referrer_
    ) external view returns (uint256);

    /// @notice             Returns maximum amount of quote token accepted by the market
    /// @param id_          ID of market
    /// @param referrer_    Address of referrer, used to get fees to calculate accurate payout amount.
    ///                     Inputting the zero address will take into account just the protocol fee.
    function maxAmountAccepted(uint256 id_, address referrer_) external view returns (uint256);

    /// @notice             Does market send payout immediately
    /// @param id_          Market ID to search for
    function isInstantSwap(uint256 id_) external view returns (bool);

    /// @notice             Is a given market accepting deposits
    /// @param id_          ID of market
    function isLive(uint256 id_) external view returns (bool);

    /// @notice             Returns array of active market IDs within a range
    /// @dev                Should be used if length exceeds max to query entire array
    function liveMarketsBetween(uint256 firstIndex_, uint256 lastIndex_)
        external
        view
        returns (uint256[] memory);

    /// @notice             Returns an array of all active market IDs for a given quote token
    /// @param token_       Address of token to query by
    /// @param isPayout_    If true, search by payout token, else search for quote token
    function liveMarketsFor(address token_, bool isPayout_)
        external
        view
        returns (uint256[] memory);

    /// @notice             Returns an array of all active market IDs for a given owner
    /// @param owner_       Address of owner to query by
    /// @param firstIndex_  Market ID to start at
    /// @param lastIndex_   Market ID to end at (non-inclusive)
    function liveMarketsBy(
        address owner_,
        uint256 firstIndex_,
        uint256 lastIndex_
    ) external view returns (uint256[] memory);

    /// @notice             Returns an array of all active market IDs for a given payout and quote token
    /// @param payout_      Address of payout token
    /// @param quote_       Address of quote token
    function marketsFor(address payout_, address quote_) external view returns (uint256[] memory);

    /// @notice                 Returns the market ID with the highest current payoutToken payout for depositing quoteToken
    /// @param payout_          Address of payout token
    /// @param quote_           Address of quote token
    /// @param amountIn_        Amount of quote tokens to deposit
    /// @param minAmountOut_    Minimum amount of payout tokens to receive as payout
    /// @param maxExpiry_       Latest acceptable vesting timestamp for bond
    ///                         Inputting the zero address will take into account just the protocol fee.
    function findMarketFor(
        address payout_,
        address quote_,
        uint256 amountIn_,
        uint256 minAmountOut_,
        uint256 maxExpiry_
    ) external view returns (uint256 id);

    /// @notice             Returns the Teller that services the market ID
    function getTeller(uint256 id_) external view returns (IBondTeller);

    /// @notice             Returns current capacity of a market
    function currentCapacity(uint256 id_) external view returns (uint256);
}

File 10 of 12 : TransferHelper.sol
// SPDX-License-Identifier: AGPL-3.0-only
pragma solidity >=0.8.0;

import {ERC20} from "solmate/tokens/ERC20.sol";

/// @notice Safe ERC20 and ETH transfer library that safely handles missing return values.
/// @author Modified from Uniswap (https://github.com/Uniswap/uniswap-v3-periphery/blob/main/contracts/libraries/TransferHelper.sol)
/// @author Taken from Solmate.
library TransferHelper {
    function safeTransferFrom(
        ERC20 token,
        address from,
        address to,
        uint256 amount
    ) internal {
        (bool success, bytes memory data) = address(token).call(
            abi.encodeWithSelector(ERC20.transferFrom.selector, from, to, amount)
        );

        require(
            success &&
                (data.length == 0 || abi.decode(data, (bool))) &&
                address(token).code.length > 0,
            "TRANSFER_FROM_FAILED"
        );
    }

    function safeTransfer(
        ERC20 token,
        address to,
        uint256 amount
    ) internal {
        (bool success, bytes memory data) = address(token).call(
            abi.encodeWithSelector(ERC20.transfer.selector, to, amount)
        );

        require(
            success &&
                (data.length == 0 || abi.decode(data, (bool))) &&
                address(token).code.length > 0,
            "TRANSFER_FAILED"
        );
    }

    // function safeApprove(
    //     ERC20 token,
    //     address to,
    //     uint256 amount
    // ) internal {
    //     (bool success, bytes memory data) = address(token).call(
    //         abi.encodeWithSelector(ERC20.approve.selector, to, amount)
    //     );

    //     require(success && (data.length == 0 || abi.decode(data, (bool))), "APPROVE_FAILED");
    // }

    // function safeTransferETH(address to, uint256 amount) internal {
    //     (bool success, ) = to.call{value: amount}(new bytes(0));

    //     require(success, "ETH_TRANSFER_FAILED");
    // }
}

File 11 of 12 : FullMath.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0;

/// @title Contains 512-bit math functions
/// @notice Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision
/// @dev Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits
library FullMath {
    /// @notice Calculates floor(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
    /// @param a The multiplicand
    /// @param b The multiplier
    /// @param denominator The divisor
    /// @return result The 256-bit result
    /// @dev Credit to Remco Bloemen under MIT license https://xn--2-umb.com/21/muldiv
    function mulDiv(
        uint256 a,
        uint256 b,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = a * b
            // Compute the product mod 2**256 and mod 2**256 - 1
            // then 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(a, b, not(0))
                prod0 := mul(a, b)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division
            if (prod1 == 0) {
                require(denominator > 0);
                assembly {
                    result := div(prod0, denominator)
                }
                return result;
            }

            // 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]
            // Compute remainder using mulmod
            uint256 remainder;
            assembly {
                remainder := mulmod(a, b, denominator)
            }
            // Subtract 256 bit number from 512 bit number
            assembly {
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator
            // Compute largest power of two divisor of denominator.
            // Always >= 1.
            uint256 twos = (type(uint256).max - denominator + 1) & denominator;
            // Divide denominator by power of two
            assembly {
                denominator := div(denominator, twos)
            }

            // Divide [prod1 prod0] by the factors of two
            assembly {
                prod0 := div(prod0, twos)
            }
            // Shift in bits from prod1 into prod0. For this we need
            // to flip `twos` such that it is 2**256 / twos.
            // If twos is zero, then it becomes one
            assembly {
                twos := add(div(sub(0, twos), twos), 1)
            }
            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
            // correct for four bits. That is, denominator * inv = 1 mod 2**4
            uint256 inv = (3 * denominator) ^ 2;
            // Now use 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.
            inv *= 2 - denominator * inv; // inverse mod 2**8
            inv *= 2 - denominator * inv; // inverse mod 2**16
            inv *= 2 - denominator * inv; // inverse mod 2**32
            inv *= 2 - denominator * inv; // inverse mod 2**64
            inv *= 2 - denominator * inv; // inverse mod 2**128
            inv *= 2 - denominator * inv; // 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 precoditions 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 * inv;
            return result;
        }
    }

    /// @notice Calculates ceil(a×b÷denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
    /// @param a The multiplicand
    /// @param b The multiplier
    /// @param denominator The divisor
    /// @return result The 256-bit result
    function mulDivUp(
        uint256 a,
        uint256 b,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        result = mulDiv(a, b, denominator);
        unchecked {
            if (mulmod(a, b, denominator) > 0) {
                require(result < type(uint256).max);
                result++;
            }
        }
    }
}

File 12 of 12 : IBondAuctioneer.sol
// SPDX-License-Identifier: AGPL-3.0
pragma solidity >=0.8.0;

import {ERC20} from "solmate/tokens/ERC20.sol";
import {IBondTeller} from "../interfaces/IBondTeller.sol";
import {IBondAggregator} from "../interfaces/IBondAggregator.sol";

interface IBondAuctioneer {
    /// @notice                 Creates a new bond market
    /// @param params_          Configuration data needed for market creation, encoded in a bytes array
    /// @dev                    See specific auctioneer implementations for details on encoding the parameters.
    /// @return id              ID of new bond market
    function createMarket(bytes memory params_) external returns (uint256);

    /// @notice                 Disable existing bond market
    /// @notice                 Must be market owner
    /// @param id_              ID of market to close
    function closeMarket(uint256 id_) external;

    /// @notice                 Exchange quote tokens for a bond in a specified market
    /// @notice                 Must be teller
    /// @param id_              ID of the Market the bond is being purchased from
    /// @param amount_          Amount to deposit in exchange for bond (after fee has been deducted)
    /// @param minAmountOut_    Minimum acceptable amount of bond to receive. Prevents frontrunning
    /// @return payout          Amount of payout token to be received from the bond
    function purchaseBond(
        uint256 id_,
        uint256 amount_,
        uint256 minAmountOut_
    ) external returns (uint256 payout);

    /// @notice                         Set market intervals to different values than the defaults
    /// @notice                         Must be market owner
    /// @dev                            Changing the intervals could cause markets to behave in unexpected way
    ///                                 tuneInterval should be greater than tuneAdjustmentDelay
    /// @param id_                      Market ID
    /// @param intervals_               Array of intervals (3)
    ///                                 1. Tune interval - Frequency of tuning
    ///                                 2. Tune adjustment delay - Time to implement downward tuning adjustments
    ///                                 3. Debt decay interval - Interval over which debt should decay completely
    function setIntervals(uint256 id_, uint32[3] calldata intervals_) external;

    /// @notice                      Designate a new owner of a market
    /// @notice                      Must be market owner
    /// @dev                         Doesn't change permissions until newOwner calls pullOwnership
    /// @param id_                   Market ID
    /// @param newOwner_             New address to give ownership to
    function pushOwnership(uint256 id_, address newOwner_) external;

    /// @notice                      Accept ownership of a market
    /// @notice                      Must be market newOwner
    /// @dev                         The existing owner must call pushOwnership prior to the newOwner calling this function
    /// @param id_                   Market ID
    function pullOwnership(uint256 id_) external;

    /// @notice             Set the auctioneer defaults
    /// @notice             Must be policy
    /// @param defaults_    Array of default values
    ///                     1. Tune interval - amount of time between tuning adjustments
    ///                     2. Tune adjustment delay - amount of time to apply downward tuning adjustments
    ///                     3. Minimum debt decay interval - minimum amount of time to let debt decay to zero
    ///                     4. Minimum deposit interval - minimum amount of time to wait between deposits
    ///                     5. Minimum market duration - minimum amount of time a market can be created for
    ///                     6. Minimum debt buffer - the minimum amount of debt over the initial debt to trigger a market shutdown
    /// @dev                The defaults set here are important to avoid edge cases in market behavior, e.g. a very short market reacts doesn't tune well
    /// @dev                Only applies to new markets that are created after the change
    function setDefaults(uint32[6] memory defaults_) external;

    /// @notice             Change the status of the auctioneer to allow creation of new markets
    /// @dev                Setting to false and allowing active markets to end will sunset the auctioneer
    /// @param status_      Allow market creation (true) : Disallow market creation (false)
    function setAllowNewMarkets(bool status_) external;

    /// @notice             Change whether a market creator is allowed to use a callback address in their markets or not
    /// @notice             Must be guardian
    /// @dev                Callback is believed to be safe, but a whitelist is implemented to prevent abuse
    /// @param creator_     Address of market creator
    /// @param status_      Allow callback (true) : Disallow callback (false)
    function setCallbackAuthStatus(address creator_, bool status_) external;

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

    /// @notice                 Provides information for the Teller to execute purchases on a Market
    /// @param id_              Market ID
    /// @return owner           Address of the market owner (tokens transferred from this address if no callback)
    /// @return callbackAddr    Address of the callback contract to get tokens for payouts
    /// @return payoutToken     Payout Token (token paid out) for the Market
    /// @return quoteToken      Quote Token (token received) for the Market
    /// @return vesting         Timestamp or duration for vesting, implementation-dependent
    /// @return maxPayout       Maximum amount of payout tokens you can purchase in one transaction
    function getMarketInfoForPurchase(uint256 id_)
        external
        view
        returns (
            address owner,
            address callbackAddr,
            ERC20 payoutToken,
            ERC20 quoteToken,
            uint48 vesting,
            uint256 maxPayout
        );

    /// @notice             Calculate current market price of payout token in quote tokens
    /// @param id_          ID of market
    /// @return             Price for market in configured decimals
    //
    // if price is below minimum price, minimum price is returned
    function marketPrice(uint256 id_) external view returns (uint256);

    /// @notice             Scale value to use when converting between quote token and payout token amounts with marketPrice()
    /// @param id_          ID of market
    /// @return             Scaling factor for market in configured decimals
    function marketScale(uint256 id_) external view returns (uint256);

    /// @notice             Payout due for amount of quote tokens
    /// @dev                Accounts for debt and control variable decay so it is up to date
    /// @param amount_      Amount of quote tokens to spend
    /// @param id_          ID of market
    /// @param referrer_    Address of referrer, used to get fees to calculate accurate payout amount.
    ///                     Inputting the zero address will take into account just the protocol fee.
    /// @return             amount of payout tokens to be paid
    function payoutFor(
        uint256 amount_,
        uint256 id_,
        address referrer_
    ) external view returns (uint256);

    /// @notice             Returns maximum amount of quote token accepted by the market
    /// @param id_          ID of market
    /// @param referrer_    Address of referrer, used to get fees to calculate accurate payout amount.
    ///                     Inputting the zero address will take into account just the protocol fee.
    function maxAmountAccepted(uint256 id_, address referrer_) external view returns (uint256);

    /// @notice             Does market send payout immediately
    /// @param id_          Market ID to search for
    function isInstantSwap(uint256 id_) external view returns (bool);

    /// @notice             Is a given market accepting deposits
    /// @param id_          ID of market
    function isLive(uint256 id_) external view returns (bool);

    /// @notice             Returns the address of the market owner
    /// @param id_          ID of market
    function ownerOf(uint256 id_) external view returns (address);

    /// @notice             Returns the Teller that services the Auctioneer
    function getTeller() external view returns (IBondTeller);

    /// @notice             Returns the Aggregator that services the Auctioneer
    function getAggregator() external view returns (IBondAggregator);

    /// @notice             Returns current capacity of a market
    function currentCapacity(uint256 id_) external view returns (uint256);
}

Settings
{
  "remappings": [
    "clones-with-immutable-args/=lib/clones-with-immutable-args/src/",
    "clones/=lib/clones-with-immutable-args/src/",
    "ds-test/=lib/ds-test/src/",
    "forge-std/=lib/forge-std/src/",
    "hardhat/=node_modules/hardhat/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "openzeppelin/=lib/openzeppelin-contracts/contracts/",
    "solidity-code-metrics/=node_modules/solidity-code-metrics/",
    "solmate/=lib/solmate/src/",
    "weird-erc20/=lib/solmate/lib/weird-erc20/src/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 100000
  },
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "london",
  "libraries": {}
}

Contract ABI

[{"inputs":[{"internalType":"contract IBondTeller","name":"teller_","type":"address"},{"internalType":"contract IBondAggregator","name":"aggregator_","type":"address"},{"internalType":"address","name":"guardian_","type":"address"},{"internalType":"contract Authority","name":"authority_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"Auctioneer_AmountLessThanMinimum","type":"error"},{"inputs":[],"name":"Auctioneer_BadExpiry","type":"error"},{"inputs":[],"name":"Auctioneer_InitialPriceLessThanMin","type":"error"},{"inputs":[],"name":"Auctioneer_InvalidCallback","type":"error"},{"inputs":[],"name":"Auctioneer_InvalidParams","type":"error"},{"inputs":[],"name":"Auctioneer_MarketNotActive","type":"error"},{"inputs":[],"name":"Auctioneer_MaxPayoutExceeded","type":"error"},{"inputs":[],"name":"Auctioneer_NewMarketsNotAllowed","type":"error"},{"inputs":[],"name":"Auctioneer_NotAuthorized","type":"error"},{"inputs":[],"name":"Auctioneer_NotEnoughCapacity","type":"error"},{"inputs":[],"name":"Auctioneer_OnlyMarketOwner","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"contract Authority","name":"newAuthority","type":"address"}],"name":"AuthorityUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint32","name":"defaultTuneInterval","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"defaultTuneAdjustment","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"minDebtDecayInterval","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"minDepositInterval","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"minMarketDuration","type":"uint32"},{"indexed":false,"internalType":"uint32","name":"minDebtBuffer","type":"uint32"}],"name":"DefaultsUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"}],"name":"MarketClosed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":true,"internalType":"address","name":"payoutToken","type":"address"},{"indexed":true,"internalType":"address","name":"quoteToken","type":"address"},{"indexed":false,"internalType":"uint48","name":"vesting","type":"uint48"},{"indexed":false,"internalType":"uint256","name":"initialPrice","type":"uint256"}],"name":"MarketCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"oldControlVariable","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"newControlVariable","type":"uint256"}],"name":"Tuned","type":"event"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"adjustments","outputs":[{"internalType":"uint256","name":"change","type":"uint256"},{"internalType":"uint48","name":"lastAdjustment","type":"uint48"},{"internalType":"uint48","name":"timeToAdjusted","type":"uint48"},{"internalType":"bool","name":"active","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"allowNewMarkets","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"authority","outputs":[{"internalType":"contract Authority","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"callbackAuthorized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id_","type":"uint256"}],"name":"closeMarket","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"params_","type":"bytes"}],"name":"createMarket","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id_","type":"uint256"}],"name":"currentCapacity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id_","type":"uint256"}],"name":"currentControlVariable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id_","type":"uint256"}],"name":"currentDebt","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultTuneAdjustment","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultTuneInterval","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getAggregator","outputs":[{"internalType":"contract IBondAggregator","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id_","type":"uint256"}],"name":"getMarketInfoForPurchase","outputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"callbackAddr","type":"address"},{"internalType":"contract ERC20","name":"payoutToken","type":"address"},{"internalType":"contract ERC20","name":"quoteToken","type":"address"},{"internalType":"uint48","name":"vesting","type":"uint48"},{"internalType":"uint256","name":"maxPayout_","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getTeller","outputs":[{"internalType":"contract IBondTeller","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id_","type":"uint256"}],"name":"isInstantSwap","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id_","type":"uint256"}],"name":"isLive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id_","type":"uint256"}],"name":"marketPrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id_","type":"uint256"}],"name":"marketScale","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"markets","outputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"contract ERC20","name":"payoutToken","type":"address"},{"internalType":"contract ERC20","name":"quoteToken","type":"address"},{"internalType":"address","name":"callbackAddr","type":"address"},{"internalType":"bool","name":"capacityInQuote","type":"bool"},{"internalType":"uint256","name":"capacity","type":"uint256"},{"internalType":"uint256","name":"totalDebt","type":"uint256"},{"internalType":"uint256","name":"minPrice","type":"uint256"},{"internalType":"uint256","name":"maxPayout","type":"uint256"},{"internalType":"uint256","name":"sold","type":"uint256"},{"internalType":"uint256","name":"purchased","type":"uint256"},{"internalType":"uint256","name":"scale","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id_","type":"uint256"},{"internalType":"address","name":"referrer_","type":"address"}],"name":"maxAmountAccepted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id_","type":"uint256"}],"name":"maxPayout","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"metadata","outputs":[{"internalType":"uint48","name":"lastTune","type":"uint48"},{"internalType":"uint48","name":"lastDecay","type":"uint48"},{"internalType":"uint32","name":"depositInterval","type":"uint32"},{"internalType":"uint32","name":"tuneInterval","type":"uint32"},{"internalType":"uint32","name":"tuneAdjustmentDelay","type":"uint32"},{"internalType":"uint32","name":"debtDecayInterval","type":"uint32"},{"internalType":"uint256","name":"tuneIntervalCapacity","type":"uint256"},{"internalType":"uint256","name":"tuneBelowCapacity","type":"uint256"},{"internalType":"uint256","name":"lastTuneDebt","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minDebtBuffer","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minDebtDecayInterval","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minDepositInterval","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"minMarketDuration","outputs":[{"internalType":"uint32","name":"","type":"uint32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"newOwners","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id_","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount_","type":"uint256"},{"internalType":"uint256","name":"id_","type":"uint256"},{"internalType":"address","name":"referrer_","type":"address"}],"name":"payoutFor","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"id_","type":"uint256"}],"name":"pullOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id_","type":"uint256"},{"internalType":"uint256","name":"amount_","type":"uint256"},{"internalType":"uint256","name":"minAmountOut_","type":"uint256"}],"name":"purchaseBond","outputs":[{"internalType":"uint256","name":"payout","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id_","type":"uint256"},{"internalType":"address","name":"newOwner_","type":"address"}],"name":"pushOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"status_","type":"bool"}],"name":"setAllowNewMarkets","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract Authority","name":"newAuthority","type":"address"}],"name":"setAuthority","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"creator_","type":"address"},{"internalType":"bool","name":"status_","type":"bool"}],"name":"setCallbackAuthStatus","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32[6]","name":"defaults_","type":"uint32[6]"}],"name":"setDefaults","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"id_","type":"uint256"},{"internalType":"uint32[3]","name":"intervals_","type":"uint32[3]"}],"name":"setIntervals","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"setOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"terms","outputs":[{"internalType":"uint256","name":"controlVariable","type":"uint256"},{"internalType":"uint256","name":"maxDebt","type":"uint256"},{"internalType":"uint48","name":"start","type":"uint48"},{"internalType":"uint48","name":"conclusion","type":"uint48"},{"internalType":"uint48","name":"vesting","type":"uint48"}],"stateMutability":"view","type":"function"}]

60c06040523480156200001157600080fd5b5060405162004a8e38038062004a8e83398101604081905262000034916200013d565b600080546001600160a01b03199081166001600160a01b0385811691821784556001805490931690851617909155604051869286928692869284928492909133917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d769190a36040516001600160a01b0382169033907fa3396fd7f6e0a21b50e5089d2da70d5ac0a3bbbd1f617a93f134b7638998019890600090a3505050506001600160a01b039081166080521660a0525050600980546001600160c01b0319167527100001518000000e100003f480000054600001518017905550506007805460ff19166001179055620001a5565b6001600160a01b03811681146200013a57600080fd5b50565b600080600080608085870312156200015457600080fd5b8451620001618162000124565b6020860151909450620001748162000124565b6040860151909350620001878162000124565b60608601519092506200019a8162000124565b939692955090935050565b60805160a0516148a7620001e76000396000818161053e01528181611f31015281816121b9015261226c0152600081816103630152612ba001526148a76000f3fe608060405234801561001057600080fd5b50600436106102c85760003560e01c8063acc5570c1161017b578063bf7e214f116100d8578063d9ccdc931161008c578063e3684e3911610071578063e3684e3914610907578063e922067314610a1b578063ea0aca3314610a3757600080fd5b8063d9ccdc93146108e4578063e007fa97146108f457600080fd5b8063c7bf8ca0116100bd578063c7bf8ca01461088d578063d2040687146108a0578063d2bee323146108c057600080fd5b8063bf7e214f146107df578063c0aa0e8a146107ff57600080fd5b8063bc3b2b121161012f578063bcf6cde811610114578063bcf6cde8146107a6578063bd1f3a5e146107b9578063bf48582b146107cc57600080fd5b8063bc3b2b121461070f578063bcb296671461079357600080fd5b8063afa9d3b011610160578063afa9d3b0146105de578063b1283e77146105eb578063bbbdd95a146106fc57600080fd5b8063acc5570c14610562578063ae418095146105cb57600080fd5b80635f77274e116102295780638973082c116101dd5780638da5cb5b116101c25780638da5cb5b146104f9578063946824cd146105195780639787d1071461053c57600080fd5b80638973082c146104a95780638b098db3146104e657600080fd5b80636729a41e1161020e5780636729a41e1461044d578063699e17d9146104835780637a9e5e4b1461049657600080fd5b80635f77274e146104045780636352211e1461041757600080fd5b80633ad59dbc1161028057806353c7f8e01161026557806353c7f8e0146103bb57806357e333ba146103ce5780635dc4d16b146103e157600080fd5b80633ad59dbc146103615780633adec5a7146103a857600080fd5b806313af4035116102b157806313af4035146103085780631c063a6c1461031b578063275074581461033e57600080fd5b80630a9d85eb146102cd57806310b05317146102f3575b600080fd5b6102e06102db3660046142c4565b610a4f565b6040519081526020015b60405180910390f35b6103066103013660046142c4565b610a81565b005b61030661031636600461430f565b610b3c565b6102e06103293660046142c4565b60009081526002602052604090206004015490565b61035161034c3660046142c4565b610c45565b60405190151581526020016102ea565b7f00000000000000000000000000000000000000000000000000000000000000005b60405173ffffffffffffffffffffffffffffffffffffffff90911681526020016102ea565b6102e06103b63660046142c4565b610cb8565b6102e06103c936600461432c565b610d1b565b6102e06103dc3660046142c4565b610dc3565b6103516103ef36600461430f565b60086020526000908152604090205460ff1681565b6103066104123660046143b7565b610ee8565b6103836104253660046142c4565b60009081526002602052604090205473ffffffffffffffffffffffffffffffffffffffff1690565b61038361045b3660046142c4565b60066020526000908152604090205473ffffffffffffffffffffffffffffffffffffffff1681565b6103066104913660046143d4565b610fad565b6103066104a436600461430f565b611448565b6009546104d19074010000000000000000000000000000000000000000900463ffffffff1681565b60405163ffffffff90911681526020016102ea565b6103516104f43660046142c4565b6115a5565b6000546103839073ffffffffffffffffffffffffffffffffffffffff1681565b6102e06105273660046142c4565b6000908152600260205260409020600a015490565b7f0000000000000000000000000000000000000000000000000000000000000000610383565b6105756105703660046142c4565b6115eb565b6040805173ffffffffffffffffffffffffffffffffffffffff97881681529587166020870152938616938501939093529316606083015265ffffffffffff909216608082015260a081019190915260c0016102ea565b6103066105d93660046142c4565b61170c565b6007546103519060ff1681565b6106826105f93660046142c4565b600260208190526000918252604090912080546001820154928201546003830154600484015460058501546006860154600787015460088801546009890154600a9099015473ffffffffffffffffffffffffffffffffffffffff9889169a891699978916988716977401000000000000000000000000000000000000000090970460ff1696908c565b6040805173ffffffffffffffffffffffffffffffffffffffff9d8e1681529b8d1660208d0152998c16998b0199909952999096166060890152931515608088015260a087019290925260c086015260e0850152610100840152610120830152610140820192909252610160810191909152610180016102ea565b61030661070a366004614407565b611775565b61076261071d3660046142c4565b6005602052600090815260409020805460019091015465ffffffffffff8082169166010000000000008104909116906c01000000000000000000000000900460ff1684565b6040516102ea949392919093845265ffffffffffff9283166020850152911660408301521515606082015260800190565b6102e06107a13660046142c4565b61185f565b6103066107b4366004614440565b611a04565b6103066107c73660046144d2565b611ab4565b6102e06107da366004614557565b611ee3565b6001546103839073ffffffffffffffffffffffffffffffffffffffff1681565b61085861080d3660046142c4565b60036020526000908152604090208054600182015460029092015490919065ffffffffffff80821691660100000000000081048216916c010000000000000000000000009091041685565b60408051958652602086019490945265ffffffffffff928316938501939093528116606084015216608082015260a0016102ea565b6102e061089b366004614440565b612032565b6009546104d1906c01000000000000000000000000900463ffffffff1681565b6009546104d190700100000000000000000000000000000000900463ffffffff1681565b6009546104d19063ffffffff1681565b6102e0610902366004614590565b612252565b6109be6109153660046142c4565b600460205260009081526040902080546001820154600283015460039093015465ffffffffffff80841694660100000000000085049091169363ffffffff6c0100000000000000000000000082048116947001000000000000000000000000000000008304821694740100000000000000000000000000000000000000008404831694780100000000000000000000000000000000000000000000000090940490921692909189565b6040805165ffffffffffff9a8b1681529990981660208a015263ffffffff96871697890197909752938516606088015291841660808701529290921660a085015260c084019190915260e0830152610100820152610120016102ea565b6009546104d19068010000000000000000900463ffffffff1681565b6009546104d190640100000000900463ffffffff1681565b600080610a5b8361259e565b5050600084815260036020526040902054909150610a7a9082906145eb565b9392505050565b60008181526006602052604090205473ffffffffffffffffffffffffffffffffffffffff163314610ade576040517f2c47703200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600090815260066020908152604080832054600290925290912080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff909216919091179055565b610b6a336000357fffffffff0000000000000000000000000000000000000000000000000000000016612679565b610bd5576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a4544000000000000000000000000000000000000000060448201526064015b60405180910390fd5b600080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff83169081178255604051909133917f8292fce18fa69edf4db7b94ea2e58241df0ae57f97e0a6c9b29067028bf92d769190a350565b60008181526002602052604081206004015415801590610c8a575060008281526003602052604090206002015465ffffffffffff428116660100000000000090920416115b8015610cb2575060008281526003602052604090206002015465ffffffffffff428116911611155b92915050565b600080610ce9610cc78461185f565b6000858152600260205260409020600a0154610ce286610a4f565b919061278a565b6000848152600260205260409020600601549091508111610cb257600083815260026020526040902060060154610a7a565b600080610d2a83850185614633565b905080610100015165ffffffffffff16600014158015610d7b57506201518081610100015165ffffffffffff161080610d7b5750635dba240065ffffffffffff1681610100015165ffffffffffff16115b15610db2576040517f3b596f5f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610dbb816127e8565b949350505050565b600080610dcf83610cb8565b6000848152600260208181526040808420815161018081018352815473ffffffffffffffffffffffffffffffffffffffff9081168252600183015481169482019490945293810154831691840191909152600381015491821660608401527401000000000000000000000000000000000000000090910460ff16151560808301819052600482015460a0840152600582015460c0840152600682015460e0840152600782015461010084015260088201546101208401526009820154610140840152600a9091015461016083015292935091610eaf578160a00151610ec4565b61016082015160a0830151610ec4918561356d565b90508082610100015111610edd57816101000151610edf565b805b95945050505050565b610f16336000357fffffffff0000000000000000000000000000000000000000000000000000000016612679565b610f7c576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a454400000000000000000000000000000000000000006044820152606401610bcc565b600780547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b610fb682610c45565b610fec576040517f3b596f5f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610ff9602082018261471c565b63ffffffff16158061101e5750611016604082016020830161471c565b63ffffffff16155b8061103c5750611034606082016040830161471c565b63ffffffff16155b15611073576040517f3b596f5f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611083604082016020830161471c565b63ffffffff16611096602083018361471c565b63ffffffff1610156110d4576040517f3b596f5f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000828152600460209081526040909120805490916c0100000000000000000000000090910463ffffffff169061110d9084018461471c565b63ffffffff16101561114b576040517f3b596f5f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60095468010000000000000000900463ffffffff16611170606084016040850161471c565b63ffffffff1610156111ae576040517f3b596f5f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600083815260026020818152604092839020835161018081018552815473ffffffffffffffffffffffffffffffffffffffff908116808352600184015482169483019490945293820154841694810194909452600381015492831660608501527401000000000000000000000000000000000000000090920460ff1615156080840152600482015460a0840152600582015460c0840152600682015460e0840152600782015461010084015260088201546101208401526009820154610140840152600a9091015461016083015233146112b4576040517f4e1c8b5d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6112c1602084018461471c565b825463ffffffff91909116700100000000000000000000000000000000027fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff90911617825561135b611316602085018561471c565b60008681526003602052604090206002015463ffffffff919091169061134f9042906601000000000000900465ffffffffffff166145eb565b60a0840151919061356d565b6001830181905560a082015111611373576000611387565b81600101548160a0015161138791906145eb565b600283015561139c604084016020850161471c565b825463ffffffff9190911674010000000000000000000000000000000000000000027fffffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffff9091161782556113f5606084016040850161471c565b825463ffffffff919091167801000000000000000000000000000000000000000000000000027fffffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffff90911617909155505050565b60005473ffffffffffffffffffffffffffffffffffffffff1633148061152b57506001546040517fb70096130000000000000000000000000000000000000000000000000000000081523360048201523060248201526000357fffffffff0000000000000000000000000000000000000000000000000000000016604482015273ffffffffffffffffffffffffffffffffffffffff9091169063b700961390606401602060405180830381865afa158015611507573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061152b9190614737565b61153457600080fd5b600180547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff831690811790915560405133907fa3396fd7f6e0a21b50e5089d2da70d5ac0a3bbbd1f617a93f134b7638998019890600090a350565b6000818152600360205260408120600201546c01000000000000000000000000900465ffffffffffff16635dba24008111156115e45742811115610a7a565b1592915050565b6000818152600260208181526040808420815161018081018352815473ffffffffffffffffffffffffffffffffffffffff90811680835260018401548216838701819052848801548316848701819052600380870154948516606087018190527401000000000000000000000000000000000000000090950460ff1615156080870152600487015460a0870152600587015460c0870152600687015460e0870152600787015461010087015260088701546101208701526009870154610140870152600a909601546101608601528a8a5294909652938720909501548695869586958695869594919392916c01000000000000000000000000900465ffffffffffff166116f78d610dc3565b949d939c50919a509850965090945092505050565b60008181526002602052604090205473ffffffffffffffffffffffffffffffffffffffff163314611769576040517f4e1c8b5d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61177281613639565b50565b6117a3336000357fffffffff0000000000000000000000000000000000000000000000000000000016612679565b611809576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a454400000000000000000000000000000000000000006044820152606401610bcc565b73ffffffffffffffffffffffffffffffffffffffff91909116600090815260086020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016911515919091179055565b600081815260036020526040812060020154429065ffffffffffff1681101561189957505060009081526002602052604090206005015490565b600083815260046020908152604091829020825161012081018452815465ffffffffffff8082168352660100000000000082041693820184905263ffffffff6c010000000000000000000000008204811695830195909552700100000000000000000000000000000000810485166060830152740100000000000000000000000000000000000000008104851660808301527801000000000000000000000000000000000000000000000000900490931660a0840152600181015460c0840152600281015460e084015260030154610100830152828111156119c55760a0820151838203906119bb9061199390839063ffffffff16614754565b60a0850151600089815260026020526040902060050154919063ffffffff9081169061356d16565b9695505050505050565b60a08201518184039063ffffffff1681116119f8576119f3818460a0015163ffffffff1661199391906145eb565b6119bb565b60009695505050505050565b60008281526002602052604090205473ffffffffffffffffffffffffffffffffffffffff163314611a61576040517f4e1c8b5d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60009182526006602052604090912080547fffffffffffffffffffffffff00000000000000000000000000000000000000001673ffffffffffffffffffffffffffffffffffffffff909216919091179055565b611ae2336000357fffffffff0000000000000000000000000000000000000000000000000000000016612679565b611b48576040517f08c379a000000000000000000000000000000000000000000000000000000000815260206004820152600c60248201527f554e415554484f52495a454400000000000000000000000000000000000000006044820152606401610bcc565b6020810151815163ffffffff91821691161015611b91576040517f3b596f5f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6060810151815163ffffffff91821691161015611bda576040517f3b596f5f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6080810151606082015163ffffffff91821691161115611c26576040517f3b596f5f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6060810151611c3690600561476c565b63ffffffff16816002602002015163ffffffff161015611c82576040517f3b596f5f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8060006020020151600980547fffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000001663ffffffff90921691909117905580600160200201516009805463ffffffff909216640100000000027fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff90921691909117905580600260200201516009805463ffffffff90921668010000000000000000027fffffffffffffffffffffffffffffffffffffffff00000000ffffffffffffffff90921691909117905580600360200201516009805463ffffffff9092166c01000000000000000000000000027fffffffffffffffffffffffffffffffff00000000ffffffffffffffffffffffff90921691909117905580600460200201516009805463ffffffff909216700100000000000000000000000000000000027fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff90921691909117905580600560209081029190910151600980547fffffffffffffffff00000000ffffffffffffffffffffffffffffffffffffffff81167401000000000000000000000000000000000000000063ffffffff9485168102918217938490556040805193861692861692909217835264010000000084048516958301959095526801000000000000000083048416908201526c010000000000000000000000008204831660608201527001000000000000000000000000000000008204831660808201529290041660a08201527fbbc02fa2138d26ec5ecb379612618d1b291bf5140167f3028178080953459c5a9060c00160405180910390a150565b6040517fb88c914800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff82811660048301526000918291611fb1917f00000000000000000000000000000000000000000000000000000000000000009091169063b88c914890602401602060405180830381865afa158015611f7a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611f9e9190614798565b869065ffffffffffff16620186a061356d565b6000858152600260205260408120600a015491925090611fe590611fd487610cb8565b611fde858a6145eb565b919061356d565b9050611ff085610dc3565b811115612029576040517f5c430eae00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b9150610a7a9050565b6000828152600260208181526040808420815161018081018352815473ffffffffffffffffffffffffffffffffffffffff9081168252600183015481169482019490945293810154831691840191909152600381015491821660608401527401000000000000000000000000000000000000000090910460ff1615156080830152600481015460a0830152600581015460c0830152600681015460e0830152600781015461010083015260088101546101208301526009810154610140830152600a01546101608201528161210685610cb8565b90506000826080015161212e5761016083015160a084015161212991849061356d565b612134565b8260a001515b905060006121578385610160015186610100015161356d9092919063ffffffff16565b90506000818310612168578161216a565b825b6040517fb88c914800000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff8981166004830152919250600091612239917f00000000000000000000000000000000000000000000000000000000000000009091169063b88c914890602401602060405180830381865afa158015612202573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906122269190614798565b839065ffffffffffff16620186a061356d565b90506122458183614754565b9998505050505050505050565b60003373ffffffffffffffffffffffffffffffffffffffff7f000000000000000000000000000000000000000000000000000000000000000016146122c3576040517f2c47703200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000848152600260208181526040808420600380845294829020825160a081018452815481526001820154948101949094529093015465ffffffffffff8082169284019290925266010000000000008104821660608401526c0100000000000000000000000090041660808201529181015490919073ffffffffffffffffffffffffffffffffffffffff16158015906123835750815473ffffffffffffffffffffffffffffffffffffffff1660009081526008602052604090205460ff16155b156123ba576040517f2c47703200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6123c386610c45565b6123f9576040517fa24c407400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006124068787426136bd565b9450905084841015612444576040517f74ec9d5b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8260070154841115612482576040517f5c430eae00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600383015474010000000000000000000000000000000000000000900460ff166124b257826004015484116124ba565b826004015486115b156124f1576040517ff3383dc900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600383015474010000000000000000000000000000000000000000900460ff1661251b578361251d565b855b83600401600082825461253091906145eb565b925050819055508583600901600082825461254b9190614754565b92505081905550838360080160008282546125669190614754565b90915550506005830154602083015110156125895761258487613639565b612594565b612594874283613a88565b5050509392505050565b600081815260056020908152604080832081516080810183528154815260019091015465ffffffffffff8082169483019490945266010000000000008104909316918101919091526c0100000000000000000000000090910460ff161515606082018190528291829161261c57600080600093509350935050612672565b602081015161262b90426147b5565b9250806040015165ffffffffffff168365ffffffffffff161091508161265257805161266e565b6040810151815161266e9165ffffffffffff808716911661356d565b9350505b9193909250565b60015460009073ffffffffffffffffffffffffffffffffffffffff16801580159061275d57506040517fb700961300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff85811660048301523060248301527fffffffff000000000000000000000000000000000000000000000000000000008516604483015282169063b700961390606401602060405180830381865afa158015612739573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061275d9190614737565b80610dbb575060005473ffffffffffffffffffffffffffffffffffffffff85811691161491505092915050565b600061279784848461356d565b9050600082806127a9576127a96147dc565b8486091115610a7a577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81106127de57600080fd5b6001019392505050565b60075460009060ff16612827576040517f64be3ffa00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000826000015173ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa158015612878573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061289c919061480b565b90506000836020015173ffffffffffffffffffffffffffffffffffffffff1663313ce5676040518163ffffffff1660e01b8152600401602060405180830381865afa1580156128ef573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612913919061480b565b905060068260ff16108061292a575060128260ff16115b15612961576040517f3b596f5f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60068160ff161080612976575060128160ff16115b156129ad576040517f3b596f5f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe884610180015160000b12806129eb5750601884610180015160000b135b15612a22576040517f3b596f5f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b3360009081526008602052604090205460ff16158015612a5b5750604084015173ffffffffffffffffffffffffffffffffffffffff1615155b15612a92576040517f2c47703200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600084610120015165ffffffffffff16118015612abb57504284610120015165ffffffffffff16105b15612af2576040517f3b596f5f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5050600082610180015160240160ff16600a0a90508260c001518360a001511015612b49576040517f4496547d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b825160208401516040517fb435914300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff928316600482015290821660248201526000917f0000000000000000000000000000000000000000000000000000000000000000169063b4359143906044016020604051808303816000875af1158015612be9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612c0d919061482e565b60095461014086015191925060009163ffffffff700100000000000000000000000000000000909204821691161080612c66575060095461016086015163ffffffff6c0100000000000000000000000090920482169116105b80612c86575084610140015163ffffffff1685610160015163ffffffff16115b15612cbd576040517f3b596f5f00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008561016001516005612cd1919061476c565b60095490915063ffffffff808316680100000000000000009092041611612cf85780612d0e565b60095468010000000000000000900463ffffffff165b600954610160880151919350600091612d6b9163ffffffff908116911611612d3e5760095463ffffffff16612d45565b8761016001515b63ffffffff1688610140015163ffffffff16896080015161356d9092919063ffffffff16565b9050600087610120015165ffffffffffff16600014612d8f57876101200151612d91565b425b604080516101208101825265ffffffffffff831680825260208201526101608b01805163ffffffff90811693830193909352600954905193945090926060840192918216911611612dea5760095463ffffffff16612df1565b8961016001515b63ffffffff9081168252600954640100000000900481166020830152861660408201526060810184905260808a810151910190612e2f9085906145eb565b8152602001612e728663ffffffff168b610140015163ffffffff168c60600151612e5d578c60800151611fde565b60a08d015160808e0151611fde918d9061356d565b90526000868152600460209081526040808320845181549386015192860151606080880151608089015160a08a015165ffffffffffff9586167fffffffffffffffffffffffffffffffffffffffff0000000000000000000000009099169890981766010000000000009590971694909402959095177fffffffffffffffffffffffff0000000000000000ffffffffffffffffffffffff166c0100000000000000000000000063ffffffff938416027fffffffffffffffffffffffff00000000ffffffffffffffffffffffffffffffff161770010000000000000000000000000000000095831695909502949094177fffffffff0000000000000000ffffffffffffffffffffffffffffffffffffffff1674010000000000000000000000000000000000000000928216929092027fffffffff00000000ffffffffffffffffffffffffffffffffffffffffffffffff16919091177801000000000000000000000000000000000000000000000000919094160292909217825560c0840151600183015560e08401516002830155610100909301516003909101559089015190935083925082915061302657876080015161303b565b60a0880151608089015161303b91889061356d565b90506130638463ffffffff1689610140015163ffffffff168361356d9092919063ffffffff16565b925061309088610160015163ffffffff1689610140015163ffffffff168361356d9092919063ffffffff16565b9150506040518061018001604052803373ffffffffffffffffffffffffffffffffffffffff168152602001886000015173ffffffffffffffffffffffffffffffffffffffff168152602001886020015173ffffffffffffffffffffffffffffffffffffffff168152602001886040015173ffffffffffffffffffffffffffffffffffffffff168152602001886060015115158152602001886080015181526020018381526020018860c0015181526020018281526020016000815260200160008152602001868152506002600086815260200190815260200160002060008201518160000160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060208201518160010160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060408201518160020160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060608201518160030160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060808201518160030160146101000a81548160ff02191690831515021790555060a0820151816004015560c0820151816005015560e0820151816006015561010082015181600701556101208201518160080155610140820151816009015561016082015181600a01559050506000600960149054906101000a900463ffffffff1663ffffffff16613330620186a065ffffffffffff16858561356d9092919063ffffffff16565b1161335b5760095474010000000000000000000000000000000000000000900463ffffffff16613369565b61336982620186a08561356d565b9050600061339e828a60e0015163ffffffff16116133875782613393565b8960e0015163ffffffff165b8590620186a061356d565b6133a89085614754565b60a08a01519091506000906133be90898761356d565b905060008a610120015165ffffffffffff166000146133e2578a61012001516133e4565b425b90506040518060a001604052808381526020018481526020018265ffffffffffff1681526020018c610140015163ffffffff16836134229190614847565b65ffffffffffff90811682526101008e018051821660209384015260008c815260038452604090819020855181558585015160018201558582015160029091018054606088015160809098015186166c01000000000000000000000000027fffffffffffffffffffffffffffff000000000000ffffffffffffffffffffffff9887166601000000000000027fffffffffffffffffffffffffffffffffffffffff0000000000000000000000009092169390961692909217919091179590951692909217909355908d01518d51925160a08f0151925173ffffffffffffffffffffffffffffffffffffffff92831694909216928c927f8235b14cd272b4e791960fe1118559bb7fed86934fcffeeae9b1175103b0756d9261355692909165ffffffffffff929092168252602082015260400190565b60405180910390a450959998505050505050505050565b600080807fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff858709858702925082811083820303915050806000036135c457600084116135b957600080fd5b508290049050610a7a565b8084116135d057600080fd5b60008486880960026001871981018816978890046003810283188082028403028082028403028082028403028082028403028082028403029081029092039091026000889003889004909101858311909403939093029303949094049190911702949350505050565b6000818152600360209081526040808320600290810180547fffffffffffffffffffffffffffffffffffffffff000000000000ffffffffffff1666010000000000004265ffffffffffff16021790559091528082206004018290555182917f9dc30b8eda31a6a144e092e5de600955523a6a925cc15cc1d1b9b4872cfa615591a250565b6000838152600260208181526040808420815161018081018352815473ffffffffffffffffffffffffffffffffffffffff9081168252600183015481169482019490945293810154831691840191909152600381015491821660608401527401000000000000000000000000000000000000000090910460ff1615156080830152600481015460a0830152600581015460c0830152600681015460e0830152600781015461010083015260088101546101208301526009810154610140830152600a01546101608201528190816137938761185f565b600088815260026020908152604080832060059081018590559091529020600101549091506c01000000000000000000000000900460ff16156138db5760008781526005602052604081209080806137ea8b61259e565b60008e8152600360205260408120805494975092955090935085926138109084906145eb565b909155505080156138ab578284600001600082825461382f91906145eb565b909155505060018401805483919060069061385d9084906601000000000000900465ffffffffffff166147b5565b92506101000a81548165ffffffffffff021916908365ffffffffffff160217905550888460010160006101000a81548165ffffffffffff021916908365ffffffffffff1602179055506138d6565b6001840180547fffffffffffffffffffffffffffffffffffffff00ffffffffffffffffffffffff1690555b505050505b6138e4876141e1565b60e0830151909450808510156138f8578094505b61016083015161390a9088908761356d565b600089815260046020526040812080546003909101549296507801000000000000000000000000000000000000000000000000810463ffffffff9081169392660100000000000090920465ffffffffffff16919061396e9085908a90869061278a16565b60008d8152600460205260409020805491925082916006906139a39084906601000000000000900465ffffffffffff16614847565b92506101000a81548165ffffffffffff021916908365ffffffffffff1602179055506000828b65ffffffffffff16116139f7576139e865ffffffffffff8c16846145eb565b6139f29086614754565b613a32565b613a098365ffffffffffff8d166145eb565b8511613a16576000613a32565b613a288365ffffffffffff8d166145eb565b613a3290866145eb565b905088613a4b86613a438585614754565b8a919061356d565b613a559190614754565b613a60906001614754565b60009d8e5260026020526040909d206005019c909c5550969a95995094975050505050505050565b600060046000858152602001908152602001600020604051806101200160405290816000820160009054906101000a900465ffffffffffff1665ffffffffffff1665ffffffffffff1681526020016000820160069054906101000a900465ffffffffffff1665ffffffffffff1665ffffffffffff16815260200160008201600c9054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020016000820160109054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020016000820160149054906101000a900463ffffffff1663ffffffff1663ffffffff1681526020016000820160189054906101000a900463ffffffff1663ffffffff1663ffffffff16815260200160018201548152602001600282015481526020016003820154815250509050600060026000868152602001908152602001600020604051806101800160405290816000820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016001820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016002820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016003820160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020016003820160149054906101000a900460ff16151515158152602001600482015481526020016005820154815260200160068201548152602001600782015481526020016008820154815260200160098201548152602001600a8201548152505090506000600360008781526020019081526020016000206040518060a001604052908160008201548152602001600182015481526020016002820160009054906101000a900465ffffffffffff1665ffffffffffff1665ffffffffffff1681526020016002820160069054906101000a900465ffffffffffff1665ffffffffffff1665ffffffffffff16815260200160028201600c9054906101000a900465ffffffffffff1665ffffffffffff1665ffffffffffff168152505090506000858260600151613e6191906147b5565b65ffffffffffff169050600082604001518360600151613e8191906147b5565b65ffffffffffff16905060008460800151613ea0578460a00151613eb5565b61016085015160a0860151613eb5918961356d565b905060008560800151613ecd57856101200151613ee3565b610160860151610140870151613ee3918a61356d565b613eed9083614754565b9050600082613f07613eff87876145eb565b84908761356d565b613f119190614754565b90508760e001518760a00151108015613f2957508181105b80613f64575060608801518851613f469163ffffffff1690614847565b65ffffffffffff168a65ffffffffffff1610158015613f6457508181115b156141d457613f88886040015163ffffffff16868561356d9092919063ffffffff16565b60008c81526002602052604081206007019190915560a0890151613fb990839063ffffffff90811690889061356d16565b90506000613fd7896101600151838d61278a9092919063ffffffff16565b885160408051918252602082018390529192508e917f78f9c01d72705dba80d6ce051d36a1f987bf2a3800fee938c111a2ae741e57d1910160405180910390a28751811015614108576040518060800160405280828a6000015161403b91906145eb565b81526020018d65ffffffffffff1681526020018b6080015163ffffffff1665ffffffffffff16815260200160011515815250600560008f81526020019081526020016000206000820151816000015560208201518160010160006101000a81548165ffffffffffff021916908365ffffffffffff16021790555060408201518160010160066101000a81548165ffffffffffff021916908365ffffffffffff160217905550606082015181600101600c6101000a81548160ff02191690831515021790555090505061414d565b60008d81526003602090815260408083208490556005909152902060010180547fffffffffffffffffffffffffffffffffffffff00ffffffffffffffffffffffff1690555b60008d815260046020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffffffff0000000000001665ffffffffffff8e1617905560c08a015160a08a0151116141a15760006141b5565b8960c001518960a001516141b591906145eb565b60008e8152600460205260409020600281019190915560030191909155505b5050505050505050505050565b6000818152600260208181526040808420815161018081018352815473ffffffffffffffffffffffffffffffffffffffff908116825260018301548116828601529482015485168184015260038083015495861660608301527401000000000000000000000000000000000000000090950460ff1615156080820152600482015460a0820152600582015460c08201819052600683015460e0830152600783015461010083015260088301546101208301526009830154610140830152600a90920154610160820181905287875294909352908420549192610a7a92919061278a565b6000602082840312156142d657600080fd5b5035919050565b73ffffffffffffffffffffffffffffffffffffffff8116811461177257600080fd5b803561430a816142dd565b919050565b60006020828403121561432157600080fd5b8135610a7a816142dd565b6000806020838503121561433f57600080fd5b823567ffffffffffffffff8082111561435757600080fd5b818501915085601f83011261436b57600080fd5b81358181111561437a57600080fd5b86602082850101111561438c57600080fd5b60209290920196919550909350505050565b801515811461177257600080fd5b803561430a8161439e565b6000602082840312156143c957600080fd5b8135610a7a8161439e565b600080608083850312156143e757600080fd5b82359150836080840111156143fb57600080fd5b50926020919091019150565b6000806040838503121561441a57600080fd5b8235614425816142dd565b915060208301356144358161439e565b809150509250929050565b6000806040838503121561445357600080fd5b823591506020830135614435816142dd565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040516101a0810167ffffffffffffffff811182821017156144b8576144b8614465565b60405290565b803563ffffffff8116811461430a57600080fd5b600060c082840312156144e457600080fd5b82601f8301126144f357600080fd5b60405160c0810181811067ffffffffffffffff8211171561451657614516614465565b6040528060c084018581111561452b57600080fd5b845b8181101561454c5761453e816144be565b83526020928301920161452d565b509195945050505050565b60008060006060848603121561456c57600080fd5b83359250602084013591506040840135614585816142dd565b809150509250925092565b6000806000606084860312156145a557600080fd5b505081359360208301359350604090920135919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000828210156145fd576145fd6145bc565b500390565b65ffffffffffff8116811461177257600080fd5b803561430a81614602565b8035600081900b811461430a57600080fd5b60006101a0828403121561464657600080fd5b61464e614494565b614657836142ff565b8152614665602084016142ff565b6020820152614676604084016142ff565b6040820152614687606084016143ac565b60608201526080830135608082015260a083013560a082015260c083013560c08201526146b660e084016144be565b60e08201526101006146c9818501614616565b908201526101206146db848201614616565b908201526101406146ed8482016144be565b908201526101606146ff8482016144be565b90820152610180614711848201614621565b908201529392505050565b60006020828403121561472e57600080fd5b610a7a826144be565b60006020828403121561474957600080fd5b8151610a7a8161439e565b60008219821115614767576147676145bc565b500190565b600063ffffffff8083168185168183048111821515161561478f5761478f6145bc565b02949350505050565b6000602082840312156147aa57600080fd5b8151610a7a81614602565b600065ffffffffffff838116908316818110156147d4576147d46145bc565b039392505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b60006020828403121561481d57600080fd5b815160ff81168114610a7a57600080fd5b60006020828403121561484057600080fd5b5051919050565b600065ffffffffffff808316818516808303821115614868576148686145bc565b0194935050505056fea2646970667358221220aa6ddb98fe9a89f9af30a6cda32eeb70e1e0bdbc7e8dc1e54d88beef47e0c0bd64736f6c634300080f0033000000000000000000000000007f7735baf391e207e3aa380bb53c4bd9a5fed6000000000000000000000000007a66a2a13415db3613c1a4dd1c942a285902d1000000000000000000000000007bd11fca0daaeadd455b51826f9a015f2f0969000000000000000000000000007a0f48a4e3d74ab4234adf9ea9eb32f87b4b14

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

000000000000000000000000007f7735baf391e207e3aa380bb53c4bd9a5fed6000000000000000000000000007a66a2a13415db3613c1a4dd1c942a285902d1000000000000000000000000007bd11fca0daaeadd455b51826f9a015f2f0969000000000000000000000000007a0f48a4e3d74ab4234adf9ea9eb32f87b4b14

-----Decoded View---------------
Arg [0] : teller_ (address): 0x007f7735baf391e207e3aa380bb53c4bd9a5fed6
Arg [1] : aggregator_ (address): 0x007a66a2a13415db3613c1a4dd1c942a285902d1
Arg [2] : guardian_ (address): 0x007bd11fca0daaeadd455b51826f9a015f2f0969
Arg [3] : authority_ (address): 0x007a0f48a4e3d74ab4234adf9ea9eb32f87b4b14

-----Encoded View---------------
4 Constructor Arguments found :
Arg [0] : 000000000000000000000000007f7735baf391e207e3aa380bb53c4bd9a5fed6
Arg [1] : 000000000000000000000000007a66a2a13415db3613c1a4dd1c942a285902d1
Arg [2] : 000000000000000000000000007bd11fca0daaeadd455b51826f9a015f2f0969
Arg [3] : 000000000000000000000000007a0f48a4e3d74ab4234adf9ea9eb32f87b4b14


Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading