Skip to content

swaps fail if token account does not exist #141

Description

@wphan

observed behavior: If user attempts to swap from a token which they don't have a token account for, the tx fails with:

[2025-12-29T02:24:07Z DEBUG gateway] request: SwapRequest { amount: 0.001, exact_in: true, input_market: 17, output_market: 1, slippage_bps: 30, use_direct_routes: None, exclude_dexes: None }

...

[2025-12-29T02:24:07Z DEBUG solana_rpc_client::nonblocking::rpc_client] -32002 Transaction simulation failed: Error processing Instruction 1: custom program error: 0xbc4
[2025-12-29T02:24:07Z DEBUG solana_rpc_client::nonblocking::rpc_client]   1: Program ComputeBudget111111111111111111111111111111 invoke [1]
[2025-12-29T02:24:07Z DEBUG solana_rpc_client::nonblocking::rpc_client]   2: Program ComputeBudget111111111111111111111111111111 success
[2025-12-29T02:24:07Z DEBUG solana_rpc_client::nonblocking::rpc_client]   3: Program dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH invoke [1]
[2025-12-29T02:24:07Z DEBUG solana_rpc_client::nonblocking::rpc_client]   4: Program log: Instruction: BeginSwap
[2025-12-29T02:24:07Z DEBUG solana_rpc_client::nonblocking::rpc_client]   5: Program log: AnchorError caused by account: in_token_account. Error Code: AccountNotInitialized. Error Number: 3012. Error Message: The program expected this account to be already initialized.
[2025-12-29T02:24:07Z DEBUG solana_rpc_client::nonblocking::rpc_client]   6: Program dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH consumed 13297 of 602850 compute units
[2025-12-29T02:24:07Z DEBUG solana_rpc_client::nonblocking::rpc_client]   7: Program dRiftyHA39MWEi3m9aunc5MzRF1JYuBsbn6VPcn33UH failed: custom program error: 0xbc4
[2025-12-29T02:24:07Z DEBUG solana_rpc_client::nonblocking::rpc_client] 

expected behavior: gateway should initialize that account in the same tx as the swap tx (prepend a createAccount ix)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions