Skip to content
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

Fix Review #1

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Fix Review #1

wants to merge 2 commits into from

Conversation

sherlock-admin
Copy link
Contributor

Fix Review of

Repo: NumaMoney/Numa
Commit Hash: e1d9b837cd0cf490d1c2a740591d87781a5a314c

Comment on lines +26 to +27
uint160 public maxSpotOffsetPlus1SqrtBps = 10072;
uint160 public maxSpotOffsetMinus1SqrtBps = 9927;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#7.

Fixes issues: #175


nuAssetManager public nuAManager;

event IntervalShort(uint32 _intervalShort);
event IntervalLong(uint32 _intervalLong);
event MaxSpotOffsetBps(uint _maxSpotOffsetBps);
event MaxSpotOffset(uint _maxSpotOffset);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#7.

Fixes issues: #175

@@ -69,20 +69,18 @@ contract NumaOracle is Ownable2Step, INumaOracle {

/**
*
* @param _maxSpotOffsetBps offset percentage variable (cf doc)
* @param _maxSpotOffset offset percentage variable (cf doc)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#7.

Fixes issues: #175

Comment on lines +74 to +75
function setMaxSpotOffset(uint _maxSpotOffset) external onlyOwner {
require(_maxSpotOffset < 1 ether, "percentage must be less than 100");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#7.

Fixes issues: #175

Comment on lines 77 to +78
maxSpotOffsetPlus1SqrtBps =
100 *
uint160(Math.sqrt(10000 + _maxSpotOffsetBps));
uint160(Math.sqrt(1 ether + _maxSpotOffset))/1e5;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#7.

Fixes issues: #175

Comment on lines 80 to +81
maxSpotOffsetMinus1SqrtBps =
100 *
uint160(Math.sqrt(10000 - _maxSpotOffsetBps));
uint160(Math.sqrt(1 ether - _maxSpotOffset))/1e5;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#7.

Fixes issues: #175


emit MaxSpotOffsetBps(_maxSpotOffsetBps);
emit MaxSpotOffset(_maxSpotOffset);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#7.

Fixes issues: #175

Comment on lines +71 to +72
// sherlock issue 41
// CF warning can be bypassed
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#8.

Fixes issues: #41

modifier notInWarningCF() {
_;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#8.

Fixes issues: #41

@@ -449,7 +451,7 @@ contract NumaPrinter is Pausable, Ownable2Step {

(uint scaleSynthBurn, , , ) = vaultManager.getSynthScaling();
// apply scale
costWithoutFee = (costWithoutFee * scaleSynthBurn) / BASE_1000;
costWithoutFee = (costWithoutFee * scaleSynthBurn) / BASE_SCALE;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#6.

Fixes issues: #161

@@ -493,7 +495,7 @@ contract NumaPrinter is Pausable, Ownable2Step {
uint256 nuAssetIn = oracle.ethToNuAssetRoundUp(_nuAsset, ethAmount);
(uint scaleSynthBurn, , , ) = vaultManager.getSynthScaling();
// apply scale
nuAssetIn = (nuAssetIn * BASE_1000) / scaleSynthBurn;
nuAssetIn = (nuAssetIn * BASE_SCALE) / scaleSynthBurn;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#6.

Fixes issues: #161

import "@openzeppelin/contracts_5.0.2/utils/structs/EnumerableSet.sol";
import "../utils/constants.sol";


Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #67, #101, #153

@@ -172,14 +173,47 @@ contract NumaVault is Ownable2Step, ReentrancyGuard, Pausable, INumaVault {
}

/**
* @dev minimum reth borrow balance needed to allow partial liquidations
* @dev minimum lst borrow balance needed to allow partial liquidations
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #67, #101, #153

Comment on lines +184 to +216
/**
* @dev minimum borrow balance needed to allow partial liquidations in numa or in lst
*/
function getMinBorrowAmountAllowPartialLiquidation(address _cBorrowToken) external view returns (uint) {
if (_cBorrowToken == address(cNuma) )
{
// numa borrower
// min amount in numa
(
,
,
uint criticalScaleForNumaPriceAndSellFee,
) = vaultManager.getSynthScaling();

uint minBorrowAmountAllowPartialLiquidationNuma = vaultManager
.tokenToNuma(
minBorrowAmountAllowPartialLiquidation,
last_lsttokenvalueWei,
decimals,
criticalScaleForNumaPriceAndSellFee
);
return minBorrowAmountAllowPartialLiquidationNuma;

}
else
{
return minBorrowAmountAllowPartialLiquidation;

}


}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #67, #101, #153

@@ -855,11 +889,12 @@ contract NumaVault is Ownable2Step, ReentrancyGuard, Pausable, INumaVault {

function startLiquidation()
internal
returns (uint criticalScaleForNumaPriceAndSellFee)
returns (uint criticalScaleForNumaPriceAndSellFee, uint sell_fee)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#13.

Fixes issues: #42, #86

{
(
,
criticalScaleForNumaPriceAndSellFee,
sell_fee
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#13.

Fixes issues: #42, #86

@@ -975,7 +1010,7 @@ contract NumaVault is Ownable2Step, ReentrancyGuard, Pausable, INumaVault {
"invalid param"
);

uint criticalScaleForNumaPriceAndSellFee = startLiquidation();
(uint criticalScaleForNumaPriceAndSellFee,) = startLiquidation();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#13.

Fixes issues: #42, #86

);
uint minAmount = minBorrowAmountAllowPartialLiquidationNuma;
if (borrowAmount < minAmount) minAmount = borrowAmount;
require(numaAmount >= minAmount, "min liquidation");
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #67, #101, #153

@@ -1015,7 +1037,7 @@ contract NumaVault is Ownable2Step, ReentrancyGuard, Pausable, INumaVault {

// liquidate
numa.approve(address(cNuma), numaAmount);
cNuma.liquidateBorrow(
(,uint badDebt) = cNuma.liquidateBorrow(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #67, #101, #153

Comment on lines +1076 to +1078
// sherlock 86 42
// for numa borrow, numa <-> lst conversions should use buyPrice
maxNumaProfitForLiquidations = (maxNumaProfitForLiquidations * vaultManager.getBuyFee()) / 1 ether;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#13.

Fixes issues: #42, #86

Comment on lines +1081 to +1084
// sherlock 101 153
// cap only if there is no bad debt, because if we are in bad debt it means this is a partial liquidation which
// should not be capped
if ((badDebt == 0) && (numaLiquidatorProfit > maxNumaProfitForLiquidations))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #67, #101, #153

Comment on lines +1109 to +1111
// sherlock 86 42
// for numa borrow, numa <-> lst conversions should use buyPrice
lstProvidedEstimate = (lstProvidedEstimate * 1 ether) / vaultManager.getBuyFee();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#13.

Fixes issues: #42, #86

Comment on lines +1120 to +1124

// cap profit
// sherlock 101 153
// cap only if there is no bad debt, because if we are in bad debt it means this is a partial liquidation which
// should not be capped
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #67, #101, #153

uint vaultProfit;
if (lstLiquidatorProfit > maxLstProfitForLiquidations) {
if ((badDebt == 0) && (lstLiquidatorProfit > maxLstProfitForLiquidations)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #67, #101, #153

Comment on lines 1172 to +1173

uint criticalScaleForNumaPriceAndSellFee = startLiquidation();
(uint criticalScaleForNumaPriceAndSellFee,uint sellfee) = startLiquidation();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#13.

Fixes issues: #42, #86

@@ -1151,7 +1184,7 @@ contract NumaVault is Ownable2Step, ReentrancyGuard, Pausable, INumaVault {

// liquidate
IERC20(lstToken).approve(address(cLstToken), lstAmount);
cLstToken.liquidateBorrow(
(,uint badDebt) = cLstToken.liquidateBorrow(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #67, #101, #153

Comment on lines +1212 to +1215
// sherlock 101 153
// cap only if there is no bad debt, because if we are in bad debt it means this is a partial liquidation which
// should not be capped
if ((badDebt == 0) && (lstLiquidatorProfit > maxLstProfitForLiquidations))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #67, #101, #153

Comment on lines +1232 to +1235
// sherlock 86 42
// for lst borrow, numa <-> lst conversions should use sellPrice
numaProvidedEstimate = (numaProvidedEstimate * 1 ether) / sellfee;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#13.

Fixes issues: #42, #86

Comment on lines +1242 to +1245
// sherlock 86 42
// for lst borrow, numa <-> lst conversions should use sellPrice
maxNumaProfitForLiquidations = (maxNumaProfitForLiquidations * 1 ether) / sellfee;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#13.

Fixes issues: #42, #86

@@ -129,5 +131,6 @@ contract TokenErrorReporter {
error ReduceReservesCashValidation();

error SetInterestRateModelOwnerCheck();
error SetBorrowRateMaxMantissaOwnerCheck();
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#12.

Fixes issues: #192

Comment on lines +113 to +115
uint ltvMinBadDebtLiquidations = 0.98 ether;
uint ltvMinPartialLiquidations = 1.1 ether;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

* @param borrower The address of the borrower
* @param repayAmount The amount of underlying being repaid
* @return (error,baddebt,restOfDebt)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

) external view override returns (uint) {
// Shh - currently unused
liquidator;
) external view override returns (uint,uint,uint) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

require((cTokenBorrowed) != (cTokenCollateral), "not isolate");
if (
!markets[cTokenBorrowed].isListed ||
!markets[cTokenCollateral].isListed
) {
return uint(Error.MARKET_NOT_LISTED);
return (uint(Error.MARKET_NOT_LISTED),0,0);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

,
uint shortfall,
uint badDebt,
uint ltv
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

CNumaToken(cTokenBorrowed)
);
if (err != Error.NO_ERROR) {
return (uint(err),0,0);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

Comment on lines +596 to +619

// sherlock 101 153
// min amount allowed for liquidations from vault
uint minAmount = 0;
bool badDebtLiquidationAllowed = false;

// Min amount from vault.
// we should have a vault, if not, it will revert which is ok
minAmount = CNumaToken(cTokenBorrowed).vault().getMinBorrowAmountAllowPartialLiquidation(cTokenBorrowed);

// if ltv > ltvMinPartialLiquidations, partial liquidations are enabled
if (ltv > ltvMinPartialLiquidations)
{
minAmount = 0;
// if ltv > ltvMinPartialLiquidations, it means we are in bad debt
// so we need to allow bad debt liquidation
badDebtLiquidationAllowed = true;
}

if (borrowBalance < minAmount) minAmount = borrowBalance;

require(repayAmount >= minAmount, "min liquidation");


Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

Comment on lines +626 to +627
if (badDebt > 0 && (!badDebtLiquidationAllowed)) {
return (uint(Error.BAD_DEBT),badDebt,0);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

Comment on lines +632 to +634
if (shortfall == 0)
{
return (uint(Error.INSUFFICIENT_SHORTFALL),badDebt,0);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

@@ -607,14 +640,16 @@ contract NumaComptroller is
borrowBalance
);
if (repayAmount > maxClose) {
return uint(Error.TOO_MUCH_REPAY);
return (uint(Error.TOO_MUCH_REPAY),badDebt,0);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

Comment on lines +646 to +647
if (badDebt > 0 && (!badDebtLiquidationAllowed)) {
return (uint(Error.BAD_DEBT),badDebt,0);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

Comment on lines +650 to +652
// sherlock 101 153 returning badDebt and restOfDebt
// because we want to know if liquidation is partial and not in baddebt to allow taking all collateral
return (uint(Error.NO_ERROR),badDebt,borrowBalance - repayAmount);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

Comment on lines +681 to +682
,
uint ltv
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

/* allow accounts to be liquidated if the market is deprecated */
if (isDeprecated(CToken(cTokenBorrowed))) {
require(
borrowBalance >= repayAmount,
"Can not repay more than the total borrow"
);
// sherlock issue 67. Even if deprecated some bad debt is needed
if (ltv < ltvMinBadDebtLiquidations) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

Comment on lines +707 to +708
// bad debt liquidation allowed only above ltvMinBadDebtLiquidations
if (ltv < ltvMinBadDebtLiquidations) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

Comment on lines +914 to +925
// function getAccountLTVIsolate(
// address account,
// CNumaToken collateral,
// CNumaToken borrow
// ) public view returns (uint, uint) {
// (Error err, uint ltv) = getAccountLTVIsolateInternal(
// account,
// collateral,
// borrow
// );
// return (uint(err), ltv);
// }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

Comment on lines +1026 to +1033
if (vars.sumCollateralNoCollateralFactor > 0)
{
ltv = (vars.sumBorrowPlusEffects * 1 ether) / vars.sumCollateralNoCollateralFactor;
}
else if (vars.sumBorrowPlusEffects > 0)
{
// no collateral but some borrow, ltv is infinite
ltv = type(uint).max;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

// no collateral but some borrow, ltv is infinite
ltv = type(uint).max;

}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

Comment on lines +1069 to +1075
// function getAccountLTVIsolateInternal(
// address account,
// CNumaToken collateral,
// CNumaToken borrow
// ) internal view returns (Error, uint) {
// AccountLiquidityLocalVars memory vars; // Holds all our calculation results
// uint oErr;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

Comment on lines +1077 to +1114
// // Here we only consider only 2 tokens: collateral token and borrow token which should be different
// // collateral
// // Read the balances and exchange rate from the cToken
// (
// oErr,
// vars.cTokenBalance,
// vars.borrowBalance,
// vars.exchangeRateMantissa
// ) = collateral.getAccountSnapshot(account);
// if (oErr != 0) {
// // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades
// return (Error.SNAPSHOT_ERROR, 0);
// }
// vars.collateralFactor = Exp({
// mantissa: markets[address(collateral)].collateralFactorMantissa
// });
// vars.exchangeRate = Exp({mantissa: vars.exchangeRateMantissa});

// // Get the normalized price of the asset
// vars.oraclePriceMantissaCollateral = oracle
// .getUnderlyingPriceAsCollateral(collateral);
// if (vars.oraclePriceMantissaCollateral == 0) {
// return (Error.PRICE_ERROR, 0);
// }
// vars.oraclePriceCollateral = Exp({
// mantissa: vars.oraclePriceMantissaCollateral
// });

// // Pre-compute a conversion factor from tokens -> ether (normalized price value)
// vars.tokensToDenomCollateral = mul_(
// mul_(vars.collateralFactor, vars.exchangeRate),
// vars.oraclePriceCollateral
// );
// vars.tokensToDenomCollateralNoCollateralFactor = mul_(
// vars.exchangeRate,
// vars.oraclePriceCollateral
// );
// // sumCollateral += tokensToDenom * cTokenBalance
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

Comment on lines +1116 to +1126
// // NUMALENDING: use collateral price
// vars.sumCollateral = mul_ScalarTruncateAddUInt(
// vars.tokensToDenomCollateral,
// vars.cTokenBalance,
// vars.sumCollateral
// );
// vars.sumCollateralNoCollateralFactor = mul_ScalarTruncateAddUInt(
// vars.tokensToDenomCollateralNoCollateralFactor,
// vars.cTokenBalance,
// vars.sumCollateralNoCollateralFactor
// );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

Comment on lines +1128 to +1143
// // borrow
// // Read the balances and exchange rate from the cToken
// (
// oErr,
// vars.cTokenBalance,
// vars.borrowBalance,
// vars.exchangeRateMantissa
// ) = borrow.getAccountSnapshot(account);
// if (oErr != 0) {
// // semi-opaque error code, we assume NO_ERROR == 0 is invariant between upgrades
// return (Error.SNAPSHOT_ERROR, 0);
// }
// // Get the normalized price of the asset
// vars.oraclePriceMantissaBorrowed = oracle.getUnderlyingPriceAsBorrowed(
// borrow
// );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

Comment on lines +1145 to +1159
// if (vars.oraclePriceMantissaBorrowed == 0) {
// return (Error.PRICE_ERROR, 0);
// }
// //vars.oraclePriceCollateral = Exp({mantissa: vars.oraclePriceMantissaCollateral});
// vars.oraclePriceBorrowed = Exp({
// mantissa: vars.oraclePriceMantissaBorrowed
// });

// // sumBorrowPlusEffects += oraclePrice * borrowBalance
// // NUMALENDING: use borrow price
// vars.sumBorrowPlusEffects = mul_ScalarTruncateAddUInt(
// vars.oraclePriceBorrowed,
// vars.borrowBalance,
// vars.sumBorrowPlusEffects
// );
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

Comment on lines +1161 to +1165
// return (
// Error.NO_ERROR,
// (vars.sumBorrowPlusEffects * 1 ether) / vars.sumCollateral
// );
// }
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

Comment on lines +1571 to +1590
/**
* @notice Sets the ltv thresholds used when liquidating borrows
* @dev Admin function to set ltv thresholds
* @param _ltvMinBadDebt min ltv to allow bad debt liquidation
* @param _ltvMinPartialLiquidation min to allow partial liquidation
* @return uint 0=success, otherwise a failure
*/
function _setLtvThresholds(
uint _ltvMinBadDebt,
uint _ltvMinPartialLiquidation
) external returns (uint) {
// Check caller is admin
require(msg.sender == admin, "only admin");
ltvMinBadDebtLiquidations = _ltvMinBadDebt;
ltvMinPartialLiquidations = _ltvMinPartialLiquidation;

return uint(Error.NO_ERROR);
}


Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

Comment on lines +4 to +5

uint constant BASE_SCALE = 1 ether;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#6.

Fixes issues: #161

Comment on lines +74 to +77
// 0.0005e16 for ethereum chain, should be 10 x less for arbitrum as blocktime is /10
//uint borrowRateMaxMantissaARBI = 0.0005e16;
uint borrowRateMaxMantissaARBI = 0.00005e16;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#12.

Fixes issues: #192

Comment on lines +221 to +223
// arbitrum values
cReth._setBorrowRateMaxMantissa(borrowRateMaxMantissaARBI);
cNuma._setBorrowRateMaxMantissa(borrowRateMaxMantissaARBI);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#12.

Fixes issues: #192

@@ -232,6 +238,7 @@ contract DeployLending is Script {
// 100% liquidation close factor
comptroller._setCloseFactor(closeFactor);
comptroller._setLiquidationIncentive(liquidationIncentive);
comptroller._setLtvThresholds(0.98 ether,1.1 ether);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change related to NumaMoney/Numa#16.

Fixes issues: #153, #67, #101

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

Successfully merging this pull request may close these issues.

1 participant