Please help me convert from ->

pub user_token_source: Account<'info, TokenAccount>,

into ->

/// CHECK: Safe. user source token Account. user Account to swap from.
pub user_token_source: UncheckedAccount<'info>,

Tried to convert w/ following w/o success


The error message is

error[E0716]: temporary value dropped while borrowed
  --> programs/amm-proxy/src/instructions/swap_base_in.rs:81:18
60 |   impl<'a, 'b, 'c, 'info> From<&mut ProxySwapBaseIn<'info>>
   |                    ----- lifetime `'info` defined here
80 |               user_token_source: UncheckedAccount::try_from(
   |  ________________________________-
81 | |                 &accounts.user_token_source.to_account_info(),
   | |                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use
82 | |             ).clone(),
   | |_____________- argument requires that borrow lasts for `'info`
88 |           };
   |            - temporary value is freed at the end of this statement

  • And just like? ``` let account_info = accounts.user_token_source.to_account_info(); let smt = UncheckedAccount::try_from(&account_info); ```
    – chalda
    Commented Jun 5 at 15:13

2 Answers 2


The two types aren't inherently different under the hood. UncheckedAccount simply skips the validation checks a normal included account would go through in an Anchor instruction.

You can attempt to reconcile this using the current accounts you've passed in, along with the programId and ix data using the below:

let unchecked = UncheckedAccount::try_accounts(

However, this won't skip any of the checks, and at this point it'd be better to look at why the program is expecting an UncheckedAccount, and evaluate the current account types/validations in place currently.


Not sure if I fully understand your question, but you want to convert a typed account to an untyped account?

Since both AccountInfo and UncheckedAccount are basically just AccountInfo types, using .to_account_info works

Converting the token account Account<'info, TokenAccount> to AccountInfo would look like

let unchecked = ctx.accounts.user_token_source.to_account_info();
  • thx, when I changed as you suggested, the err is -> expected UncheckedAccount<'_>, found AccountInfo<'_>
    – att
    Commented Jun 5 at 12:14
  • Basically I'm trying to add swapInOut instruction to the https://github.com/raydium-io/raydium-contract-instructions/blob/master/example/programs/amm-proxy/src/lib.rs. After swapIn and get tokens, I need to know the amount of token I get, then I'll swapOut back for WSOL. Can you please comment out on that? Thank you
    – att
    Commented Jun 6 at 14:16
  • @att could you create a new question and provide more context? Is it still converting type TokenAccount to AccountInfo?
    – Jimii
    Commented Jun 8 at 10:43

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.