-
Notifications
You must be signed in to change notification settings - Fork 15
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
Feature/0x V4 #44
Feature/0x V4 #44
Conversation
@hubagaspar91 Thank you for submitting this PR integrating 0x. Feel free to share your thoughts on the comments above! |
…ase its wrapping or unwrapping WETH, added a check to getTokenList to check whether an address is a valid ETH address, as there was an error with one of the responses containing an invalid ETH address
Implemented all the changes you guys requested. Most changes were straightforward, I have however though about a reasonable behaviour for the quote, after changing it to the
Actually, please disregard the above, there are 2 price endpoints, and the one we are using works the same as quote, so none of the above logic is needed, and slippage can be handled as usual. Made the changes in a new commit. Also added two extra fields, which we will be using for our integration, Also, I am not sure if you already handle this somehow somewhere, or this is the correct way to handle it, but I included logic that sets the |
I think this approach could also work, considering that the 0x response provides |
Yes, I only went for the previous solution as I got mixed up in the docs as there is also another price endpoint which does not take a slippagePercentage param. Generally, in think this latest approach is better and more in line with how swap UIs usually work, that is, the slippage value is provided as preset/input and is validated against during execution. |
Understood, the latest approach looks good. |
I just noticed the comment update. I'm thinking that Ref: https://0x.org/docs/0x-swap-api/api-references/get-swap-v1-quote
|
Yes this is also a great suggestion, will implement this too. |
@zodahu Implemented your above 2 suggested improvements in my latest commits. Added the same logic for calculating the agent for the |
@hubagaspar91 LGTM! Thank you for this PR. We'll integrate it into the Protocolink API next week. |
Protocol Information
Checklist:
./{protocolId}
insrc/logics/index.ts
src/logics/{protocolId}/index.ts
Additional Notes
The PR adds support for 0x swaps. Since 0x quotes are obtainable from a paid API, an API key has to be included when getting a quote or building logics.
Tests need a Github secret
ZEROEX_API_KEY
to be defined and contain a valid 0x API key.I also reused the token url lists from the paraswap logic by extracting them to
utils/tokens
.