Skip to content

Commit

Permalink
Gas and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
haydenshively committed Sep 13, 2023
1 parent a660c8e commit 86e2084
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
24 changes: 12 additions & 12 deletions core/.gas-snapshot
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
BorrowerGasTest:test_addMargin() (gas: 16203)
BorrowerGasTest:test_borrow() (gas: 110758)
BorrowerGasTest:test_borrow() (gas: 110705)
BorrowerGasTest:test_getUniswapPositions() (gas: 5219)
BorrowerGasTest:test_modify() (gas: 82355)
BorrowerGasTest:test_modifyWithAnte() (gas: 88810)
BorrowerGasTest:test_modify() (gas: 82302)
BorrowerGasTest:test_modifyWithAnte() (gas: 88757)
BorrowerGasTest:test_repay() (gas: 65245)
BorrowerGasTest:test_uniswapDepositInBorrower() (gas: 257967)
BorrowerGasTest:test_uniswapDepositInBorrower() (gas: 257914)
BorrowerGasTest:test_uniswapDepositStandard() (gas: 167558)
BorrowerGasTest:test_uniswapWithdraw() (gas: 147818)
BorrowerGasTest:test_withdraw() (gas: 105875)
BorrowerGasTest:test_uniswapWithdraw() (gas: 147776)
BorrowerGasTest:test_withdraw() (gas: 105822)
FactoryGasTest:test_createBorrower() (gas: 156519)
FactoryGasTest:test_createMarket() (gas: 3889605)
FactoryGasTest:test_createMarket() (gas: 3878781)
LenderGasTest:test_accrueInterest() (gas: 46070)
LenderGasTest:test_borrow() (gas: 40834)
LenderGasTest:test_deposit() (gas: 53422)
LenderGasTest:test_depositWithCourier() (gas: 53568)
LenderGasTest:test_redeem() (gas: 53114)
LenderGasTest:test_redeemWithCourier() (gas: 83506)
LenderGasTest:test_repay() (gas: 44774)
LiquidatorGasTest:test_noCallbackOneAsset() (gas: 51278)
LiquidatorGasTest:test_noCallbackTwoAssets() (gas: 59459)
LiquidatorGasTest:test_noCallbackTwoAssetsAndUniswapPosition() (gas: 95805)
LiquidatorGasTest:test_warn() (gas: 35262)
LiquidatorGasTest:test_withCallbackAndSwap() (gas: 130443)
LiquidatorGasTest:test_noCallbackOneAsset() (gas: 51225)
LiquidatorGasTest:test_noCallbackTwoAssets() (gas: 59406)
LiquidatorGasTest:test_noCallbackTwoAssetsAndUniswapPosition() (gas: 95763)
LiquidatorGasTest:test_warn() (gas: 35209)
LiquidatorGasTest:test_withCallbackAndSwap() (gas: 130390)
VolatilityGasTest:test_consult() (gas: 43075)
VolatilityGasTest:test_updateNoBinarySearch() (gas: 145902)
6 changes: 4 additions & 2 deletions core/src/libraries/BalanceSheet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ library BalanceSheet {
}

/// @dev Equivalent to \\( \frac{log_{1.0001} \left( \frac{10^{12}}{cf} \right)}{\text{MANIPULATION_THRESHOLD_DIVISOR}} \\)
function _manipulationThreshold(uint256 cf, uint256 manipulationThresholdDivisor) private pure returns (uint24) {
return uint24(-TickMath.getTickAtSqrtRatio(uint160(cf)) - 778261) / uint24(2 * manipulationThresholdDivisor);
function _manipulationThreshold(uint256 cf, uint8 manipulationThresholdDivisor) private pure returns (uint24) {
unchecked {
return uint24(-TickMath.getTickAtSqrtRatio(uint160(cf)) - 778261) / (2 * manipulationThresholdDivisor);
}
}

/// @dev Equivalent to \\( \frac{1 - σ}{1 + \frac{1}{liquidationIncentive} + \frac{1}{maxLeverage}} \\) where
Expand Down
2 changes: 2 additions & 0 deletions core/src/libraries/constants/Constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,10 @@ uint8 constant CONSTRAINT_N_SIGMA_MIN = 40;
/// Expressed x10, e.g. 80 → 8σ
uint8 constant CONSTRAINT_N_SIGMA_MAX = 80;

/// @dev The minimum value of the `manipulationThresholdDivisor`, described above
uint8 constant CONSTRAINT_MANIPULATION_THRESHOLD_DIVISOR_MIN = 12;

/// @dev The maximum value of the `manipulationThresholdDivisor`, described above
uint8 constant CONSTRAINT_MANIPULATION_THRESHOLD_DIVISOR_MAX = 20;

/// @dev The lower bound on what any `Lender`'s reserve factor can be. Expressed as reciprocal, e.g. 4 → 25%
Expand Down

0 comments on commit 86e2084

Please sign in to comment.