-
Notifications
You must be signed in to change notification settings - Fork 13
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
feat(trading-sdk): set default slippage 2% for eth selling #243
base: main
Are you sure you want to change the base?
Conversation
src/trading/utils.ts
Outdated
return { | ||
...params, | ||
sellToken: WRAPPED_NATIVE_CURRENCIES[chainId], | ||
slippageBps: typeof params.slippageBps === 'number' ? params.slippageBps : ETH_FLOW_DEFAULT_SLIPPAGE_BPS, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here users will always have 2% for EthFlow, even if they set more than that.
I would expect the minimum to be applied only if value is < than min.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I don't understand.
This code takes slippageBps
from params and fallback to ETH_FLOW_DEFAULT_SLIPPAGE_BPS
if it's not set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think he means, you need MAX(slippageFromUser, ETH_FLOW_DEFAULT_SLIPPAGE_BPS[chainId])
if slippage for the network is 50 and user sets 30 --> 50
if slippage for the network is 50 and user sets 100 --> 100
Note how mainnet is 200, and GC is 50
[SupportedChainId.BASE]: 50, // 0.5%, | ||
[SupportedChainId.GNOSIS_CHAIN]: 50, // 0.5%, | ||
[SupportedChainId.SEPOLIA]: 50, // 0.5%, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome!
Just ready for dog-fooding i the feature :)
👍 approve |
Eth-flow orders are special and need higher slippage (2%)
Testing
Please, use
examples/vanilla
app in order to try the SDK live (run it locally)