Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

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
Contributor

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
Contributor

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
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants