porter-finance / v1-core

⛰️ Smart contracts powering the Porter protocol.
https://porter.finance
GNU Affero General Public License v3.0
4 stars 3 forks source link

Add Check for too-large Bond Supply #290

Closed Namaskar-1F64F closed 2 years ago

Namaskar-1F64F commented 2 years ago

https://github.com/spearbit-audits/porter/issues/17

Description:

Issuing too many bonds can result in users being unable to redeem. This is caused by arithmetic overflow in previewRedeemAtMaturity.

If a user's bonds and the paidAmount's (or bonds * nonPaidAmount) product is greater than 2**256, it will overflow, reverting all attempts to redeem bonds.

This is fixed by adding the safety checks