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

stake-pool: Add slippage to all deposit and withdraw ixs #3980

Merged
merged 1 commit into from
Feb 1, 2023

Conversation

joncinque
Copy link
Contributor

Problem

When depositing and withdrawing from stake pools, it's impossible for a user to guarantee how much they'll receive.

Solution

Add *WithSlippage variants to all deposit and withdraw instructions, which guarantee a minimum output, similar to an AMM.

@2501babe
Copy link
Member

2501babe commented Feb 1, 2023

going to review this now, just curious, the intent of this is to protect against sandwich attacks, right? wondering if i should make deposit/withdraw always work like this in my program...

@joncinque
Copy link
Contributor Author

Yeah exactly, someone can watch for transactions depositing into the pool and put in an instruction to increase the deposit fee immediately. In your case, I think you don't need it since there's no fees to consider

@2501babe
Copy link
Member

2501babe commented Feb 1, 2023

im imagining a situation where someone does a reasonably large deposit so i frontrun their deposit with my own and backrun a withdrawal

@joncinque joncinque merged commit 6394e49 into solana-labs:master Feb 1, 2023
@joncinque joncinque deleted the sp-slip branch February 1, 2023 11:16
HaoranYi pushed a commit to HaoranYi/solana-program-library that referenced this pull request Jul 19, 2023
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.

2 participants