project-serum / swap-ui

React Component for Swapping on the Serum DEX
Apache License 2.0
113 stars 117 forks source link

bug: First token balance not updated after swap #75

Open secretshardul opened 3 years ago

secretshardul commented 3 years ago

After swaps go through, the second token's balance is updated but the first one's not. This leaves end-users confused.

  1. Before swap: 0.1 SRM, 0.04 USDC. image

  2. After swap: SRM balance remains 0.1, even though USDC balance is 0.8 now image

armaniferrante commented 3 years ago

After swaps go through, the second token's balance is updated but the first one's not. This leaves end-users confused.

  1. Before swap: 0.1 SRM, 0.04 USDC. image
  2. After swap: SRM balance remains 0.1, even though USDC balance is 0.8 now image

Likely an RPC node issue with websockets. We might want to instead poll for accounts instead.

matt-scientist commented 2 years ago

I think this is actually an issue with the useOwnedTokenAccount hook. The account is updated properly in the _OWNED_TOKEN_ACCOUNTS_CACHE by using provider.connection.onAccountChange, but this value isn't propagated to the returned tokenAccount. I've been looking at it for a few hours, but can't figure out how to resolve it