Skip to content

WIP: Implement fallback oracles for perps#943

Open
Lou-Kamades wants to merge 23 commits into
devfrom
lou/perp-fallbacks
Open

WIP: Implement fallback oracles for perps#943
Lou-Kamades wants to merge 23 commits into
devfrom
lou/perp-fallbacks

Conversation

@Lou-Kamades

Copy link
Copy Markdown
Contributor

No description provided.

farnyser and others added 22 commits March 20, 2024 15:25
liquidator: split TCS triggering and liquidation job

Concurrent execution of candidate lookup and tx building/sending
- Also added an health assertion IX to protect liqor in multi liquidation scenario
- And a timeout for jupiter v6 queries (avoid blocking liquidation because of slow TCS)
…ing at every try if one token is having an issue (#921)
* liquidator: forcefully exit process if snapshot job die

* client: return snapshot_job join handle so it can be watched for early unexpected exit
liquidator: add a sequence check in rebalancing
liquidator: add sanctum swap
This is necessary for new liquidator feature of rebalancing using limit orders:
We need to close the token and market slot so that it's available for new liquidation, but at the same time, it's possible that the min order quantity for a given market is still bigger than allowed max withdrawal.
liquidator: rebalance with limit order
Co-authored-by: CanardMandarin <thibault.marboud@gmail.com>
@github-actions github-actions Bot added the program On-chain program changes label Apr 16, 2024

@ckamm ckamm left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

While this approach could work with some fixes (to enable raydium/orca fallbacks), my opinion is that we should stop reading the explicitly-passed oracles where possible.

Instead, we should read the oracle price from the AccountRetriever, to have a unified way of accessing oracle prices for a token/perp.

Unfortunately that will often require significant instruction adjustments (because creating the AccountRetriever is reasonably expensive and also holds a bunch of borrows)

let oracle_state = perp_market.oracle_state(
&OracleAccountInfos::from_reader(oracle_ref),
&OracleAccountInfos::from_reader_with_fallback(oracle_ref, fallback_opt.as_ref()),
None, // staleness checked in health

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

note that continuing to pass None here will not do the staleness check and thus potentially not use the fallback when it should

oracle: acc_reader,
fallback_opt,
usdc_opt: None,
sol_opt: None,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

so when this function is used, raydium/orca fallbacks are not available?

@Lou-Kamades Lou-Kamades changed the title Implement fallback oracles for perps WIP: Implement fallback oracles for perps Apr 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

program On-chain program changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants