Context
Depending on the item price in USD, users should be able to pay for items with different tokens/currencies (this is made possible with Switchboard Oracles). The payments then go towards a program-owned TreasuryAccount.
For regular tokens, I just send from the buyerTokenAccount to the corresponding treasuryTokenAccount.
For SOL payments, it becomes a bit more troublesome. Let us say an item has an USD cost that is equivalent to 1 SOL.
CASE 1: I can create a buyerTokenAccount for WSOL, then transfer 1 SOL to that account. Now I can transfer from the WSOL buyerTokenAccount to the WSOL treasuryTokenAccount. Although, the issue arises when I have to instantiate the WSOL buyerTokenAccount, since the initial 1 SOL transfer is predetermined and is not subject to change. Whereas the solana program will report a changing price due to the use of an oracle. E.g. it can cost 0.99 SOL or 1.01 SOL. For the former:
, for the latter: simulation will report "insufficient tokens" and the Tx will fail.
CASE 2: Alternatively, I have done special handling of SOL. If the user wants to make payments with SOL, I just do a regular system transfer (as opposed to token transfer) of 1 SOL directly to the TreasuryAccount address.
Questions
Is there a good way to handle multiple tokens + SOL (not WSOL)?
Is it bad practice to store SOL at the account address as per CASE 2? I can see that it would perhaps be an issue since, if you wanted to transfer out the SOL, you might accidentally transfer out the account rent fees as well, thus end up closing the account?