Skip to content

Commit

Permalink
Remove liquidation margin check in increaseCollateralAmount of all Va…
Browse files Browse the repository at this point in the history
…ults
  • Loading branch information
kree-dotcom committed Dec 13, 2022
1 parent 6cfe103 commit 6b403ba
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 19 deletions.
7 changes: 0 additions & 7 deletions contracts/Vault_Lyra.sol
Original file line number Diff line number Diff line change
Expand Up @@ -176,13 +176,6 @@ contract Vault_Lyra is Vault_Base_ERC20{
) = _getCollateral(_collateralAddress);
//check for frozen or paused collateral
_checkIfCollateralIsActive(currencyKey);
//debatable check begins here
uint256 totalCollat = collateralPosted[_collateralAddress][msg.sender] + _colAmount;
uint256 colInUSD = priceCollateralToUSD(currencyKey, totalCollat);
uint256 USDborrowed = (isoUSDLoanAndInterest[_collateralAddress][msg.sender] * virtualPrice) / LOAN_SCALE;
uint256 borrowMargin = (USDborrowed * liquidatableMargin) / LOAN_SCALE;
require(colInUSD >= borrowMargin, "Liquidation margin not met!");
//debatable check ends here
//update mapping with new collateral amount
collateralPosted[_collateralAddress][msg.sender] = collateralPosted[_collateralAddress][msg.sender] + _colAmount;
emit IncreaseCollateral(msg.sender, currencyKey, _colAmount);
Expand Down
7 changes: 0 additions & 7 deletions contracts/Vault_Synths.sol
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,6 @@ contract Vault_Synths is Vault_Base_ERC20 {
) = _getCollateral(_collateralAddress);
//check for frozen or paused collateral
_checkIfCollateralIsActive(currencyKey);
//debatable check begins here
uint256 totalCollat = collateralPosted[_collateralAddress][msg.sender] + _colAmount;
uint256 colInUSD = priceCollateralToUSD(currencyKey, totalCollat);
uint256 USDborrowed = (isoUSDLoanAndInterest[_collateralAddress][msg.sender] * virtualPrice) / LOAN_SCALE;
uint256 borrowMargin = (USDborrowed * liquidatableMargin) / LOAN_SCALE;
require(colInUSD >= borrowMargin, "Liquidation margin not met!");
//debatable check ends here
//update mapping with new collateral amount
collateralPosted[_collateralAddress][msg.sender] = collateralPosted[_collateralAddress][msg.sender] + _colAmount;
emit IncreaseCollateral(msg.sender, currencyKey, _colAmount);
Expand Down
5 changes: 0 additions & 5 deletions contracts/Vault_Velo.sol
Original file line number Diff line number Diff line change
Expand Up @@ -483,11 +483,6 @@ contract Vault_Velo is RoleControl(VAULT_VELO_TIME_DELAY), Pausable {
,
uint256 virtualPrice
) = _getCollateral(_collateralAddress);
//We check adding the collateral brings the user above the liquidation point to avoid instantly being liquidated, poor UX
uint256 USDborrowed = (isoUSDLoanAndInterest[_collateralAddress][msg.sender] * virtualPrice) / LOAN_SCALE;
uint256 borrowMargin = (USDborrowed * liquidatableMargin) / LOAN_SCALE;
require(existingCollateral + addedValue >= borrowMargin, "Liquidation margin not met!");

//update mapping with new collateral amount
emit IncreaseCollateralNFT(msg.sender, currencyKey, addedValue);
NFTids storage userNFTs = loanNFTids[_collateralAddress][msg.sender];
Expand Down

0 comments on commit 6b403ba

Please sign in to comment.