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

feat(trading-sdk): set default slippage 2% for eth selling #243

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

shoom3301
Copy link
Contributor

@shoom3301 shoom3301 commented Feb 5, 2025

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)

@shoom3301 shoom3301 requested a review from a team February 5, 2025 13:21
@shoom3301 shoom3301 self-assigned this Feb 5, 2025
@coveralls
Copy link
Collaborator

coveralls commented Feb 5, 2025

Coverage Status

coverage: 78.856% (+0.07%) from 78.785%
when pulling 8a8ee01 on feat/eth-flow-default-slippage
into d27c205 on main.

return {
...params,
sellToken: WRAPPED_NATIVE_CURRENCIES[chainId],
slippageBps: typeof params.slippageBps === 'number' ? params.slippageBps : ETH_FLOW_DEFAULT_SLIPPAGE_BPS,
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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%,
}
Copy link
Contributor

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 :)

@anxolin
Copy link
Contributor

anxolin commented Feb 24, 2025

👍 approve

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.

4 participants