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

0x v2 support #106

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

0x v2 support #106

wants to merge 14 commits into from

Conversation

sunce86
Copy link
Contributor

@sunce86 sunce86 commented Feb 4, 2025

Support for v2 version of 0x API: https://0x.org/docs/api#tag/Swap/operation/swap::allowanceHolder::getQuote

Migration tips: https://0x.org/docs/upgrading/upgrading_to_swap_v2

There is no support for BUY orders so will have to exclude 0x from native price estimators list.

Tested on mainnet staging. Quote solved and verified.

@sunce86 sunce86 self-assigned this Feb 4, 2025
@sunce86 sunce86 changed the title [DRAFT] 0x v2 0x v2 support Feb 6, 2025
@sunce86 sunce86 marked this pull request as ready for review February 6, 2025 18:40
Comment on lines +24 to +25
/// https://0x.org/docs/introduction/0x-cheat-sheet#0x-contracts
const DEFAULT_ALLOWANCE_TARGET: &str = "0x0000000000001fF3684f28c67538d4D072C22734";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This address depends on the EVM hardfork at the time of deployment. I think we should probably future proof this and make this an optional config parameter which defaults to this value instead of having this always hardcoded constant here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is dangerous to change without official version update (where api endpoints would be changed as well, similar to this PR), so I don't expect we will need to update this any time soon. That said, I would rather avoid adding configuration just because we might need it sometimes in the future, but probably won't. If we do, why not making it configurable when needed.

},
"issues": {
"allowance": {
"spender": "0xdef1c0ded9bec7f1a1670819833240f027b25eff",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this spender actually correct? I would have expected this to be equal to the default allowance target? Can you set an allowance on either contract?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just kept the value from previous test, but for the purpose of the test the correct value is not relevant.

Copy link
Collaborator

@mstrug mstrug left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also /config/example.zeroex.toml should be updated.

Copy link
Contributor

@squadgazzz squadgazzz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@@ -19,7 +21,13 @@ pub struct ZeroEx {
defaults: dto::Query,
}

/// https://0x.org/docs/introduction/0x-cheat-sheet#0x-contracts
const DEFAULT_ALLOWANCE_TARGET: &str = "0x0000000000001fF3684f28c67538d4D072C22734";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An eth::ContractAddress gets constructed each time in the code. Can we use this type instead of &str here?

Copy link
Contributor

@MartinquaXD MartinquaXD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that 0x was important for quoting native prices we should probably discuss how big of an impact no longer having that API would be before actually switching over. 🤔

Copy link
Collaborator

@m-lord-renkse m-lord-renkse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Besides latest @MartinquaXD 's comment, code wise looks good to me.

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.

5 participants