Skip to content

BitGet solver#203

Closed
squadgazzz wants to merge 23 commits intomainfrom
bitget
Closed

BitGet solver#203
squadgazzz wants to merge 23 commits intomainfrom
bitget

Conversation

@squadgazzz
Copy link
Contributor

@squadgazzz squadgazzz commented Mar 2, 2026

Summary

  • Add a new solver that integrates with the https://web3.bitget.com/en/docs/swap/ API to find swap routes, following existing patterns
  • The Bitget API uses a two-step POST flow: quote (to get the optimal routing market and output amount) followed by swap (to get the on-chain calldata) The BitGet team suggested using the request_mod="rich" param in the /swap API, which makes the response contain much more data, including the outAmount.
  • To mitigate the race condition between quote and swap calls, slippage is applied to the quoted output and passed as toMinAmount to the swap endpoint, ensuring consistency between what the calldata enforces on-chain and what the solver reports Not needed anymore because of the previous point
  • Only sell orders are supported - the Bitget API has no exactOut mode

Changes

  • Bitget API client and DTOs with HMAC-SHA256 request signing, base64 calldata decoding, typed ChainName enum, and serialize::U256 for amount fields
  • TOML config loading (endpoint, chain-id, api-key, api-secret)
  • E2E tests: market sell order, buy order rejection, insufficient liquidity, and out-of-price limit order
  • config/example.bitget.toml - Example configuration

How to test

New unit and manual e2e tests (ignored by default).

@squadgazzz squadgazzz marked this pull request as ready for review March 3, 2026 18:44
Comment on lines +64 to +65
/// Target chain name (same as from_chain for same-chain swaps).
pub to_chain: ChainName,
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting! So in the cross chain version of cow protocol this solver could already be used. 🚀

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.

PR looks alright to me but it's always hard to know this definitively when integrating a new API. Can you run this a little bit on staging as a sanity check before merging?

@squadgazzz
Copy link
Contributor Author

Can you run this a little bit on staging as a sanity check before merging?

Yeah, as soon as the solver is whitelisted.

Also, the approach was simplified and now it uses a single /swap endpoint with the request_mod="rich" param, which makes the response contain enriched data, including the outAmount. No need to call the /quote API anymore.

@squadgazzz
Copy link
Contributor Author

In favor of cowprotocol/services#4249

@squadgazzz squadgazzz closed this Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants