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

Settling Perp PnL on an account before we liquidate perp and token #17

Merged

Conversation

ricardojmendez
Copy link
Contributor

Otherwise we may end up with token liquidations of value 0. See this post by Daffy

To be frank, I'm not sure if this is the right point to do it at, but thought I'd contribute it just in case.

@dafyddd
Copy link

dafyddd commented Jan 25, 2022

This is good, but I think it'd be more efficient to use the settlePosPnl function on client.ts in mango-client-v3. And also important to pass in all the mangoAccounts because they're already in memory in the liquidator.

@ricardojmendez
Copy link
Contributor Author

This is good, but I think it'd be more efficient to use the settlePosPnl function on client.ts in mango-client-v3. And also important to pass in all the mangoAccounts because they're already in memory in the liquidator.

Thanks for the pointer, @dafyddd. To confirm: on the settlePosPnl function, is mangoAccount the account you're settling on, and owner the payer/account executing the transaction?

This is an optimization on f97370f following Dafy's suggestion here:

blockworks-foundation#17 (comment)

It uses the client's settlePosPnl function instead of doing all the work
itself. It required making the mangoAccounts array global so we can have
access to it when liquidating from the RPC endpoint, but I'm not getting
any movement from the feed anyway.
@riordanp riordanp changed the base branch from main to settle April 12, 2022 10:49
@riordanp riordanp merged commit 14736b4 into blockworks-foundation:settle Apr 12, 2022
@riordanp
Copy link
Contributor

Hi @ricardojmendez, thanks for this. The settlePosPnl function is in a later mango-client version so I will upgrade.

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.

None yet

3 participants