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

WIP: Implement fallback oracles for perps #943

Open
wants to merge 23 commits into
base: dev
Choose a base branch
from

Conversation

Lou-Kamades
Copy link
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
@github-actions github-actions bot added the program On-chain program changes label Apr 16, 2024
Copy link
Collaborator

@ckamm ckamm left a comment

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_ref = &AccountInfoRef::borrow(ctx.accounts.oracle.as_ref())?;
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
Collaborator

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
Collaborator

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