"Equilibrium price" is not used to compute the capacity (OSDA Only)
"Equilibrium price" is not used to compute the capacity leading to a smaller-than-expected max payout.\\nIn OFDA, it was observed that if the capacity is denominated in the quote token, the capacity will be calculated with the discounted price.\\n```\\nFile: BondBaseOFDA.sol\\n    function _createMarket(MarketParams memory params_) internal returns (uint256) {\\n..SNIP..\\n        // Calculate the maximum payout amount for this market\\n        uint256 capacity = params_.capacityInQuote\\n            ? params_.capacity.mulDiv(\\n                scale,\\n                price.mulDivUp(\\n                    uint256(ONE_HUNDRED_PERCENT - params_.fixedDiscount),\\n                    uint256(ONE_HUNDRED_PERCENT)\\n                )\\n            )\\n            : params_.capacity;\\n        market.maxPayout = capacity.mulDiv(uint256(params_.depositInterval), uint256(length));\\n```\\n\\nHowever, in OSDA, if the capacity is denominated in the quote token, the capacity will be calculated with the oracle price instead of the discounted price.\\n```\\nFile: BondBaseOSDA.sol\\n    function _createMarket(MarketParams memory params_) internal returns (uint256) {\\n..SNIP..\\n        // Calculate the maximum payout amount for this market, determined by deposit interval\\n        uint256 capacity = params_.capacityInQuote\\n            ? params_.capacity.mulDiv(scale, price)\\n            : params_.capacity;\\n        market.maxPayout = capacity.mulDiv(uint256(params_.depositInterval), uint256(length));\\n```\\n\\nIn OSDA, it was also observed that the base discount is applied to the oracle price while calculating the price decimals because this will be the initial equilibrium price of the market. However, this "initial equilibrium price" is not used earlier when computing the capacity.\\n```\\nFile: BondBaseOSDA.sol\\n    function _validateOracle(\\n        uint256 id_,\\n        IBondOracle oracle_,\\n        ERC20 quoteToken_,\\n        ERC20 payoutToken_,\\n        uint48 baseDiscount_\\n    )\\n..SNIP..\\n        // Get the price decimals for the current oracle price\\n        // Oracle price is in quote tokens per payout token\\n        // E.g. if quote token is $10 and payout token is $2000,\\n        // then the oracle price is 200 quote tokens per payout token.\\n        // If the oracle has 18 decimals, then it would return 200 * 10^18.\\n        // In this case, the price decimals would be 2 since 200 = 2 * 10^2.\\n        // We apply the base discount to the oracle price before calculating\\n        // since this will be the initial equilibrium price of the market.\\n        int8 priceDecimals = _getPriceDecimals(\\n            currentPrice.mulDivUp(\\n                uint256(ONE_HUNDRED_PERCENT - baseDiscount_),\\n                uint256(ONE_HUNDRED_PERCENT)\\n            ),\\n            oracleDecimals\\n        );\\n```\\n
Applied the discount to obtain the "equilibrium price" before computing the capacity.\\n```\\n// Calculate the maximum payout amount for this market, determined by deposit interval\\nuint256 capacity = params_.capacityInQuote\\n// Remove the line below\\n  ? params_.capacity.mulDiv(scale, price)\\n// Add the line below\\n    ? params_.capacity.mulDiv(scale, price.mulDivUp(\\n// Add the line below\\n      uint256(ONE_HUNDRED_PERCENT // Remove the line below\\n params_.baseDiscount),\\n// Add the line below\\n      uint256(ONE_HUNDRED_PERCENT)\\n// Add the line below\\n     )\\n// Add the line below\\n    )\\n    : params_.capacity;\\nmarket.maxPayout = capacity.mulDiv(uint256(params_.depositInterval), uint256(length));\\n```\\n
As the discount is not applied to the price when computing the capacity, the price will be higher which leads to a smaller capacity. A smaller capacity will in turn result in a smaller max payout. A smaller-than-expected max payout reduces the maximum number of payout tokens a user can purchase at any single point in time, which might reduce the efficiency of a Bond market.\\nUsers who want to purchase a large number of bond tokens have to break their trade into smaller chunks to overcome the smaller-than-expected max payout, leading to unnecessary delay and additional gas fees.
```\\nFile: BondBaseOFDA.sol\\n    function _createMarket(MarketParams memory params_) internal returns (uint256) {\\n..SNIP..\\n        // Calculate the maximum payout amount for this market\\n        uint256 capacity = params_.capacityInQuote\\n            ? params_.capacity.mulDiv(\\n                scale,\\n                price.mulDivUp(\\n                    uint256(ONE_HUNDRED_PERCENT - params_.fixedDiscount),\\n                    uint256(ONE_HUNDRED_PERCENT)\\n                )\\n            )\\n            : params_.capacity;\\n        market.maxPayout = capacity.mulDiv(uint256(params_.depositInterval), uint256(length));\\n```\\n