Skip to content

feat(buy-sol) PR 1: route native SOL buys to solvers as wSOL - #4985

Merged
squadgazzz merged 1 commit into
mainfrom
solana-driver/be-329-native-sol-buys-as-wsol
Sep 29, 2026
Merged

squadgazzz merged 1 commit into
mainfrom
solana-driver/be-329-native-sol-buys-as-wsol

Conversation

@squadgazzz

Copy link
Copy Markdown
Contributor

Description

Program v0.4.1 lets an order buy native SOL. The intent puts the System Program ID where the buy mint goes. Solvers only swap into token accounts, so a native SOL buy passed through as-is gives them a buy token they can't route.

So the driver hands solvers a wSOL buy instead, with the taker's wSOL ATA as the destination. The output can't go to the wSOL buffer PDA, because FinalizeSettle pays a native buy out of the state PDA and the program can't unwrap the buffer into it. Unwrapping the wSOL and funding the state PDA at settle time is BE-330.

Native SOL buys still can't reach /solve, since the orderbook rejects them at creation and the autopilot cut drops orders whose payout account isn't a token account. So only quotes change for now.

Changes

  • Native SOL buys go to solvers with wSOL as buyMint and the taker's wSOL ATA as buyDestination
  • /quote rejects selling wSOL for native SOL with QuoteSameTokens, the same rule EVM applies to WETH and ETH in is_same_buy_and_sell_token

How to test

New unit and API tests.

Related issues

BE-329

@linear-code

linear-code Bot commented Sep 28, 2026

Copy link
Copy Markdown

BE-329

@squadgazzz
squadgazzz marked this pull request as ready for review September 28, 2026 15:04
@squadgazzz
squadgazzz requested a review from a team as a code owner September 28, 2026 15:04
@claude

claude Bot commented Sep 28, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @squadgazzz's task in 3m 8s —— View job


Review

  • Gather context (diff, related code)
  • Review changes
  • Post findings

I traced the full path and this change is clean and well-scoped. No blocking issues found — I'm not posting inline comments because I didn't find anything that should lead to a change.

What I verified

  • The wSOL substitution lives only in the solver-facing DTO (Order::new) and quote flow. The settle path (domain/settlement.rs) builds intents from the untouched domain order, so the native-SOL→wSOL mapping never leaks into on-chain settlement — consistent with the PR scoping this to quotes/solve only.
  • The quote path goes quote → compute_solutions → solver.solve → Auction::new → Order::new(taker = self.pubkey(), …), so a native-SOL buy is presented to the engine as a wSOL buy and priced by the wSOL mint. The new native_sol_buy_quote_is_priced_as_wsol test exercises exactly this.
  • All Order::new call sites are updated for the new taker parameter; buys_native_sol() compares the buy mint against ENCODED_NATIVE_SOL_TRANSFER, and native_mint/associated_token_address are used correctly (wSOL is a classic SPL token, so the token-2022 caveat on associated_token_address doesn't apply here).
  • /quote rejecting sell wSOL → buy native SOL as QuoteSameTokens matches the stated EVM parity. The wrap direction isn't guarded, but native SOL can't be a sell token, so that's moot rather than a gap.

Non-blocking notes (already covered by the PR / BE-330, no action needed)

  • The native-SOL buy destination is the taker's (solver's) wSOL ATA rather than the order owner's account. That's fine for quotes (never settled) and the PR calls out that native buys can't reach /solve today (orderbook + autopilot cut). Worth keeping front-of-mind for BE-330 so the settle work routes the payout to the user rather than inheriting a solver-owned destination.

Overall: LGTM. Good comments and test coverage.
· branch solana-driver/be-329-native-sol-buys-as-wsol

@tilacog tilacog left a comment •

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.

I foresee issues when creating setup accounts (solver/user ATAs and buffer PDAs) w/ this new native token denomination ENCODED_NATIVE_SOL_TRANSFER.

We can merge as is, and I'll provide a follow up PR.
I see #4986 already addresses these concerns.

@squadgazzz squadgazzz changed the title solana-driver: route native SOL buys to solvers as wSOL feat(buy-sol) PR 1: route native SOL buys to solvers as wSOL Sep 29, 2026
@squadgazzz
squadgazzz added this pull request to the merge queue Sep 29, 2026
Merged via the queue into main with commit 345c2b4 Sep 29, 2026
28 checks passed
@squadgazzz
squadgazzz deleted the solana-driver/be-329-native-sol-buys-as-wsol branch September 29, 2026 19:39
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 29, 2026
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.

2 participants