Market Price Lower Than Expected
The market price does not conform to the specification documented within the whitepaper. As a result, the computed market price is lower than expected.\\nThe following definition of the market price is taken from the whitepaper. Taken from Page 13 of the whitepaper - Definition 25\\n\\nThe integer implementation of the market price must be rounded up per the whitepaper. This ensures that the integer implementation of the market price is greater than or equal to the real value of the market price so as to protect makers from selling tokens at a lower price than expected.\\nWithin the `BondBaseSDA.marketPrice` function, the computation of the market price is rounded up in Line 688, which conforms to the specification.\\n```\\nFile: BondBaseSDA.sol\\n    function marketPrice(uint256 id_) public view override returns (uint256) {\\n        uint256 price = currentControlVariable(id_).mulDivUp(currentDebt(id_), markets[id_].scale);\\n\\n        return (price > markets[id_].minPrice) ? price : markets[id_].minPrice;\\n    }\\n```\\n\\nHowever, within the `BondBaseSDA._currentMarketPrice` function, the market price is rounded down, resulting in the makers selling tokens at a lower price than expected.\\n```\\nFile: BondBaseSDA.sol\\n    function _currentMarketPrice(uint256 id_) internal view returns (uint256) {\\n        BondMarket memory market = markets[id_];\\n        return terms[id_].controlVariable.mulDiv(market.totalDebt, market.scale);\\n    }\\n```\\n
Ensure the market price is rounded up so that the desired property can be achieved and the makers will not be selling tokens at a lower price than expected.\\n```\\nfunction _currentMarketPrice(uint256 id_) internal view returns (uint256) {\\n    BondMarket memory market = markets[id_];\\n// Remove the line below\\n   return terms[id_].controlVariable.mulDiv(market.totalDebt, market.scale);\\n// Add the line below\\n   return terms[id_].controlVariable.mulDivUp(market.totalDebt, market.scale);\\n}\\n```\\n
Loss for the makers as their tokens are sold at a lower price than expected.\\nAdditionally, the affected `BondBaseSDA._currentMarketPrice` function is used within the `BondBaseSDA._decayAndGetPrice` function to derive the market price. Since a lower market price will be returned, this will lead to a higher amount of payout tokens. Subsequently, the `lastDecayIncrement` will be higher than expected, which will lead to a lower `totalDebt`. Lower debt means a lower market price will be computed later.
```\\nFile: BondBaseSDA.sol\\n    function marketPrice(uint256 id_) public view override returns (uint256) {\\n        uint256 price = currentControlVariable(id_).mulDivUp(currentDebt(id_), markets[id_].scale);\\n\\n        return (price > markets[id_].minPrice) ? price : markets[id_].minPrice;\\n    }\\n```\\n