Skip to content

Commit

Permalink
fixes #9
Browse files Browse the repository at this point in the history
  • Loading branch information
0xjeffro committed Dec 9, 2024
1 parent 6fe810d commit 5392a6b
Show file tree
Hide file tree
Showing 3 changed files with 377 additions and 3 deletions.
342 changes: 342 additions & 0 deletions solana/data/raydiumLiquidityPoolV4_swap_2.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,342 @@
[
{
"blockTime": 1733393650,
"meta": {
"computeUnitsConsumed": 53274,
"err": null,
"fee": 205002,
"innerInstructions": [
{
"index": 2,
"instructions": [
{
"accounts": [
9
],
"data": "84eT",
"programIdIndex": 11,
"stackHeight": 2
},
{
"accounts": [
0,
1
],
"data": "11119os1e9qSs2u7TsThXqkBSRVFxhmYaFKFZ1waB2X7armDmvK3p5GmLdUxYdg3h7QSrL",
"programIdIndex": 10,
"stackHeight": 2
},
{
"accounts": [
1
],
"data": "P",
"programIdIndex": 11,
"stackHeight": 2
},
{
"accounts": [
1,
9
],
"data": "6MwZH6Px6qJXZj8tYueKo9WrrKfRVDHxJCdK88k4LkM36",
"programIdIndex": 11,
"stackHeight": 2
}
]
},
{
"index": 3,
"instructions": [
{
"accounts": [
5,
4,
0
],
"data": "3uyyT2PjqNNj",
"programIdIndex": 11,
"stackHeight": 2
},
{
"accounts": [
3,
1,
13
],
"data": "3TfEAHDG6wy1",
"programIdIndex": 11,
"stackHeight": 2
}
]
}
],
"loadedAddresses": {
"readonly": [],
"writable": []
},
"logMessages": [
"Program ComputeBudget111111111111111111111111111111 invoke [1]",
"Program ComputeBudget111111111111111111111111111111 success",
"Program ComputeBudget111111111111111111111111111111 invoke [1]",
"Program ComputeBudget111111111111111111111111111111 success",
"Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL invoke [1]",
"Program log: Create",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]",
"Program log: Instruction: GetAccountDataSize",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 1569 of 94333 compute units",
"Program return: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA pQAAAAAAAAA=",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success",
"Program 11111111111111111111111111111111 invoke [2]",
"Program 11111111111111111111111111111111 success",
"Program log: Initialize the associated token account",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]",
"Program log: Instruction: InitializeImmutableOwner",
"Program log: Please upgrade to SPL Token 2022 for immutable owner support",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 1405 of 87746 compute units",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]",
"Program log: Instruction: InitializeAccount3",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 3158 of 83864 compute units",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success",
"Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL consumed 19277 of 99700 compute units",
"Program ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL success",
"Program 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8 invoke [1]",
"Program log: ray_log: A/JHdi4FAAAAAQAAAAAAAAABAAAAAAAAAAJJOCYGAgAAnswgeQoAAABbD7gYQVsBAFTnJwAAAAAA",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]",
"Program log: Instruction: Transfer",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4645 of 63028 compute units",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]",
"Program log: Instruction: Transfer",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4736 of 55402 compute units",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success",
"Program 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8 consumed 30632 of 80423 compute units",
"Program 675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8 success",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]",
"Program log: Instruction: CloseAccount",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 2915 of 49791 compute units",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success",
"Program 11111111111111111111111111111111 invoke [1]",
"Program 11111111111111111111111111111111 success"
],
"postBalances": [
184387854020,
0,
6124800,
44981289786,
2039280,
2039280,
2100675,
1,
731913600,
742524947309,
1,
934087680,
1141440,
13532449905,
3591360
],
"postTokenBalances": [
{
"accountIndex": 3,
"mint": "So11111111111111111111111111111111111111112",
"owner": "5Q544fKrFoe6tsEbD7S8EmxGTJYAKtTVhAW5Q5pge4j1",
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"uiTokenAmount": {
"amount": "44979250506",
"decimals": 9,
"uiAmount": 44.979250506,
"uiAmountString": "44.979250506"
}
},
{
"accountIndex": 4,
"mint": "AaJ6gmTzaQw9zxfK6BD9N89wzZLuSuwTRbi8YrTCpump",
"owner": "5Q544fKrFoe6tsEbD7S8EmxGTJYAKtTVhAW5Q5pge4j1",
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"uiTokenAmount": {
"amount": "381832376768333",
"decimals": 6,
"uiAmount": 381832376.768333,
"uiAmountString": "381832376.768333"
}
},
{
"accountIndex": 5,
"mint": "AaJ6gmTzaQw9zxfK6BD9N89wzZLuSuwTRbi8YrTCpump",
"owner": "orcACRJYTFjTeo2pV8TfYRTpmqfoYgbVi9GeANXTCc8",
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"uiTokenAmount": {
"amount": "2203179942160",
"decimals": 6,
"uiAmount": 2203179.94216,
"uiAmountString": "2203179.94216"
}
}
],
"preBalances": [
184386443918,
0,
6124800,
44983904910,
2039280,
2039280,
1100655,
1,
731913600,
742524947309,
1,
934087680,
1141440,
13532449905,
3591360
],
"preTokenBalances": [
{
"accountIndex": 3,
"mint": "So11111111111111111111111111111111111111112",
"owner": "5Q544fKrFoe6tsEbD7S8EmxGTJYAKtTVhAW5Q5pge4j1",
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"uiTokenAmount": {
"amount": "44981865630",
"decimals": 9,
"uiAmount": 44.98186563,
"uiAmountString": "44.98186563"
}
},
{
"accountIndex": 4,
"mint": "AaJ6gmTzaQw9zxfK6BD9N89wzZLuSuwTRbi8YrTCpump",
"owner": "5Q544fKrFoe6tsEbD7S8EmxGTJYAKtTVhAW5Q5pge4j1",
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"uiTokenAmount": {
"amount": "381810122428251",
"decimals": 6,
"uiAmount": 381810122.428251,
"uiAmountString": "381810122.428251"
}
},
{
"accountIndex": 5,
"mint": "AaJ6gmTzaQw9zxfK6BD9N89wzZLuSuwTRbi8YrTCpump",
"owner": "orcACRJYTFjTeo2pV8TfYRTpmqfoYgbVi9GeANXTCc8",
"programId": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"uiTokenAmount": {
"amount": "2225434282242",
"decimals": 6,
"uiAmount": 2225434.282242,
"uiAmountString": "2225434.282242"
}
}
],
"rewards": [],
"status": {
"Ok": null
}
},
"slot": 305539244,
"transaction": {
"message": {
"accountKeys": [
"orcACRJYTFjTeo2pV8TfYRTpmqfoYgbVi9GeANXTCc8",
"H2AuE7NVmJ1TtqsWWfSaNh5S7TLk7j5vwzkpXu7VnDbA",
"FrSpBqMa6MbEt4EY9CvPdM6Ycuc5wRYCdNcDMxgSznLz",
"DfXYzvmP9JgF7JxMbipDcx9rSoB5fzodAaYEr1ScJ3bG",
"DB7bz74FypSXqwsAh8q2pEp4LjCbi9NpKdViCCof4aim",
"AarSAVG8DLJ27HYAy5GNmz2RAKzNWx5qk85AVUG3Vas3",
"DfXygSm4jCyNCybVYYK6DwvWqjKee8pbDmJGcLWNDXjh",
"ComputeBudget111111111111111111111111111111",
"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",
"So11111111111111111111111111111111111111112",
"11111111111111111111111111111111",
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"675kPX9MHTjS2zt1qfr1NYHuzeLXfQM9H24wFSUt1Mp8",
"5Q544fKrFoe6tsEbD7S8EmxGTJYAKtTVhAW5Q5pge4j1",
"5m2GnfN5ma2R64xMf1R8ciHNzVv8HbCBZNCDyHBXChxr"
],
"addressTableLookups": [],
"header": {
"numReadonlySignedAccounts": 0,
"numReadonlyUnsignedAccounts": 8,
"numRequiredSignatures": 1
},
"instructions": [
{
"accounts": [],
"data": "3eJMY7mcBi9m",
"programIdIndex": 7,
"stackHeight": null
},
{
"accounts": [],
"data": "JC3gyu",
"programIdIndex": 7,
"stackHeight": null
},
{
"accounts": [
0,
1,
0,
9,
10,
11
],
"data": "",
"programIdIndex": 8,
"stackHeight": null
},
{
"accounts": [
11,
2,
13,
14,
3,
4,
14,
14,
14,
14,
14,
14,
14,
14,
5,
1,
0
],
"data": "6RRg4WiFngE5NtxBuqnEfbV",
"programIdIndex": 12,
"stackHeight": null
},
{
"accounts": [
1,
0,
0
],
"data": "A",
"programIdIndex": 11,
"stackHeight": null
},
{
"accounts": [
0,
6
],
"data": "3Bxs4Ex4wq3eMLMV",
"programIdIndex": 10,
"stackHeight": null
}
],
"recentBlockhash": "9gS6fP4QuxbFdCzL1gfc1n776v37agKK1wsyer5yzzKq"
},
"signatures": [
"2XgzfkWeDeua4oemWXrj3JzhxVsV4mGsqVZfETSbhn6hGFuLvi2fjdK2TGcmuQQnZSEjUmMmPjUnCFWDebGJcgWQ"
]
},
"version": 0
}
]
28 changes: 28 additions & 0 deletions solana/parser_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package solana

