-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The _currentExchangeRate
of the Vault contract can't increase, and always be lower than or equal to _assetUnit
#443
Comments
Picodes marked the issue as primary issue |
Hmm not sure about this one. Will mark as confirm and figure it out later |
asselstine marked the issue as sponsor confirmed |
@asselstine did you figure it out? |
Picodes marked the issue as satisfactory |
Picodes marked the issue as selected for report |
Indeed, the exchange rate should not be greater than 1 cause users should not be able to claim the yield that has accrued in the YieldVault.
We subtract the yield from the total amount, the yield being the difference between If the YIeldVault becomes undercollateralized, users won't be able to deposit anymore but will be able to withdraw their share of the deposit and any yield that as accrued and has not been claimed yet will be shared proportionally amongst users. |
The code has been improved and clarified in the following PR: GenerationSoftware/pt-v5-vault#13 |
Keeping high severity here because of the issue in case of temporary under-collateralization. |
Lines of code
https://github.com/GenerationSoftware/pt-v5-vault/blob/b1deb5d494c25f885c34c83f014c8a855c5e2749/src/Vault.sol#L1168-L1187
Vulnerability details
Impact
The
_currentExchangeRate
of the Vault contract can not increase, and always be lower than or equal to_assetUnit
. Therefore, when the vault is undercollateralized (_currentExchangeRate
<_assetUnit
), it can't be further collateralized.Proof of concept
In case
_totalSupplyAmount != 0 && _withdrawableAssets != 0
,_currentExchangeRate
function will return a value_withdrawableAssets * _assetUnit / _totalSupplyAmount
.However
_withdrawableAssets
can not exceed_totalSupplyToAssets
, which is equal to_totalSupplyAmount * _lastRecordedExchangeRate / _assetUnit
.Therefore,
_currentExchangeRate
always be lower than or equal to_lastRecordedExchangeRate
.Testing:
Add this assert line and run
forge test
, all tests will passed.Tool used
Manual Review
Recommended Mitigation Steps
Remove these lines of code that limit the
_withdrawableAssets
Assessed type
Context
The text was updated successfully, but these errors were encountered: