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 Excluded Sources Configuration #246

Merged
merged 2 commits into from
Jun 2, 2022
Merged

0x Excluded Sources Configuration #246

merged 2 commits into from
Jun 2, 2022

Conversation

nlordell
Copy link
Contributor

@nlordell nlordell commented Jun 2, 2022

Fixes #243

This PR extends the 0x API implementation to allow setting excluded sources for /swap and /quote queries and adds configuration options in the driver and orderbook for setting these excluded sources.

Test Plan

Added a new test to see if 0x takes different routes when buying SNX for route (i.e. it doesn't use the "bad" Balancer pool):

% cargo test -p shared -- --ignored --nocapture zeroex_api::tests::excluded_sources
    Finished test [unoptimized + debuginfo] target(s) in 0.10s
     Running unittests src/lib.rs (target/debug/deps/shared-5653717641331484)

running 1 test
[crates/shared/src/zeroex_api.rs:526] &swap = Ok(
    SwapResponse {
        price: PriceResponse {
            sell_amount: 1000000000000000000000,
            buy_amount: 508509876034390373504047,
            allowance_target: 0xdef1c0ded9bec7f1a1670819833240f027b25eff,
            price: 508.5098760343904,
            estimated_gas: 1382394,
        },
        to: 0xdef1c0ded9bec7f1a1670819833240f027b25eff,
        data: 0x...ba12222222228d8ba445958a75a0704d566bf2c8...,
        value: 0,
    },
)
[crates/shared/src/zeroex_api.rs:535] &swap = Ok(
    SwapResponse {
        price: PriceResponse {
            sell_amount: 1000000000000000000000,
            buy_amount: 412021081473199945924709,
            allowance_target: 0xdef1c0ded9bec7f1a1670819833240f027b25eff,
            price: 412.02108147319996,
            estimated_gas: 1282394,
        },
        to: 0xdef1c0ded9bec7f1a1670819833240f027b25eff,
        data: 0x...,
        value: 0,
    },
)
test zeroex_api::tests::excluded_sources ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 254 filtered out; finished in 2.63s

Notice that the results are different in both cases and that when Balancer_V2 is excluded, the calldata no longer contains the 0xba1222.... Vault address.

@nlordell nlordell requested a review from a team as a code owner June 2, 2022 10:28
@josojo josojo enabled auto-merge (squash) June 2, 2022 11:11
@josojo josojo merged commit 3861021 into main Jun 2, 2022
@josojo josojo deleted the filter-0x-dexes branch June 2, 2022 11:13
@github-actions github-actions bot locked and limited conversation to collaborators Jun 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Configurable deny-list for 0x protocols
4 participants