-
Notifications
You must be signed in to change notification settings - Fork 3
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
Drain pool by sandwiching matured shorts #426
Comments
IdeaOne way to prevent the short sandwich exploit is to design the pricing mechanism to be invariant under the closing of bonds at maturity. Since Hyperdrive decomposes trades into trades of newly minted bonds (the curve component) and trades of matured bonds (the flat component), holding the pricing mechanism invariant under the closing of bonds at maturity is equivalent to holding the pricing mechanism invariant under flat updates.\ Zeta AdjustmentTradingTo achieve the property of the pricing mechanism being invariant under flat updates, we modify the way that we account for the flat parts of trades. Currently, we call When a long is closed, the flat component of the trade should be removed from the share reserves since the long is redeeming bonds 1:1 a at maturity. Since the LP is the owner of the bonds in the case of shorts, the flat component is added to the share reserves when shorts are closed. Let Suppose Bob closes a short at maturity of Similarly, if Bob closes a long at maturity of Adding and Removing LiquiditySince the spot price formula changes to We have InvariantsWell-defined PricingMost AMM invariants are only defined in the first quadrant of the Negative InterestThe negative interest invariant doesn't change because we still can't quote prices above 1 base per bond. We'll need to update the check to use the new spot price calculation, but it's a minor change. SolvencyTo maintain the property that all longs can be closed instantaneously (this property will be removed when #13 is implemented), we need to enforce a strong form of the current solvency invariant: Since ExamplesTODO: Write up an example with the short sandwich and show that it isn't profitable with a massive short on our curve. It would be good to work through all the math to make sure that it works as expected. |
Here is a desmos that illustrates the issue we are fixing |
Spearbit Issue: https://github.com/spearbit-audits/review-element/issues/68.
The text was updated successfully, but these errors were encountered: