-
Notifications
You must be signed in to change notification settings - Fork 122
feat(trade): use Trading SDK in trade flows #5549
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<
10000
batch-deferred-content class="d-inline-block" data-url="/commits/badges">
… feat/bridge-token-selector
anxolin
reviewed
Apr 21, 2025
… feat/use-trading-sdk
…/cowswap into feat/use-trading-sdk
alfetopito
approved these changes
Apr 23, 2025
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.
Working well both via EOA and Safe, at least the SWAP and Bundle SWAP flows respectively.
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Finally, dog-fooded TradingSDK in CoW Swap.
It required some changes in the SDK: cowprotocol/cow-sdk#256
There are tow big changes:
Now we have a instance of
TradingSdk
insrc/tradingSdk/tradingSdk
plusTradingSdkUpdater
for updating appCode, chainId, signer and env inTradingSdk
.Quote fetching
The most of the changes are in this commit: e02652f
There are other fixes on top of this commit, see them in the final changes.
Order posting
That part needs refactoring in the future!
As we discussed, it requires significant time to make the design better, so I only migrated existing code to TradingSDK.
The plan for the refactoring will be bellow.
You can find key changes by searching
postSwapOrderFromQuote(
andpostLimitOrder(
in the code.Those calls are located in 6 flow functions:
In the next iterations would be great to merge the first 4 of flows into one.
Basically, I replaced
signEthFlowOrderStep
,signAndPostOrder
,buildPresignTx
functions with the calls above.Refactoring plan
swapFlow
,ethFlow
,safeBundleApprovalFlow
,safeBundleEthFlow
into one flow in order to reduce code duplicationsTradeFlowContext
withtradeQuotesAtom
state. Trade quote already contains all the necessary data and duplicatesTradeFlowContext
getQuote
fromsrc/api/cowProtocol
withTradingSDK
. It's still in use inFullAmountQuoteUpdater
andUnfillableOrdersUpdater
To Test
All the trading flows:
Trade parameters:
Confirmation screen:
Quote:
App data:
Approvals:
Summary by CodeRabbit
New Features
Refactor
Bug Fixes
Chores
Tests