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

program: settle_pnls that handles invalid oracle and efficient cus #1030

Merged
merged 8 commits into from
May 28, 2024

Conversation

crispheaney
Copy link
Member

No description provided.

programs/drift/src/instructions/keeper.rs Show resolved Hide resolved
msg!("User has no unsettled pnl for market {}", market_index);
return Ok(());
let msg = format!("User has no unsettled pnl for market {}", market_index);
return mode.result(ErrorCode::NoUnsettledPnl, &msg);
Copy link
Member Author

Choose a reason for hiding this comment

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

is it bad these dont always return OK? do we need update_pool_balances to go through above?

Copy link
Member

Choose a reason for hiding this comment

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

only the 'MUST' will cause update_pool_balances to not go through? think its fine to just have 'TRY' allow that

"User must settle their own unsettled pnl when its positive and pnl pool not in excess"
)?;
let user_must_settle_themself = pnl_to_settle_with_user > 0
&& max_pnl_pool_excess < 0
Copy link
Member Author

Choose a reason for hiding this comment

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

should this be <=

Copy link
Member

Choose a reason for hiding this comment

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

  1. low chance excess is exactly = 0, even so not sure its necessary since theres no incentive for settle run

return mode.result(
ErrorCode::InsufficientCollateralForSettlingPNL,
"Does not meet margin requirement",
);
Copy link
Member

@0xbigz 0xbigz May 28, 2024

Choose a reason for hiding this comment

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

should market_index info get propagated if errors get hit for logs?

@crispheaney crispheaney merged commit 19de114 into master May 28, 2024
9 of 10 checks passed
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.

None yet

2 participants