import (
"fmt"
"github.com/0xjeffro/tx-parser/solana/programs/jupiterAggregatorV6"
"io/ioutil"
"os"
Expand Down Expand Up @@ -556,6 +557,33 @@ func TestRaydiumLiquidityPoolV4Swap_1(t *testing.T) {
}
}

func TestRaydiumLiquidityPoolV4Swap_2(t *testing.T) {
byteValue, err := readJsonFile("data/raydiumLiquidityPoolV4_swap_2.json")
if err != nil {
t.Errorf("Error reading JSON file: %v", err)
}
results, _ := Parser(byteValue)
action := results[0].Actions[3]

fmt.Println(action)

if swapAction, ok := action.(*types.RaydiumLiquidityPoolV4SwapAction); ok {
assert.Equal(t, swapAction.ProgramID, raydiumLiquidityPoolV4.Program)
assert.Equal(t, swapAction.ProgramName, raydiumLiquidityPoolV4.ProgramName)
assert.Equal(t, swapAction.InstructionName, "Swap")
assert.Equal(t, swapAction.Who, "orcACRJYTFjTeo2pV8TfYRTpmqfoYgbVi9GeANXTCc8")
assert.Equal(t, swapAction.FromToken, "AaJ6gmTzaQw9zxfK6BD9N89wzZLuSuwTRbi8YrTCpump")
assert.Equal(t, swapAction.FromTokenAmount, uint64(22254340082))
assert.Equal(t, swapAction.FromTokenDecimals, uint64(6))
assert.Equal(t, swapAction.ToToken, globals.WSOL)
assert.Equal(t, swapAction.ToTokenAmount, uint64(2615124))
assert.Equal(t, swapAction.ToTokenDecimals, uint64(globals.SOLDecimals))
assert.Equal(t, swapAction.MinimumAmountOut, uint64(1))
} else {
t.Errorf("Error type assertion")
}
}

func TestJupiterAggregatorV6SharedAccountRoute_1(t *testing.T) {
byteValue, err := readJsonFile("data/jupiterAggregatorV6_sharedAccountsRoute_1.json")
if err != nil {
Expand Down
Loading

0 comments on commit 5392a6b

Please sign in to comment.