This commit is contained in:
thloyi
2026-02-02 14:13:00 +08:00
parent c25c856a47
commit 0eb1628119
3 changed files with 269 additions and 9 deletions

63
tx.go
View File

@@ -65,6 +65,7 @@ type SolTransfer struct {
type Tx struct {
rawTx *RawTx
Vote bool
Signer solana.PublicKey
Err interface{} `json:"err,omitempty"`
Swaps []Swap `json:"swaps,omitempty"`
@@ -91,6 +92,10 @@ type Tx struct {
// todo pool info ??
}
func (tx *Tx) GetRawTx() *RawTx {
return tx.rawTx
}
func (tx *Tx) SetRawTx(t *RawTx) {
tx.rawTx = t
}
@@ -136,16 +141,33 @@ func (tx *Tx) CheckPlatform(swap Swap) (string, decimal.Decimal) {
platformFee = info.PlatformFee
break
}
if swap.Event == "buy" && swap.Program == SolProgramRaydiumLaunchLabBonk {
for _, p := range tx.Platform {
switch p.Platform {
case PlatformAxiom:
if !checkBonkAxiomBuy(rawTx) {
platform = PlatformFake
if swap.Event == "buy" {
switch swap.Program {
case SolProgramRaydiumLaunchLabBonk:
for _, p := range tx.Platform {
switch p.Platform {
case PlatformAxiom:
if !checkBonkAxiomBuy(rawTx) {
platform = PlatformFake
}
case PlatformGMGN:
if !checkBonkGmgnBuy(rawTx) {
platform = PlatformFake
}
}
case PlatformGMGN:
if !checkBonkGmgnBuy(rawTx) {
platform = PlatformFake
}
}
if swap.Program == SolProgramRaydiumLaunchLabBonk {
for _, p := range tx.Platform {
switch p.Platform {
case PlatformAxiom:
if !checkPumpFunAxiomBuy(rawTx) {
platform = PlatformFake
}
case PlatformGMGN:
if !checkPumpFunGmgnBuy(rawTx) {
platform = PlatformFake
}
}
}
}
@@ -196,6 +218,29 @@ func (s Swap) CheckEntryContract() string {
return EntryContractUnknown
}
func (tx *Tx) LoadAfterSOLBalance(swap Swap) decimal.Decimal {
if swap.User.Equals(tx.Signer) {
return tx.AfterSOLBalance
}
found := false
makerIndex := 0
for i, account := range tx.rawTx.getAccountList() {
if account == swap.User {
found = true
makerIndex = i
break
}
}
if found && makerIndex < len(tx.rawTx.Meta.PostBalances) {
return decimal.NewFromInt(
int64(tx.rawTx.Meta.PostBalances[makerIndex]),
).Div(decimal.NewFromInt(1000000000)) // sol decimals
}
return decimal.Zero
}
func (s Swap) CheckEntryContractV2() string {
name, ok := entryContractAddresses[s.EntryContract]
if ok {