Skip to content

Conversation

@moosecat2
Copy link
Member

No description provided.

let depth = perp_market.get_market_depth_for_funding_rate()?;

let (bids, asks) =
let amm_worst_price_bid = perp_market
Copy link
Member

@crispheaney crispheaney Oct 27, 2025

Choose a reason for hiding this comment

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

technically this is average price, does that mess with things?

Copy link
Member

Choose a reason for hiding this comment

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

you can get the worst case price by looking at base/quote reserves to get price of amm at end of swap

bids.retain(|level| level.price >= amm_worst_price_bid);
asks.retain(|level| level.price <= amm_worst_price_ask);

if !perp_market.is_operation_paused(PerpOperation::AmmFill) && !state.amm_paused()? {
Copy link
Member

Choose a reason for hiding this comment

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

one thing i'd be worried about is if there are any weird cu issues here, should we think about a feature flag for this?

quote_reserve = new_quote_reserve;
remaining = remaining.saturating_sub(step_swap);

if out.len() as u8 >= levels {
Copy link
Member

Choose a reason for hiding this comment

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

is this redundant?

sanitize_clamp: Option<i64>,
) -> DriftResult {
let amm_reserve_price = amm.reserve_price()?;
let (amm_bid_price, amm_ask_price) = amm.bid_ask_price(amm_reserve_price)?;
Copy link
Member

Choose a reason for hiding this comment

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

nit: we might be able to save CUs only getting bid/ask iff on of the best bid/ask are none

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.

3 participants