Skip to content

Fix the sell side for native SOL - #213

Closed
anxolin wants to merge 1 commit into
mainfrom
fix/native-sol-wrap
Closed

anxolin wants to merge 1 commit into
mainfrom
fix/native-sol-wrap

Conversation

@anxolin

@anxolin anxolin commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

What

SOL and WSOL resolved to Token-2022's native mint (9pan9bMn…) rather than So111…112. Nothing quotes that mint, so every order selling SOL was unfillable. Both symbols now resolve to the legacy wrapped SOL mint.

Wrapping was also gated on the user typing the literal string sol, so naming the sell token by mint address — the only workaround for the above — skipped the wrap, and the CLI never creates the sell-side account either. That produced a successful transaction and an order over an empty account, which just never filled.

The gate is now what the token names:

Sell token Behaviour
SOL, or 11111111111111111111111111111111 wraps the shortfall, creating the account if needed
WSOL, or a mint address spends the balance already held; errors if it is short

The native SOL marker is accepted as a sell token because lamports have no mint on the wire — the sell side can only carry them wrapped, so the CLI does the conversion and reports it. The summary now prints sellMint, plus wrappedLamports when it wrapped.

Test plan

just test && just lint && just fmt-check

I run the following:

❯ cow sell 0.01 SOL for 0.5 EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
      signature = GVm8DP4LvXMjyknjrwN6CWXzdD5aXMtu4wJWEAEWbTzvFC5VQed1tvyHpZqtmodbr7vb8jowBo7LH4gb6ntd8bm
       orderPda = 4GFrNnhXUCczgzevaAfnmC3JqJZ91mK8PPt6oDDexikY
       orderUid = 6639024830e332980b04cb8a845eea4859a62a2f8a21eec3fc1c1ff9503b598d
       sellMint = So11111111111111111111111111111111111111112
wrappedLamports = 10000000

❯ cow buy 0.5 EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v for 0.01 SOL
      signature = 2VuxHVAjy14qPtFmJqXp7DnnPcJ3qbDcGQyWirM379LegQrhPRXUFtuiDfGwg3SE3umPrMJXdzygY2sedhgC9vda
       orderPda = B3FaARVjsm1fePUeJLsNuVxC4kVtVuZzPDzrxRBspnGg
       orderUid = 8f166ab4a92ee165b109308b100810ba8d86bf867ff986c7344e7fdbd18e409b
       sellMint = So11111111111111111111111111111111111111112
wrappedLamports = 10000000

@anxolin
anxolin requested a review from a team as a code owner October 31, 2026 20:33
@anxolin
anxolin marked this pull request as draft October 31, 2026 20:34
`SOL` and `WSOL` resolved to Token-2022's native mint, which carries no
liquidity, so the orders they produced could not be filled. Both now
resolve to the legacy wrapped SOL mint.

Wrapping was gated on the user typing "sol", so naming the token by mint
address skipped it and created an order over an empty account that
silently never filled. The gate is now what the token names: `SOL` or the
native SOL marker wraps the shortfall, creating the account if needed,
while `WSOL` or a mint address spends the balance already held and fails
when it is short. The summary reports the sell mint and any wrapping.
@anxolin
anxolin force-pushed the fix/native-sol-wrap branch from a4a4ba2 to 22b43aa Compare October 31, 2026 22:58
@anxolin anxolin changed the title Wrap native SOL for any spelling of the sell token Fix the sell side for native SOL Oct 31, 2026
@anxolin
anxolin marked this pull request as ready for review November 3, 2026 05:29

@kaze-cow kaze-cow 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.

overall the changes seem a lot more verbose than actually necessary.

as the most simple solution, couldn't we just update the address of WSOL? example PR

Also, the native sol marker is not universally or low level recognized as 11111111111111111111111111111111, so it seems wierd to explicitly code for it in the test CLI. if we do want to do such a thing

Comment on lines +243 to +246
/// Whether `token_str` names native SOL: the `SOL` symbol, or the marker the
/// wire uses for a native side ([`ENCODED_NATIVE_SOL_TRANSFER`], the system
/// program). `WSOL` and the wrapped mint's address are the wrapped token, not
/// this.

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.

too verbose

also I think this function should be named is_native_sol for clarity that this is effectively a yes/no check. Also, I believe we have an applicable function

@anxolin

anxolin commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favour of #216

@anxolin anxolin closed this Nov 3, 2026
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.

2 participants