Skip to content
This repository has been archived by the owner on May 26, 2023. It is now read-only.

caventa - The calculation of totalUSDborrowed value is wrong in Vault Synths #208

Closed
github-actions bot opened this issue Dec 11, 2022 · 0 comments
Closed

Comments

@github-actions
Copy link

github-actions bot commented Dec 11, 2022

caventa

medium

The calculation of totalUSDborrowed value is wrong in Vault Synths

Summary

The calculation of totalUSDborrowed value is wrong in Vault Synths because of a typo.

Vulnerability Detail

uint256 totalUSDborrowed = _USDborrowed +  (isoUSDLoaned[_collateralAddress][msg.sender] * virtualPrice)/LOAN_SCALE;

should be changed to

uint256 totalUSDborrowed = _USDborrowed +  (isoUSDLoanAndInterest[_collateralAddress][msg.sender] * virtualPrice)/LOAN_SCALE;

Impact

This leads to a different coinInUSD value which will affect the result of the require checking a few lines after the code.

require(colInUSD >= borrowMargin, "Minimum margin not met!");

Code Snippet

https://github.com/sherlock-audit/2022-11-isomorph/blob/main/contracts/Isomorph/contracts/Vault_Synths.sol#L120
https://github.com/sherlock-audit/2022-11-isomorph/blob/main/contracts/Isomorph/contracts/Vault_Synths.sol#L123

Tool used

Manual Review

Recommendation

Apply the changes abovementioned. Kindly compare with vault lyra and vault velo. All these 3 vaults should share the similar logic.

Duplicate of #85

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant