Skip to content

Implement bitget /swap adapter for solana solver - #5107

Open
AryanGodara wants to merge 5 commits into
aryan/be-252-bitget-scaffoldfrom
aryan/be-253-bitget-adapter
Open

AryanGodara wants to merge 5 commits into
aryan/be-252-bitget-scaffoldfrom
aryan/be-253-bitget-adapter

Conversation

@AryanGodara

@AryanGodara AryanGodara commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Description

Makes the Bitget engine quote real sell orders. Each order is one signed call to Bitget's /swap endpoint. This version doesn't need Bitget to co-sign, and pays Bitget's 1 bp fee on every order instead. Sell orders only; buy orders return order-not-supported.

Changes

  • One POST /swap per order, with market bgwaggregator (which skips /quote) and amounts in atoms.
  • Bitget pays the solver's buy-token ATA, so the adapter appends a transfer of minAmount into the settlement's buy buffer. Positive slippage stays with the solver.
  • ComputeBudget instructions are dropped, and a route that needs a signer other than the solver is rejected.
  • max-accounts (sent as solMaxAccounts, default 48) leaves room for the settlement's own 7–8 accounts within the 64-account limit.
  • Error mapping follows the EVM engine: 429 is rate limited, and Bitget's no-route codes are not found.
  • Jupiter's instruction DTO moves to dex/dto.rs, shared by both adapters.
  • The endpoint works with or without a trailing slash.

How to test

Closes BE-253

Signed-off-by: Aryan Godara <aryangodara03@gmail.com>
@AryanGodara AryanGodara self-assigned this Oct 15, 2026
@linear-code

linear-code Bot commented Oct 15, 2026

Copy link
Copy Markdown

BE-253

…dapter

Signed-off-by: Aryan Godara <aryangodara03@gmail.com>
…to aryan/be-253-bitget-adapter

Signed-off-by: Aryan Godara <aryangodara03@gmail.com>
…to aryan/be-253-bitget-adapter

Signed-off-by: Aryan Godara <aryangodara03@gmail.com>
…test, trim docs

Signed-off-by: Aryan Godara <aryangodara03@gmail.com>
@AryanGodara
AryanGodara marked this pull request as ready for review October 16, 2026 16:33
@AryanGodara
AryanGodara requested a review from a team as a code owner October 16, 2026 16:33
@claude

claude Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @AryanGodara's task in 2m 1s —— View job


PR Review: Bitget /swap adapter

  • Read PR diff vs origin/aryan/be-252-bitget-scaffold
  • Review bitget adapter (mod.rs, dto.rs)
  • Review config + shared DTO refactor
  • Post inline comments
  • Post summary

Overall this is clean, well-documented work. The ApiInstruction extraction into a shared dex/dto.rs is a nice dedup, the signer/ComputeBudget filtering and ATA-transfer logic are clear, and the error mapping mirrors the EVM/Jupiter engine. Test coverage is good (unit + ignored live tests). Only one minor robustness point worth considering:

  • SwapResponse deserialization is less lenient than Jupiter's — inline comment. address_lookup_table_account (and instruction_lists) lack #[serde(default)], so a Bitget response that omits/nulls the lookup-table field (e.g. a direct route with no LUTs) fails to parse and the order gets dropped as BadResponse. Adding a default keeps it consistent with the Jupiter DTO and more forgiving.

A couple of things I checked and found fine (no action needed): the signed body string is reused verbatim for the HTTP body so the HMAC can't drift; the trailing-slash normalization + join("swap") is correct; the extra-signer rejection runs before the taker-authorized transfer is appended; and mapping transient Bitget error codes to NotFound for next-auction retry is a reasonable design choice.
· aryan/be-253-bitget-adapter

Comment on lines +101 to +103
instruction_lists: Vec<ApiInstruction>,
#[serde_as(as = "Vec<DisplayFromStr>")]
address_lookup_table_account: Vec<Pubkey>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Unlike the Jupiter DTO (which marks address_lookup_table_addresses, setup_instructions, and cleanup_instruction with #[serde(default)]), neither instruction_lists nor address_lookup_table_account has a default here. If Bitget ever omits (or sends null for) addressLookupTableAccount — e.g. a direct route that uses no lookup tables — deserialization fails outright and the order is silently dropped as BadResponse instead of being quoted. Consider adding #[serde(default)] to be defensive and consistent with the Jupiter adapter:

Suggested change
instruction_lists: Vec<ApiInstruction>,
#[serde_as(as = "Vec<DisplayFromStr>")]
address_lookup_table_account: Vec<Pubkey>,
instruction_lists: Vec<ApiInstruction>,
#[serde(default)]
#[serde_as(as = "Vec<DisplayFromStr>")]
address_lookup_table_account: Vec<Pubkey>,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

"Every /swap response i saw had addressLookupTableAccount, and a missing field already logs as quote failed.

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.

1 participant