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

Fee curve update #232

Merged
merged 2 commits into from
Jan 29, 2025
Merged

Fee curve update #232

merged 2 commits into from
Jan 29, 2025

Conversation

aalavandhan
Copy link
Member

@aalavandhan aalavandhan commented Nov 5, 2024

Updated enrichment/debasement fee curve.

Motivation:

The current implementation caps the enrichment rate when dr is high. The side-effect of this is that the vault's effective funding rate (rate vault holders pay to get magnified exposure) reduces.

When dr = 2, for example the perpTVL:vaultTVL ratio is 1:6 and at dr = 3 its 1:9. Say there's a perp tvl of 1m$. Perp's enrichment would be ~200k at dr = 2 and at dr = 3. However, the vault's effective rate would be 200k/6m ~3.3% when dr =2 and 200k/9m ~2.2% when dr = 3 and so on. So it actually continues to go down. (As shown in the following figure)

download

Alternatively as dr continues to increase we want the vault's effective funding rate to increase or at least stay constant. This would mean that perp's enrichment rate is unbounded on the upside.
(As shown below)
download

Copy link

openzeppelin-code bot commented Nov 5, 2024

Fee curve update

Generated at commit: 36e93acb815b72025efeb17ad592c2d61fb37ef7

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
1
0
0
3
23
27
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

@aalavandhan aalavandhan force-pushed the fee-curve-fix branch 2 times, most recently from aae3cd7 to 8fbec06 Compare November 14, 2024 17:44
spot-contracts/contracts/FeePolicy.sol Show resolved Hide resolved
perpRolloverFee.growth,
ONE.toInt256()
if (dr <= ONE) {
uint256 perpRate = MathUpgradeable.min(
Copy link
Member

Choose a reason for hiding this comment

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

Let's call this something like negPerpRate (most accurate?) so it's more clear what this intermediate value is.

Then, maybe take the max of -1* negPerpRate and the debasement limit? Seems more in the spirit of the computation.

Copy link
Member

@brandoniles brandoniles left a comment

Choose a reason for hiding this comment

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

LGTM

@aalavandhan aalavandhan merged commit 55cbb39 into main Jan 29, 2025
1 check passed
@aalavandhan aalavandhan deleted the fee-curve-fix branch January 29, 2025 22:14
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.

2 participants