Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 23f37cff2c | |||
| 6bab10866b | |||
| 83aa772710 | |||
| da51b19b50 | |||
| f39b89b497 |
6
go.mod
6
go.mod
@@ -4,10 +4,13 @@ go 1.25.1
|
||||
|
||||
require (
|
||||
github.com/BlockRazorinc/solana-trader-client-go v0.0.0-20250722092120-44561cb37455
|
||||
github.com/gagliardetto/binary v0.8.0
|
||||
github.com/gagliardetto/solana-go v1.12.0
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7
|
||||
github.com/mr-tron/base58 v1.2.0
|
||||
github.com/near/borsh-go v0.3.2-0.20220516180422-1ff87d108454
|
||||
github.com/panjf2000/ants/v2 v2.11.4
|
||||
github.com/quic-go/quic-go v0.58.0
|
||||
github.com/shopspring/decimal v1.4.0
|
||||
google.golang.org/grpc v1.75.0
|
||||
google.golang.org/protobuf v1.36.10
|
||||
@@ -19,10 +22,8 @@ require (
|
||||
github.com/blendle/zapdriver v1.3.1 // indirect
|
||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||
github.com/fatih/color v1.9.0 // indirect
|
||||
github.com/gagliardetto/binary v0.8.0 // indirect
|
||||
github.com/gagliardetto/treeout v0.1.4 // indirect
|
||||
github.com/google/uuid v1.6.0 // indirect
|
||||
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
|
||||
github.com/json-iterator/go v1.1.12 // indirect
|
||||
github.com/klauspost/compress v1.13.6 // indirect
|
||||
github.com/logrusorgru/aurora v2.0.3+incompatible // indirect
|
||||
@@ -32,7 +33,6 @@ require (
|
||||
github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect
|
||||
github.com/modern-go/reflect2 v1.0.2 // indirect
|
||||
github.com/mostynb/zstdpool-freelist v0.0.0-20201229113212-927304c0c3b1 // indirect
|
||||
github.com/quic-go/quic-go v0.58.0 // indirect
|
||||
github.com/streamingfast/logging v0.0.0-20230608130331-f22c91403091 // indirect
|
||||
go.mongodb.org/mongo-driver v1.12.2 // indirect
|
||||
go.uber.org/atomic v1.7.0 // indirect
|
||||
|
||||
5
go.sum
5
go.sum
@@ -88,9 +88,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
|
||||
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
|
||||
github.com/stretchr/testify v1.11.1 h1:7s2iGBzp5EwR7/aIZr8ao5+dra3wiQyKjjFuvgVKu7U=
|
||||
github.com/stretchr/testify v1.11.1/go.mod h1:wZwfW3scLgRK+23gO65QZefKpKQRnfz6sD981Nm4B6U=
|
||||
github.com/test-go/testify v1.1.4 h1:Tf9lntrKUMHiXQ07qBScBTSA0dhYQlu83hswqelv1iE=
|
||||
github.com/test-go/testify v1.1.4/go.mod h1:rH7cfJo/47vWGdi4GPj16x3/t1xGOj2YxzmNQzk2ghU=
|
||||
github.com/xdg-go/pbkdf2 v1.0.0/go.mod h1:jrpuAogTd400dnrH08LKmI/xc1MbPOebTwRqcT5RDeI=
|
||||
@@ -118,6 +117,8 @@ go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw=
|
||||
go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
|
||||
go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI=
|
||||
go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ=
|
||||
go.uber.org/mock v0.5.2 h1:LbtPTcP8A5k9WPXj54PPPbjcI4Y6lhyOZXn+VS7wNko=
|
||||
go.uber.org/mock v0.5.2/go.mod h1:wLlUxC2vVTPTaE3UD51E0BGOAElKrILxhVSDYQLld5o=
|
||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||
go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4=
|
||||
go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU=
|
||||
|
||||
@@ -128,10 +128,14 @@ func (c *Client) ReadSync(ctx context.Context, txCh chan<- TxSignalBatch) error
|
||||
return err
|
||||
}
|
||||
|
||||
// reboot the pool
|
||||
c.pool.Reboot()
|
||||
|
||||
for {
|
||||
response, err := stream.Recv()
|
||||
var response *SubscribeTransactionsResponse
|
||||
response, err = stream.Recv()
|
||||
if err != nil {
|
||||
return err
|
||||
break
|
||||
}
|
||||
|
||||
if c.enableBlockStats {
|
||||
@@ -165,7 +169,12 @@ func (c *Client) ReadSync(ctx context.Context, txCh chan<- TxSignalBatch) error
|
||||
}
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// sync waiting for all tasks to complete
|
||||
c.pool.Release()
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -47,6 +47,8 @@ var (
|
||||
jupiterV6ProgramID = solana.MustPublicKeyFromBase58("JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4")
|
||||
|
||||
gmgnProgramID = solana.MustPublicKeyFromBase58("GMgnVFR8Jb39LoXsEVzb3DvBy3ywCmdmJquHUy1Lrkqb")
|
||||
|
||||
bonkProgramID = solana.MustPublicKeyFromBase58("BBRouter1cVunVXvkcqeKkZQcBK7ruan37PPm3xzWaXD")
|
||||
)
|
||||
|
||||
type AccountNotFoundError struct {
|
||||
@@ -98,6 +100,8 @@ var (
|
||||
terminalAmmSellTokensIX = []byte{0x40, 0x64, 0x97, 0xb9, 0x16, 0xfa, 0xec, 0xb1}
|
||||
|
||||
gmgnBuyTokensIX = []byte{0x66, 0x06, 0x3d, 0x12, 0x01, 0xda, 0xeb, 0xea}
|
||||
|
||||
bonkBuyAndSellTokensIX = []byte{0x00, 0x01, 0x00, 0x00, 0x00, 0x09, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a}
|
||||
)
|
||||
|
||||
type compiledInstruction struct {
|
||||
@@ -342,6 +346,9 @@ func ParseTransaction(update *SubscribeUpdateTransaction, loader *AddressTables,
|
||||
case gmgnProgramID:
|
||||
txRes, err := parseGMGNInstruction(versioned, i)
|
||||
parsed = appendParsed(now, parsed, txRes, err, txHash, "gmgn")
|
||||
case bonkProgramID:
|
||||
txRes, err := parseBonkInstruction(versioned, i)
|
||||
parsed = appendParsed(now, parsed, txRes, err, txHash, "bonk")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1119,6 +1126,7 @@ func parsePhotonBuy(tx *versionedTransaction, instruction *compiledInstruction)
|
||||
Event: "buy",
|
||||
IsToken2022: false,
|
||||
IsMayhemMode: false,
|
||||
ExactSOL: true,
|
||||
Block: tx.Block,
|
||||
Token0AmountUint64: args.TokenAmount,
|
||||
Token1AmountUint64: solAmount,
|
||||
@@ -1702,6 +1710,99 @@ func parseFjszInstruction(tx *versionedTransaction, instructionIndex int) (*TxSi
|
||||
}, nil
|
||||
}
|
||||
|
||||
func parseBonkInstruction(tx *versionedTransaction, instructionIndex int) (*TxSignal, error) {
|
||||
msg := tx.Message
|
||||
if instructionIndex >= len(msg.Instructions) {
|
||||
return nil, fmt.Errorf("instruction index out of bounds")
|
||||
}
|
||||
|
||||
instruction := msg.Instructions[instructionIndex]
|
||||
if len(instruction.Data) == 0 {
|
||||
return nil, fmt.Errorf("data is empty")
|
||||
}
|
||||
|
||||
if matchMethod(instruction.Data, bonkBuyAndSellTokensIX) {
|
||||
return parseBonkBuyAndSell(tx, &instruction)
|
||||
}
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
func parseBonkBuyAndSell(tx *versionedTransaction, instruction *compiledInstruction) (*TxSignal, error) {
|
||||
if len(instruction.Accounts) < 8 {
|
||||
return nil, fmt.Errorf("accounts too short")
|
||||
}
|
||||
staticKeys := tx.Message.StaticAccountKeys
|
||||
programId, err := getStaticKey(staticKeys, int(instruction.Accounts[7]))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if programId != pumpProgramID {
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
user, err := getStaticKey(staticKeys, int(instruction.Accounts[0]))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
flagAccount, err := getStaticKey(staticKeys, int(instruction.Accounts[4]))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
amount1 := binary.LittleEndian.Uint64(instruction.Data[17:25])
|
||||
amount2 := binary.LittleEndian.Uint64(instruction.Data[25:33])
|
||||
|
||||
if user == flagAccount {
|
||||
mint, err := getStaticKey(staticKeys, int(instruction.Accounts[6]))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &TxSignal{
|
||||
TxHash: tx.Signatures[0].String(),
|
||||
Label: "bonk",
|
||||
Maker: user.String(),
|
||||
Token0Address: mint.String(),
|
||||
Token1Address: wsolMint,
|
||||
Token0Amount: formatTokenAmount(amount2),
|
||||
Token1Amount: formatSolAmount(amount1),
|
||||
Program: "Pump",
|
||||
Event: "buy",
|
||||
IsToken2022: false,
|
||||
IsMayhemMode: false,
|
||||
ExactSOL: true,
|
||||
Block: tx.Block,
|
||||
Token0AmountUint64: amount2,
|
||||
Token1AmountUint64: amount1,
|
||||
}, nil
|
||||
} else {
|
||||
mint, err := getStaticKey(staticKeys, int(instruction.Accounts[5]))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &TxSignal{
|
||||
TxHash: tx.Signatures[0].String(),
|
||||
Label: "bonk",
|
||||
Maker: user.String(),
|
||||
Token0Address: mint.String(),
|
||||
Token1Address: wsolMint,
|
||||
Token0Amount: formatTokenAmount(amount1),
|
||||
Token1Amount: formatSolAmount(amount2),
|
||||
Program: "Pump",
|
||||
Event: "sell",
|
||||
IsToken2022: false,
|
||||
IsMayhemMode: false,
|
||||
ExactSOL: false,
|
||||
Block: tx.Block,
|
||||
Token0AmountUint64: amount1,
|
||||
Token1AmountUint64: amount2,
|
||||
}, nil
|
||||
}
|
||||
}
|
||||
|
||||
func matchMethod(data []byte, methods []byte) bool {
|
||||
if len(data) < len(methods) {
|
||||
return false
|
||||
|
||||
@@ -1,9 +1,13 @@
|
||||
package shreder
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/hex"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"github.com/gagliardetto/solana-go"
|
||||
"github.com/gagliardetto/solana-go/rpc"
|
||||
"github.com/near/borsh-go"
|
||||
)
|
||||
|
||||
@@ -54,3 +58,234 @@ func TestDecodeAxiomArgs(t *testing.T) {
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func toUpdata(slot uint64, tx *solana.Transaction) *SubscribeUpdateTransaction {
|
||||
signatures := make([][]byte, len(tx.Signatures))
|
||||
for i, sig := range tx.Signatures {
|
||||
signatures[i] = sig[:]
|
||||
}
|
||||
|
||||
accountKeys := make([][]byte, len(tx.Message.AccountKeys))
|
||||
for i, key := range tx.Message.AccountKeys {
|
||||
accountKeys[i] = key[:]
|
||||
}
|
||||
|
||||
instructions := make([]*CompiledInstruction, len(tx.Message.Instructions))
|
||||
for i, instr := range tx.Message.Instructions {
|
||||
accounts := make([]byte, len(instr.Accounts))
|
||||
for j, acc := range instr.Accounts {
|
||||
accounts[j] = byte(acc)
|
||||
}
|
||||
instructions[i] = &CompiledInstruction{
|
||||
ProgramIdIndex: uint32(instr.ProgramIDIndex),
|
||||
Accounts: accounts,
|
||||
Data: instr.Data[:],
|
||||
}
|
||||
}
|
||||
|
||||
addressTableLookups := make([]*MessageAddressTableLookup, len(tx.Message.AddressTableLookups))
|
||||
for i, lookup := range tx.Message.AddressTableLookups {
|
||||
writable := make([]byte, len(lookup.WritableIndexes))
|
||||
for j, idx := range lookup.WritableIndexes {
|
||||
writable[j] = byte(idx)
|
||||
}
|
||||
readonly := make([]byte, len(lookup.ReadonlyIndexes))
|
||||
for j, idx := range lookup.ReadonlyIndexes {
|
||||
readonly[j] = byte(idx)
|
||||
}
|
||||
addressTableLookups[i] = &MessageAddressTableLookup{
|
||||
AccountKey: lookup.AccountKey[:],
|
||||
WritableIndexes: writable,
|
||||
ReadonlyIndexes: readonly,
|
||||
}
|
||||
}
|
||||
|
||||
return &SubscribeUpdateTransaction{
|
||||
Transaction: &Transaction{
|
||||
Signatures: signatures,
|
||||
Message: &Message{
|
||||
Header: &MessageHeader{
|
||||
NumRequiredSignatures: uint32(tx.Message.Header.NumRequiredSignatures),
|
||||
NumReadonlySignedAccounts: uint32(tx.Message.Header.NumReadonlySignedAccounts),
|
||||
NumReadonlyUnsignedAccounts: uint32(tx.Message.Header.NumReadonlyUnsignedAccounts),
|
||||
},
|
||||
AccountKeys: accountKeys,
|
||||
RecentBlockhash: nil, // TODO
|
||||
Instructions: instructions,
|
||||
Versioned: false, // TODO
|
||||
AddressTableLookups: addressTableLookups,
|
||||
},
|
||||
},
|
||||
Slot: slot,
|
||||
}
|
||||
}
|
||||
|
||||
func getTransaction(t *testing.T, client *rpc.Client, signature string) *SubscribeUpdateTransaction {
|
||||
version := uint64(0)
|
||||
tx, err := client.GetTransaction(
|
||||
context.Background(),
|
||||
solana.MustSignatureFromBase58(signature),
|
||||
&rpc.GetTransactionOpts{
|
||||
Commitment: rpc.CommitmentFinalized,
|
||||
MaxSupportedTransactionVersion: &version,
|
||||
},
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get transaction: %v", err)
|
||||
}
|
||||
|
||||
_tx, err := tx.Transaction.GetTransaction()
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get transaction: %v", err)
|
||||
}
|
||||
|
||||
return toUpdata(tx.Slot, _tx)
|
||||
}
|
||||
|
||||
func TestParseTermBuy(t *testing.T) {
|
||||
rpcUrl := os.Getenv("SOL_RPC_URL")
|
||||
if rpcUrl == "" {
|
||||
t.Fatalf("SOL_RPC_URL is not set")
|
||||
}
|
||||
|
||||
client := rpc.New(rpcUrl)
|
||||
signals := ParseTransaction(
|
||||
getTransaction(t, client, "5Gz1fa4Qhb35bkg9QCMXpxCX5uuNr7WcjcmrwajGZA7kXsvNS9pDnYe12ggWeSqf1nwZbVPob6DkX6fcwbE9ofBR"),
|
||||
nil,
|
||||
false,
|
||||
)
|
||||
if len(signals) != 1 {
|
||||
t.Fatalf("expected 1 signal, got %d", len(signals))
|
||||
}
|
||||
|
||||
signal := signals[0]
|
||||
if signal.Label != "terminal" {
|
||||
t.Fatalf("expected terminal signal, got %s", signal.Label)
|
||||
}
|
||||
if signal.Event != "buy" {
|
||||
t.Fatalf("expected buy event, got %s", signal.Event)
|
||||
}
|
||||
if signal.Maker != "BaLxyjXzATAnfm7cc5AFhWBpiwnsb71THcnofDLTWAPK" {
|
||||
t.Fatalf("expected maker BaLxyjXzATAnfm7cc5AFhWBpiwnsb71THcnofDLTWAPK, got %s", signal.Maker)
|
||||
}
|
||||
if signal.Token0Address != "5Wgv54peXRKDHYHapAELzgNKEPEh9E5Bf3hUR3sTpump" {
|
||||
t.Fatalf("expected token0 address 5Wgv54peXRKDHYHapAELzgNKEPEh9E5Bf3hUR3sTpump, got %s", signal.Token0Address)
|
||||
}
|
||||
if signal.Token0AmountUint64 != 6952026214256 {
|
||||
t.Fatalf("expected token0 amount 6952026214256, got %d", signal.Token0AmountUint64)
|
||||
}
|
||||
if signal.Token1AmountUint64 != 653333333 {
|
||||
t.Fatalf("expected token1 amount 653333333, got %d", signal.Token1AmountUint64)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseBonkBuy(t *testing.T) {
|
||||
rpcUrl := os.Getenv("SOL_RPC_URL")
|
||||
if rpcUrl == "" {
|
||||
t.Fatalf("SOL_RPC_URL is not set")
|
||||
}
|
||||
|
||||
client := rpc.New(rpcUrl)
|
||||
signals := ParseTransaction(
|
||||
getTransaction(t, client, "3gHF3TA2aA8rpjdmoEs2vA89vrq9J9NnTTUSXHfE6uXcaYP9cJgLtEUjCmsK9EWAyHEg7cEiepehQf4GFv1272jW"),
|
||||
nil,
|
||||
false,
|
||||
)
|
||||
if len(signals) != 1 {
|
||||
t.Fatalf("expected 1 signal, got %d", len(signals))
|
||||
}
|
||||
|
||||
signal := signals[0]
|
||||
if signal.Label != "bonk" {
|
||||
t.Fatalf("expected bonk signal, got %s", signal.Label)
|
||||
}
|
||||
if signal.Event != "buy" {
|
||||
t.Fatalf("expected buy event, got %s", signal.Event)
|
||||
}
|
||||
if signal.Maker != "BFobdhAbdBteBuDvHUdBthsQqJyMuWnG9SGUheW1Ni2C" {
|
||||
t.Fatalf("expected maker BFobdhAbdBteBuDvHUdBthsQqJyMuWnG9SGUheW1Ni2C, got %s", signal.Maker)
|
||||
}
|
||||
if signal.Token0Address != "Awupo9Jxe1fsc7eEtCEcN9D3PoyReQhc9WEuEAHXpump" {
|
||||
t.Fatalf("expected token0 address Awupo9Jxe1fsc7eEtCEcN9D3PoyReQhc9WEuEAHXpump, got %s", signal.Token0Address)
|
||||
}
|
||||
if signal.Token0AmountUint64 != 8616799656436 {
|
||||
t.Fatalf("expected token0 amount 8616799656436, got %d", signal.Token0AmountUint64)
|
||||
}
|
||||
if signal.Token1AmountUint64 != 495000000 {
|
||||
t.Fatalf("expected token1 amount 495000000, got %d", signal.Token1AmountUint64)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParseBonkSell(t *testing.T) {
|
||||
rpcUrl := os.Getenv("SOL_RPC_URL")
|
||||
if rpcUrl == "" {
|
||||
t.Fatalf("SOL_RPC_URL is not set")
|
||||
}
|
||||
|
||||
client := rpc.New(rpcUrl)
|
||||
signals := ParseTransaction(
|
||||
getTransaction(t, client, "3XNi6b3j69SSStqLLRQVH5BNGVfEoFxGCzmpdd5FvrY4kmC8T644WGdEhCH9fAdrxWuR2Mtzgywq8K7qetu5MGyb"),
|
||||
nil,
|
||||
false,
|
||||
)
|
||||
if len(signals) != 1 {
|
||||
t.Fatalf("expected 1 signal, got %d", len(signals))
|
||||
}
|
||||
|
||||
signal := signals[0]
|
||||
if signal.Label != "bonk" {
|
||||
t.Fatalf("expected bonk signal, got %s", signal.Label)
|
||||
}
|
||||
if signal.Event != "sell" {
|
||||
t.Fatalf("expected sell event, got %s", signal.Event)
|
||||
}
|
||||
if signal.Maker != "2xTT7XXCEYSCrRb3G4Egc4ZwpCe78qq6r7w6ChZhbTXc" {
|
||||
t.Fatalf("expected maker 2xTT7XXCEYSCrRb3G4Egc4ZwpCe78qq6r7w6ChZhbTXc, got %s", signal.Maker)
|
||||
}
|
||||
if signal.Token0Address != "8pgpJDYuojYXvb8KE4Hv7DCty12FrkqpKChgfHzspump" {
|
||||
t.Fatalf("expected token0 address 8pgpJDYuojYXvb8KE4Hv7DCty12FrkqpKChgfHzspump, got %s", signal.Token0Address)
|
||||
}
|
||||
if signal.Token0AmountUint64 != 6235736929390 {
|
||||
t.Fatalf("expected token0 amount 6235736929390, got %d", signal.Token0AmountUint64)
|
||||
}
|
||||
if signal.Token1AmountUint64 != 1379707703 {
|
||||
t.Fatalf("expected token1 amount 1379707703, got %d", signal.Token1AmountUint64)
|
||||
}
|
||||
}
|
||||
|
||||
func TestParsePhotonBuy(t *testing.T) {
|
||||
rpcUrl := os.Getenv("SOL_RPC_URL")
|
||||
if rpcUrl == "" {
|
||||
t.Fatalf("SOL_RPC_URL is not set")
|
||||
}
|
||||
|
||||
client := rpc.New(rpcUrl)
|
||||
signals := ParseTransaction(
|
||||
getTransaction(t, client, "4DCEcXAWBxagXoUNGhWsJ7qfxq5SuE5BG2cBDBqAY7sCHkBopaMJu33ZnXnFHqzPMmWxVxq6666KRF4hMHVB33Ux"),
|
||||
nil,
|
||||
false,
|
||||
)
|
||||
if len(signals) != 1 {
|
||||
t.Fatalf("expected 1 signal, got %d", len(signals))
|
||||
}
|
||||
|
||||
signal := signals[0]
|
||||
if signal.Label != "photon" {
|
||||
t.Fatalf("expected terminal signal, got %s", signal.Label)
|
||||
}
|
||||
if signal.Event != "buy" {
|
||||
t.Fatalf("expected buy event, got %s", signal.Event)
|
||||
}
|
||||
if signal.Maker != "8sUm7sLf3Steu6oVyVQqoA9GpFcMRz6YhrAidd4x7g7a" {
|
||||
t.Fatalf("expected maker 8sUm7sLf3Steu6oVyVQqoA9GpFcMRz6YhrAidd4x7g7a, got %s", signal.Maker)
|
||||
}
|
||||
if signal.Token0Address != "jx4PF2MwC7AK9S8dTeYm29hM3vAN8Rtfs2VX4Vz5UVj" {
|
||||
t.Fatalf("expected token0 address jx4PF2MwC7AK9S8dTeYm29hM3vAN8Rtfs2VX4Vz5UVj, got %s", signal.Token0Address)
|
||||
}
|
||||
if signal.Token0AmountUint64 != 1796593710706 {
|
||||
t.Fatalf("expected token0 amount 1796593710706, got %d", signal.Token0AmountUint64)
|
||||
}
|
||||
if signal.Token1AmountUint64 != 1955555553 {
|
||||
t.Fatalf("expected token1 amount 1955555553, got %d", signal.Token1AmountUint64)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user