Skip to content

Bug: Raydium Parser Swaps TokenIn and TokenOut for Pump.fun Migrated TokensΒ #6

@vexelgray

Description

@vexelgray

I've identified a potential bug in the Raydium transaction parser within this library. It appears that for transactions involving tokens that have migrated from Pump.fun to Raydium, the parser incorrectly swaps the tokenIn and tokenOut fields in the parsed output.

This issue is not observed with tokens that were originally deployed directly on Raydium.

To demonstrate this problem, I've provided two example "buy" transactions (WSOL being exchanged for another token):

Example 1: Transaction with a Pump.fun Migrated Token

Signature: 48Sysuy1xSfiUhuH7Ktj4yri2RCoPuDyCWXbgKZqACTXE5oPVUP1C2MLtEeM2icbQrp9z4Q3gDPXWSEPx6BHRv8w

Parsed Output:

RaydiumParser {
  amountIn: 248526n,
  amountOut: 60166396n,
  baseReserve: 565278097927n,
  quoteReserve: 137193807824049n,
  tokenIn: PublicKey [PublicKey(hTRDn7zE5tDHRnjj6Qms2WG1zEGv9ii6AiwfgbFpump)] {
    _bn: <BN: a5d1a5300134806cc52d503758a539194031cc6b13795f6b4bbc4f628fc17af>
  },
  tokenInDecimal: 6n,
  tokenOut: PublicKey [PublicKey(So11111111111111111111111111111111111111112)] {
    _bn: <BN: 69b8857feab8184fb687f634618c035dac439dc1aeb3b5598a0f00000000001>
  },
  tokenOutDecimal: 9n,
  user: PublicKey [PublicKey(AA95dMp7ZmqV2KM7x4q1hXiaTtwaboNyz2ZhJNd12g42)] {
    _bn: <BN: 88108ba27d19e33d676a3c0e934329d2a8a7332b5bef9b8bfc69be3651b80f93>
  },
  poolId: PublicKey [PublicKey(3eGxLTiyoDwoRc9vnzSERz2yqf66xgBQgHBJu4EDSNWt)] {
    _bn: <BN: 2743e731bb9cec57bab31fd62a15660cc60547c239bfe7ba773feee788143041>
  }
}

Problem: In this case, the expected behavior is that tokenIn should represent WSOL (SOL being spent) and tokenOut should be the migrated Pump.fun token (token being received). However, the parser output incorrectly reverses these. The tokenIn is identified as hTRDn7zE5tDHRnjj6Qms2WG1zEGv9ii6AiwfgbFpump (the migrated token) and tokenOut as So11111111111111111111111111111111111111112 (WSOL).

Example 2: Transaction with a Token Deployed Directly on Raydium

Signature: 5QAijtNpbKBemWzGefaqcwRjRFuSazkCCa4gRxh6DW8E1bqBDoeK2aDtE7QRMV1ddXv61uTagtp7AgkfZihyxoFF

Parsed Output:

RaydiumParser {
  amountIn: 100000000n,
  amountOut: 113305726n,
  baseReserve: 238920252098n,
  quoteReserve: 210236442000n,
  tokenIn: PublicKey [PublicKey(So11111111111111111111111111111111111111112)] {
    _bn: <BN: 69b8857feab8184fb687f634618c035dac439dc1aeb3b5598a0f00000000001>
  },
  tokenInDecimal: 9n,
  tokenOut: PublicKey [PublicKey(EkDsamMWbbEFPu7oV19SGo7ZUETDSGy56MK21MkNN4S5)] {
    _bn: <BN: cc3a75993d7314587dae2ff535621e758956391fa49b7453e7a28e8f97f13092>
  },
  tokenOutDecimal: 6n,
  user: PublicKey [PublicKey(4Ndu2tVrJee7sopWiJ97Pn5nzLC5Gmp3JbmRX7CscyPE)] {
    _bn: <BN: 321dfa3b5b878ad836fd7c44cf5bb9a3eb9a0dbcdc11b6f5bad8e24886e393e1>
  },
  poolId: PublicKey [PublicKey(9wncFDQMp8s68ufMR2VGJXCApGAmxaGScjum7XrE92g)] {
    _bn: <BN: 24a97f51c0574a6e8dec74072ed4a9e136bf2b439e78bf586cae51aef0215d9>
  }
}

Observation: The parsing in this example appears to be correct, with tokenIn being WSOL and tokenOut being the other token (EkDsamMWbbEFPu7oV19SGo7ZUETDSGy56MK21MkNN4S5).

Impact: This incorrect parsing leads to a misrepresentation of the actual tokens being traded in transactions involving Pump.fun migrated tokens, which can affect applications relying on accurate Raydium transaction data.

Could you please investigate this issue? Thank you for your time and attention to this matter.

Sincerely,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions