-
Notifications
You must be signed in to change notification settings - Fork 10
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: sdk extension for people to swap #213
Conversation
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 like where this is going.
However, I imagined this differently.
Here you make a call to postSwapOrder
once with the equivalent to what you input in the widget form, and it will post the order.
I think is great, but if someone needs to build a UI will need the quote information.
The problem I think is interesting to improve is, its freaking hard to come up with the parameters of the order as we send them to be signed.
This is why this should be broken in 2 steps:
-
- Get order params
-
- Post order
In (1) we will:
- Make a quote
- Take slippage into account
- prepare the app data
- handle eth flow
- return
- order params, AS WE SHOULD SIGN THEM in the wallet
- convenient info to show to the user
- Mimum received
- USD amounts
- fee estimation
- fee estimations in USD
- slippage calculations
- warnings of all sort! (let people to have good protection without effort)
- etc
In essence, for me the great contribution is implementing this (1). Maybe this is herlpul:
For (2), we just need to pass the order params from (1) and pass them along the signer
Just some final 💡 I'd like to add. This logic will be made into a library, which we can reuse anywhere. I'd like to use it in BFF and implement a simple endpoint, so it allows non JS projects to easily get the trading parameters. This way, we make integrations dead simple
Here are some related notes on some similar idea:
I just want to add a plausible roadmap of this: v1: Library This way we can provide "progressive integrations" Form left to right, you get more and more control. This way, we provide an easy way to start, and then ways to gain control |
👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎ This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored. |
6fab215
to
ee092bb
Compare
…at/swap-for-people
…at/swap-for-people # Conflicts: # src/index.ts
…at/swap-for-people
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.
Great job!
I have a couple of comments/questions/nitpicks
…at/swap-for-people # Conflicts: # package.json
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.
All good, just make sure the CI tasks are passing.
Unittests are currently failing.
Report too large to display inline |
README https://github.com/cowprotocol/cow-sdk/blob/feat/swap-for-people/src/trading/README.md
The shortest way to post an order
Get quote -> confirm -> post order