-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
40 changed files
with
641 additions
and
583 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,16 @@ | ||
// SPDX-License-Identifier: UNLICENSED | ||
pragma solidity 0.8.20; | ||
|
||
import {Vault} from "@src/libraries/VaultLibrary.sol"; | ||
import {LoanOffer, BorrowOffer} from "@src/libraries/OfferLibrary.sol"; | ||
import {PERCENT} from "@src/libraries/MathLibrary.sol"; | ||
|
||
import {FixedPointMathLib} from "@solmate/utils/FixedPointMathLib.sol"; | ||
|
||
struct User { | ||
Vault collateralAsset; | ||
Vault borrowAsset; | ||
LoanOffer loanOffer; | ||
BorrowOffer borrowOffer; | ||
uint256 totalDebtCoveredByRealCollateral; | ||
} | ||
|
||
library UserLibrary { | ||
function collateralRatio(User memory self, uint256 price) public pure returns (uint256) { | ||
return self.totalDebtCoveredByRealCollateral == 0 | ||
? type(uint256).max | ||
: FixedPointMathLib.mulDivDown( | ||
FixedPointMathLib.mulDivDown(self.collateralAsset.free, price, self.totalDebtCoveredByRealCollateral), | ||
PERCENT, | ||
1e18 // TODO this is only because the price feed reports prices in 1e18 | ||
); | ||
} | ||
|
||
function isLiquidatable(User memory self, uint256 price, uint256 crLiquidation) public pure returns (bool) { | ||
return collateralRatio(self, price) < crLiquidation; | ||
} | ||
|
||
// solhint-disable-next-line var-name-mixedcase | ||
function getAssignedCollateral(User memory self, uint256 FV) public pure returns (uint256) { | ||
if (self.totalDebtCoveredByRealCollateral == 0) { | ||
return 0; | ||
} else { | ||
return FixedPointMathLib.mulDivDown(self.collateralAsset.free, FV, self.totalDebtCoveredByRealCollateral); | ||
} | ||
} | ||
struct UserView { | ||
User user; | ||
uint256 collateralAmount; | ||
uint256 borrowAmount; | ||
uint256 debtAmount; | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.