franco-bianco / sol-swap-parse

17 stars 2 forks source link

Fail to parse moonshot buy and raydium TX with custom program #2

Closed ix-56h closed 3 weeks ago

ix-56h commented 4 weeks ago

Hi,

Thanks for your work and reactivity. I've noticed that sometimes, the moonshot buy swap is not correctly parsed :

Working tx : AhiFQX1Z3VYbkKQH64ryPDRwxUv8oEPzQVjSvT7zY58UYDm4Yvkkt2Ee9VtSXtF6fJz8fXmb5j3xYVDF17Gr9CG

  "TokenInMint": "So11111111111111111111111111111111111111112",
  "TokenInAmount": 4999500,
  "TokenInDecimals": 9,
  "TokenOutMint": "DpFmJ6tCTmmnXFAy4qMujKuDd9Z86g7ecFqu75tktYYE",
  "TokenOutAmount": 172904389391231,
  "TokenOutDecimals": 9

Not working tx : C4cA4n4ALP5dtsmYaQDMxfu1M1Rgna1E9L16YuLC7FhGi8UeqLdtpyLk6bx2kvcJw5KYdoAvexwtjRHPwgp6L4G

  "TokenInMint": "thLdrYehS3qQLa2jgaCksSAVBRE4vYQ4Gj1qfUZZH8k",
  "TokenInAmount": 56612378894086665,
  "TokenInDecimals": 9,
  "TokenOutMint": "So11111111111111111111111111111111111111112",
  "TokenOutAmount": 1980000000,
  "TokenOutDecimals": 9

Both are buy, but the tx C4cA...6L4G tokenIn and tokenOut are not correctly set.

For raydium, these TX can't be parsed : 4MSVpVBwxnYTQSF3bSrAB99a3pVr6P6bgoCRDsrBbDMA77WeQqoBDDDXqEh8WpnUy5U4GeotdCG9xyExjNTjYE1u 2w8qogodpouCcj9c7xjs3MV9KpGKVPbH7YpGo1EW27TLfDbpE11DmvQ79mdCytume6XKBoXpMv3a9YeGmJ741m8R

For tx with custom program, i've read that custom program are not yet supported, and i wonder if it's actually planned ? I'm currently in test phase with your code without the check on outerInstruction in the parse.go, and it work pretty well but still have some weird behavior.

Thanks.

franco-bianco commented 3 weeks ago

I just realised that the 0 // 1 which I thought was used for the direction of the trade isn’t right. I’ll look into it and fix it tomorrow, will probably have to check the first few bytes of the instruction data for this.

On 15 Sep 2024, at 06:16, Zarial @.***> wrote:

Hi,

Thanks for your work and reactivity. I've noticed that sometimes, the moonshot buy swap is not correctly parsed :

Working tx : AhiFQX1Z3VYbkKQH64ryPDRwxUv8oEPzQVjSvT7zY58UYDm4Yvkkt2Ee9VtSXtF6fJz8fXmb5j3xYVDF17Gr9CG

"TokenInMint": "So11111111111111111111111111111111111111112", "TokenInAmount": 4999500, "TokenInDecimals": 9, "TokenOutMint": "DpFmJ6tCTmmnXFAy4qMujKuDd9Z86g7ecFqu75tktYYE", "TokenOutAmount": 172904389391231, "TokenOutDecimals": 9 Not working tx : C4cA4n4ALP5dtsmYaQDMxfu1M1Rgna1E9L16YuLC7FhGi8UeqLdtpyLk6bx2kvcJw5KYdoAvexwtjRHPwgp6L4G

"TokenInMint": "thLdrYehS3qQLa2jgaCksSAVBRE4vYQ4Gj1qfUZZH8k", "TokenInAmount": 56612378894086665, "TokenInDecimals": 9, "TokenOutMint": "So11111111111111111111111111111111111111112", "TokenOutAmount": 1980000000, "TokenOutDecimals": 9 Both are buy, but the tx C4cA...6L4G tokenIn and tokenOut are not correctly set.

Also, on raydium, this tx can't be parsed, and i wonder if it's actually supposed to work : 2w8qogodpouCcj9c7xjs3MV9KpGKVPbH7YpGo1EW27TLfDbpE11DmvQ79mdCytume6XKBoXpMv3a9YeGmJ741m8R

Thanks.

— Reply to this email directly, view it on GitHub https://github.com/franco-bianco/sol-swap-parse/issues/2, or unsubscribe https://github.com/notifications/unsubscribe-auth/AZP32TWZ2S3AIYLRRMQ3VWTZWSYSPAVCNFSM6AAAAABOHGQWOKVHI2DSMVQWIX3LMV43ASLTON2WKOZSGUZDMNRSGU3TCOI. You are receiving this because you are subscribed to this thread.

franco-bianco commented 3 weeks ago

Hi,

I just fixed the trade type for moonshot. I've just pushed the fix, let me know if you've other questions/encounter any other errors. We're now comparing the first 8 bytes of the instruction data to determine the right types, got this from the bindings:

var (
    MOONSHOT_BUY_INSTRUCTION  = ag_binary.TypeID([8]byte{102, 6, 61, 18, 1, 218, 235, 234})
    MOONSHOT_SELL_INSTRUCTION = ag_binary.TypeID([8]byte{51, 230, 133, 164, 1, 127, 131, 173})
)

The results are now correct:

{
  "Signers": [
    "BCRijED3Xe7QHqZQfFfGDvbWUmw79cEhNxcTNc1vAfyc"
  ],
  "Signatures": [
    "C4cA4n4ALP5dtsmYaQDMxfu1M1Rgna1E9L16YuLC7FhGi8UeqLdtpyLk6bx2kvcJw5KYdoAvexwtjRHPwgp6L4G"
  ],
  "AMMs": [
    "Moonshot"
  ],
  "Timestamp": "0001-01-01T00:00:00Z",
  "TokenInMint": "So11111111111111111111111111111111111111112",
  "TokenInAmount": 1980000000,
  "TokenInDecimals": 9,
  "TokenOutMint": "thLdrYehS3qQLa2jgaCksSAVBRE4vYQ4Gj1qfUZZH8k",
  "TokenOutAmount": 56612378894086665,
  "TokenOutDecimals": 9
}

Regarding the custom programs, I need to do a little more experimentation first. I don't really think even block explorers parse custom programs - it isn't because its complicated but I don't think its possible to have a general case that envelopes everything.

Thanks!