If I understand correctly: During transactions where we transfer SOL to/from wallets, we need to wrap the SOL in a temporarily created WSOL Token Program account. Then use that to transfer SOL from our wallet to wherever. Finally, we close the WSOL account.

But for other tokens, we only create a Token Program account once, and just leave it there. So what's up with SOL's being special?


To provide a concrete example, using an arbitrary swap from a few minutes ago.

That transaction is converting SOL -> MOBY, instructions are:

  1. Compute Budget: setComputeUnitPrice Just set a limit on how much to spend for this tx

  2. System Program: createAccountWithSeed: we create the HyAQ4...n1XYV WSOL account, the seed helps us know the account address beforehand

  3. Token Program: InitializeAccount: pairs up with the instruction above, initializes the account

  4. Raydium Liquidity Pool V4: raydium:swap ...: Raydium does the swap

  5. Token Program: closeAccount: we close the HyAQ4...n1XYV account we just made.


Why can't we just create a WSOL token account just once, and have Raydium and other programs use that?

That would make the entire swap much less compute intensive right?

I'm only asking because I'm writing a client that interacts with multiple tokens, and I always had to make this hardcoded exception for SOL to create/delete a temporary WSOL account, and this never made sense to me...

If I have every single Token Account address cached, why can't I just do the same for WSOL? is it safe to keep a WSOL account open?

** Small note: I don't care about the 0.002 or whatever the small amount of rent I would pay for not atomically opening/closing the WSOL account

1 Answer 1


It's really a question of user expectations. There's a fundamental inconsistency with how SOL is treated in wallets vs on-chain programs.

In wallets, typically SOL is held directly in the user's signing account, rather than through a WSOL accounts.

In on-chain programs, devs don't want to write special cases for handling native SOL (and rightfully so!), so trades go through WSOL accounts.

In order to satisfy the inconsistency, most dapps will include instructions to wrap and unwrap the native SOL into WSOL when calling into a program for trading. This way, the user never needs to know about WSOL, but the trade still works.

So you can definitely choose to keep a WSOL account open and keep trading through that, but users might be confused about where their SOL went.

  • cool. this is extremely useful, I was just wondering if there's a safety issue but sounds like it's fine. yeah I might just keep it in WSOL. this is for a private app, and so the users are all smart enough to figure it out or reach out if they are stuck.
    – Joe
    Commented May 16 at 16:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.