Skip to content

Conversation

@0xbigz
Copy link
Member

@0xbigz 0xbigz commented Oct 30, 2025

No description provided.

// Calculates the revenue pool transfer amount for a given market state (positive = send to revenue pool, negative = pull from revenue pool)
// If the AMM budget is above `FEE_POOL_TO_REVENUE_POOL_THRESHOLD` (in surplus), settle fees collected to the revenue pool depending on the health of the AMM state
// Otherwise, spull from the revenue pool (up to a constraint amount)
// Otherwise, pull from the revenue pool (up to a constraint amount)
Copy link
Member

Choose a reason for hiding this comment

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

nice one

Comment on lines +2585 to +2592
let spot_market = &mut load_mut!(ctx.accounts.quote_spot_market)?;

validate!(
spot_market.market_index == QUOTE_SPOT_MARKET_INDEX,
ErrorCode::DefaultError,
"invalid spot market"
)?;

Copy link
Member

Choose a reason for hiding this comment

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

did you run this through a bankrun test yet? quote market is not marked as mutable in the context struct so i think it would throw. can also through this validate in the context struct as well as a constraint

market.amm.total_fee_withdrawn = market
.amm
.total_fee_withdrawn
.saturating_sub(revenue_pool_transfer.unsigned_abs());
Copy link
Member

Choose a reason for hiding this comment

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

saturating sub or safe sub? should it throw if it wants to take the value negative instead of sending to 0?

above there's safe_add as well

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