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: ensure we hit leave auction trigger on mark-price calc, and hand… #10861

Merged
merged 2 commits into from Mar 11, 2024

Conversation

wwestgarth
Copy link
Contributor

@wwestgarth wwestgarth commented Mar 11, 2024

close #10858

The addition of the check that the mark price calculation can trigger a price auction was causing the book-keeping of enter/leaving auctions for perpetuals to become out of sync.

We now tell the perp that we are leaving when we call as.Left() and then update it again to entering an auction if the price-monitoring is triggered. The perpetual then just handles this zero length interval.

Another interesting thing is that the flow was a bit borked in leaveAuction() where price monitoring is triggered by the mark price calculation, we would never hit the call to enterAuction() after the call to CalculateMarkPrice() but would by luck start the auction by falling into commandLiquidityAuction().

I've changed the check in updateMarkPriceIfNotInAuction() to properly return an err if we hit price-monitoring, hopefully this does not cause integration tests to fail.

@wwestgarth wwestgarth force-pushed the 10858-auction-state-sync branch 2 times, most recently from 4c16e5c to 2a8c33d Compare March 11, 2024 12:39
witgaw
witgaw previously approved these changes Mar 11, 2024
Copy link
Member

@witgaw witgaw left a comment

Choose a reason for hiding this comment

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

LGTM

return
}

st, nd := a.auctions[len(a.auctions)-2], a.auctions[len(a.auctions)-1]
Copy link
Member

@witgaw witgaw Mar 11, 2024

Choose a reason for hiding this comment

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

start, end rather than st, nd would save a little bit of mental effort.

@wwestgarth wwestgarth marked this pull request as ready for review March 11, 2024 14:05
@wwestgarth wwestgarth requested a review from a team as a code owner March 11, 2024 14:05
…le zero length auction intervals in perpetual
@jeremyletang jeremyletang merged commit 0471be2 into develop Mar 11, 2024
14 checks passed
@jeremyletang jeremyletang deleted the 10858-auction-state-sync branch March 11, 2024 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Panic when preparing for the incentive
3 participants