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

Remove log2TotalSupply from Rewards in favor of passing in totalSupply #226

Closed
wants to merge 21 commits into from

Conversation

haydenshively
Copy link
Member

@haydenshively haydenshively commented Nov 28, 2023

Saves like 3% gas on most Lender methods; makes Lender.transfer more expensive; expands valid range of rate to 10^17 --> 10^28

Not worth the last minute change imo, just posting for posterity.

* Simpler computeTickTvl method in Volatility library

* Eliminate IV's dependence on slot0.sqrtPriceX96 and pool.liquidity()

* Clean up Oracle.sol
* Increase FEE_GROWTH_AVG_WINDOW so it's harder to manipulate

* Allow IV to increase faster than it decreases to match CEX more closely

* Interpolate between old and new IV samples instead of jumping

* Switch to EMA updates for smoother IV
* Remove RESERVE and associated totalSupply inflation

* Clean up _previewInterest return values

* Add AccrueInterest() event

* Create erase() function in Lender
* Evaluate shortfall at the probe prices in BalanceSheet.isHealthy

* Rename SLOT0_MASK_UNLEASH

* Replace strain with closeFactor in bips

* Only reset warning state and pay out ANTE if healthy after liquidate()

* Operate on unleashTime inside liquidate() instead of pre-adding in warn()

* Implement dutch auction liquidations

* Reuse assets and liabilities values for gas efficiency

* Clamp liquidators' amounts to what's actually available
Copy link

Changes to gas cost

Generated at commit: 0a44de571a2b91c083a84591605ad95ebbb30b0b, compared to commit: e24c6bc9a261078d0b65ec5f7d70afb4fd402f80

🧾 Summary (10% most significant diffs)

Contract Method Avg (+/-) %
BorrowerDeployer deploy +3,764 ❌ +0.11%

Full diff report 👇
Contract Deployment Cost (+/-) Method Min (+/-) % Avg (+/-) % Median (+/-) % Max (+/-) % # Calls (+/-)
Borrower 3,468,003 (+3,764) borrow
liquidate
modify
repay
warn
0 (0)
0 (0)
0 (0)
42,906 (-22)
0 (0)
+∞%
+∞%
+∞%
-0.05%
+∞%
13,660 (-15)
57,642 (-36)
68,558 (-27)
42,906 (-22)
18,419 (-13)
-0.11%
-0.06%
-0.04%
-0.05%
-0.07%
17,697 (-22)
52,490 (-58)
94,604 (-47)
42,906 (-22)
18,419 (-13)
-0.12%
-0.11%
-0.05%
-0.05%
-0.07%
41,597 (-22)
146,011 (-47)
240,984 (-25)
42,906 (-22)
36,839 (-25)
-0.05%
-0.03%
-0.01%
-0.05%
-0.07%
16 (0)
6 (0)
26 (0)
1 (0)
2 (0)
BorrowerDeployer 3,739,836 (+3,800) deploy 3,504,580 (+3,764) +0.11% 3,504,996 (+3,764) +0.11% 3,504,580 (+3,764) +0.11% 3,507,080 (+3,764) +0.11% 18 (0)

@haydenshively haydenshively reopened this Dec 9, 2023
@haydenshively haydenshively force-pushed the sherlock-audit-fixes branch 2 times, most recently from 7edebd5 to 4ff9aea Compare December 9, 2023 05:27
@haydenshively haydenshively deleted the remove-log2 branch December 12, 2023 04:43
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