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
pragma solidity ^0.8.13; | |
vars.healthFactor = calculateHealthFactorFromBalances( | |
vars.totalCollateralInETH, | |
vars.totalDebtInETH, | |
vars.avgLiquidationThreshold | |
); | |
// ... |
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
pragma solidity ^0.8.13; | |
function bark(bytes32 ilk, address urn, address kpr) external returns (uint256 id) { | |
require(live == 1, "Dog/not-live"); | |
(uint256 ink, uint256 art) = vat.urns(ilk, urn); | |
Ilk memory milk = ilks[ilk]; | |
uint256 dart; | |
uint256 rate; | |
uint256 dust; |
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
pragma solidity ^0.8.13; | |
function bite(bytes32 ilk, address urn) external returns (uint id) { | |
(, uint rate, uint spot) = vat.ilks(ilk); | |
(uint ink, uint art) = vat.urns(ilk, urn); | |
require(live == 1, "Cat/not-live"); | |
require(spot > 0 && mul(ink, spot) < mul(art, rate), "Cat/not-unsafe"); |
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
pragma solidity ^0.8.13; | |
uint internal constant collateralFactorMaxMantissa = 0.9e18; // 0.9 |
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
pragma solidity ^0.8.13; | |
struct AccountLiquidityLocalVars { | |
uint sumCollateral; | |
uint sumBorrowPlusEffects; | |
uint cTokenBalance; | |
uint borrowBalance; | |
uint exchangeRateMantissa; | |
uint oraclePriceMantissa; | |
Exp collateralFactor; |
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
pragma solidity ^0.8.13; | |
function computeExchangeRate(AssetCache memory assetCache) private pure returns (uint) { | |
uint totalAssets = assetCache.poolSize + (assetCache.totalBorrows / INTERNAL_DEBT_PRECISION); | |
if (totalAssets == 0 || assetCache.totalBalances == 0) return 1e18; | |
return totalAssets * 1e18 / assetCache.totalBalances; | |
} | |
function underlyingAmountToBalance(AssetCache memory assetCache, uint amount) internal pure returns (uint) { | |
uint exchangeRate = computeExchangeRate(assetCache); |
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
pragma solidity ^0.8.13; | |
function deposit(uint subAccountId, uint amount) external nonReentrant { | |
(address underlying, AssetStorage storage assetStorage, address proxyAddr, address msgSender) = CALLER(); | |
address account = getSubAccount(msgSender, subAccountId); | |
updateAverageLiquidity(account); | |
emit RequestDeposit(account, amount); | |
AssetCache memory assetCache = loadAssetCache(underlying, assetStorage); |
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
pragma solidity ^0.8.13; | |
function mintFresh(address minter, uint mintAmount) internal returns (uint, uint) { | |
uint allowed = comptroller.mintAllowed(address(this), minter, mintAmount); | |
if (allowed != 0) { | |
return (failOpaque(Error.COMPTROLLER_REJECTION, FailureInfo.MINT_COMPTROLLER_REJECTION, allowed), 0); | |
} | |
if (accrualBlockNumber != getBlockNumber()) { | |
return (fail(Error.MARKET_NOT_FRESH, FailureInfo.MINT_FRESHNESS_CHECK), 0); |
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
pragma solidity ^0.8.13; | |
function exchangeRateStoredInternal() internal view returns (MathError, uint) { | |
uint _totalSupply = totalSupply; | |
if (_totalSupply == 0) { | |
return (MathError.NO_ERROR, initialExchangeRateMantissa); | |
} else { | |
uint totalCash = getCashPrior(); | |
uint cashPlusBorrowsMinusReserves; | |
Exp memory exchangeRate; |
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
pragma solidity ^0.8.13; | |
function getOverallBorrowRateInternal( | |
uint256 _totalBorrowsStable, | |
uint256 _totalBorrowsVariable, | |
uint256 _currentVariableBorrowRate, | |
uint256 _currentAverageStableBorrowRate | |
) internal pure returns (uint256) { | |
uint256 totalBorrows = _totalBorrowsStable.add(_totalBorrowsVariable); |