Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Improve serum liquidation #270

Merged
merged 3 commits into from Nov 30, 2021
Merged

Improve serum liquidation #270

merged 3 commits into from Nov 30, 2021

Conversation

suscd
Copy link
Collaborator

@suscd suscd commented Oct 18, 2021

Rework the calculations in the serum liquidation to find the worst acceptable price to set when placing a limit order. This allows for better efficiency by accepting trades with partial order fills.

This also now allows for serum liquidations to occur when the quote token is being used as collateral.

@suscd suscd requested review from eyevz and dnut October 18, 2021 23:19
@netlify
Copy link

netlify bot commented Oct 18, 2021

✔️ Deploy Preview for heuristic-wilson-e60030 canceled.

🔨 Explore the source changes: 4bcd2f9

🔍 Inspect the deploy log: https://app.netlify.com/sites/heuristic-wilson-e60030/deploys/616e233aed9a640008a28f0c

@cloudflare-pages
Copy link

cloudflare-pages bot commented Oct 18, 2021

Deploying with  Cloudflare Pages  Cloudflare Pages

Latest commit: 4bcd2f9
Status: ✅  Deploy successful!
Preview URL: https://af443a16.jet-v1.pages.dev

View logs

@eyevz
Copy link
Contributor

eyevz commented Oct 21, 2021

This code is remarkably clear! I like we now have symmetry between base and quote tokens.

I'm not done going through this yet, and I think there may be small problems with the amount of collateral lined up for sale in the plan. It could be that those get addressed during execution. I will finish this review over the next day or two.

Copy link

@AuthorOfTheSurf AuthorOfTheSurf left a comment

Choose a reason for hiding this comment

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

On line 66 of libraries/ts/src/user.ts user.refresh() should be await-ed to ensure that the loaded user has an initial set of collateral, deposits, loans data

I was working with this code and noticed the absence of an await was causing a race-condition when querying these fields

@eyevz
Copy link
Contributor

eyevz commented Oct 23, 2021

On line 66 of libraries/ts/src/user.ts user.refresh() should be await-ed to ensure that the loaded user has an initial set of collateral, deposits, loans data

I was working with this code and noticed the absence of an await was causing a race-condition when querying these fields

Hi @AuthorOfTheSurf, welcome and thank you. For integrating with our program, please keep an eye on jet-engine, our nascent client library.

@Tristyn please consider this comment in the context of the client lib.

@eyevz
Copy link
Contributor

eyevz commented Oct 23, 2021

@suscd I've left some specific questions around the liquidation sizing logic. As a general comment, it may be worth gathering all the logic relating to the target trade size in one place, like the plan.

Although it didn't change much, I still want to go through the accounting code before submitting this review.

Copy link
Contributor

@eyevz eyevz left a comment

Choose a reason for hiding this comment

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

Publishing comments so far. Still need to review the accounting step.

programs/jet/src/instructions/liquidate_dex.rs Outdated Show resolved Hide resolved
programs/jet/src/instructions/liquidate_dex.rs Outdated Show resolved Hide resolved
@Tristyn
Copy link
Contributor

Tristyn commented Oct 25, 2021

Nice work. I've reimplemented this in the jet-lab/jet-engine repo, the ts libs new home. Need to transition importers of libraries/ts to import the package @jet-lab/jet-engine instead

@AuthorOfTheSurf Yes that refresh should definitely be awaited. I've fixed it in @jet-lab/jet-engine

Rework the calculations in the serum liquidation to find the worst
acceptable price to set when placing a limit order. This allows for
better efficiency by accepting trades with partial order fills.
@suscd suscd requested a review from eyevz November 24, 2021 17:36
@suscd suscd merged commit 081a9e5 into master Nov 30, 2021
@suscd suscd deleted the feature/improved-serum-liq branch November 30, 2021 17:21
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants