Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e68907e9c7 |
208
checking.go
208
checking.go
@@ -173,8 +173,6 @@ func checkBonkGmgnBuy(rawTx *RawTx) bool {
|
||||
|
||||
var (
|
||||
axiomTxLoopupTable = solana.MustPublicKeyFromBase58("7RKtfATWCe98ChuwecNq8XCzAzfoK3DtZTprFsPMGtio")
|
||||
axiomProgramID = solana.MustPublicKeyFromBase58("AxiomfHaWDemCFBLBayqnEnNwE6b7B2Qz3UmzMpgbMG6")
|
||||
gmgnProgramID = solana.MustPublicKeyFromBase58("GMgnVFR8Jb39LoXsEVzb3DvBy3ywCmdmJquHUy1Lrkqb")
|
||||
)
|
||||
|
||||
func checkBonkAxiomBuy(rawTx *RawTx) bool {
|
||||
@@ -368,209 +366,3 @@ func checkBonkAxiomBuy(rawTx *RawTx) bool {
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func checkPumpFunAxiomBuy(rawTx *RawTx) bool {
|
||||
|
||||
// 检查交易版本
|
||||
if rawTx.Version == "legacy" || len(rawTx.Transaction.Message.AddressTableLookups) != 1 {
|
||||
return false
|
||||
}
|
||||
|
||||
// 检查 addressLookupTable 是否是 Axiom 的
|
||||
if rawTx.Transaction.Message.AddressTableLookups[0].AccountKey != axiomTxLoopupTable {
|
||||
return false
|
||||
}
|
||||
|
||||
// 检查交易指令数量
|
||||
if len(rawTx.Transaction.Message.Instructions) != 6 {
|
||||
return false
|
||||
}
|
||||
|
||||
accountList := rawTx.getAccountList()
|
||||
// 检查 cu limit
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[0]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.ComputeBudget {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Accounts) != 1 {
|
||||
return false
|
||||
}
|
||||
|
||||
accountId := accountList[instruction.Accounts[0]].String()
|
||||
if !strings.HasPrefix(accountId, "jitodontfront") || !strings.HasSuffix(accountId, "TradeWithAxiomDotTrade") {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 cu price
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[1]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.ComputeBudget {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 ata.createIdempotent
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[2]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.SPLAssociatedTokenAccountProgramID {
|
||||
return false
|
||||
}
|
||||
|
||||
if instruction.Data.String() != "2" {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Accounts) < 4 {
|
||||
return false
|
||||
}
|
||||
|
||||
// axiom 会先创建 token 账户, 而不是 wsol 账户
|
||||
accountId := accountList[instruction.Accounts[3]]
|
||||
if accountId == solana.WrappedSol {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查调用axiom合约
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[3]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != axiomProgramID {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 transfer
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[4]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.SystemProgramID {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Data) == 0 || instruction.Data[0] != 2 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 transfer
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[5]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.SystemProgramID {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Data) == 0 || instruction.Data[0] != 2 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
func checkPumpFunGmgnBuy(rawTx *RawTx) bool {
|
||||
|
||||
// 检查交易版本
|
||||
if rawTx.Version != "legacy" {
|
||||
return false
|
||||
}
|
||||
|
||||
// 检查交易指令数量
|
||||
if len(rawTx.Transaction.Message.Instructions) != 6 {
|
||||
return false
|
||||
}
|
||||
|
||||
accountList := rawTx.getAccountList()
|
||||
// 检查 cu limit
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[0]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.ComputeBudget {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Accounts) != 1 {
|
||||
return false
|
||||
}
|
||||
|
||||
accountId := accountList[instruction.Accounts[0]].String()
|
||||
if !strings.HasPrefix(accountId, "jitodontfront1111111111151111111111111655") {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 cu price
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[1]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.ComputeBudget {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 ata.createIdempotent
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[2]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.SPLAssociatedTokenAccountProgramID {
|
||||
return false
|
||||
}
|
||||
|
||||
if instruction.Data.String() != "2" {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Accounts) < 4 {
|
||||
return false
|
||||
}
|
||||
|
||||
accountId := accountList[instruction.Accounts[3]]
|
||||
if accountId == solana.WrappedSol {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查调用 gmgn 合约
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[3]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != gmgnProgramID {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 transfer
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[4]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.SystemProgramID {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Data) == 0 || instruction.Data[0] != 2 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
// 检查 transfer
|
||||
{
|
||||
instruction := rawTx.Transaction.Message.Instructions[5]
|
||||
programId := accountList[instruction.ProgramIDIndex]
|
||||
if programId != solana.SystemProgramID {
|
||||
return false
|
||||
}
|
||||
|
||||
if len(instruction.Data) == 0 || instruction.Data[0] != 2 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -48,14 +48,6 @@ var platformFeeAddresses = map[solana.PublicKey]string{
|
||||
solana.MustPublicKeyFromBase58("MaestroUL88UBnZr3wfoN7hqmNWFi3ZYCGqZoJJHE36"): PlatformMaestro,
|
||||
solana.MustPublicKeyFromBase58("ZG98FUCjb8mJ824Gbs6RsgVmr1FhXb2oNiJHa2dwmPd"): PlatformBonkBot,
|
||||
solana.MustPublicKeyFromBase58("J5XGHmzrRmnYWbmw45DbYkdZAU2bwERFZ11qCDXPvFB5"): PlatformPadre,
|
||||
solana.MustPublicKeyFromBase58("5vPNE6VFyXmCmzmWotdxmRk57LEWiXxuAfZL3hKbi2LH"): PlatformAxiom,
|
||||
solana.MustPublicKeyFromBase58("ECDrSz47nXihe5kyK4oWEePPsPi9qz6u5d6Fa2sDj3uM"): PlatformAxiom,
|
||||
solana.MustPublicKeyFromBase58("EqGzowSp6cKAsMSRyyrFTaBxnZEVeNY81LC18YFy8Cx9"): PlatformAxiom,
|
||||
solana.MustPublicKeyFromBase58("3Tu1Y9aNveLFN4WTAwnAwXL6tbUp5MMe3RxyybG4jTAS"): PlatformAxiom,
|
||||
solana.MustPublicKeyFromBase58("3PvqoztjnRxaAiFmLuEfqZkU4GSbjUareks8S2xCZaTa"): PlatformAxiom,
|
||||
solana.MustPublicKeyFromBase58("HkJYryz2BNeMQfuuSWDYktWt5fZLV26eK6nqu7EJycoG"): PlatformAxiom,
|
||||
solana.MustPublicKeyFromBase58("BfFX9rUm8qTZiZjmeq9BktWVTNuG3YWMc5AvkrCKJike"): PlatformAxiom,
|
||||
solana.MustPublicKeyFromBase58("2ApLdwLrGayEmxgpLX9BTR47Q2QprfMg5SpjrLeaK8s7"): PlatformAxiom,
|
||||
}
|
||||
|
||||
var mevAgentFeeAddresses = map[solana.PublicKey]string{
|
||||
|
||||
29
meta.go
29
meta.go
@@ -35,11 +35,8 @@ var pumpMigrateEventDiscriminator = calculateDiscriminator("event:CompletePumpAm
|
||||
var pumpBuyEventDiscriminator = [8]byte{189, 219, 127, 211, 78, 230, 97, 238}
|
||||
|
||||
var (
|
||||
pumpAmmProgram = solana.MustPublicKeyFromBase58("pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA")
|
||||
wSolMint = solana.MustPublicKeyFromBase58("So11111111111111111111111111111111111111112")
|
||||
usdcMint = solana.MustPublicKeyFromBase58("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v")
|
||||
usd1Mint = solana.MustPublicKeyFromBase58("USD1ttGY1N17NEEHLmELoaybftRBUSErhqYiQzvEmuB")
|
||||
meteoraDlmmProgram = solana.MustPublicKeyFromBase58("LBUZKhRxPF3XUpBCjp4YzTKgLccjZhTSDM9YuVaPwxo")
|
||||
pumpAmmProgram = solana.MustPublicKeyFromBase58("pAMMBay6oceH9fJKBRHGP5D4bD4sWpmSwMn52FMfXEA")
|
||||
wSolMint = solana.MustPublicKeyFromBase58("So11111111111111111111111111111111111111112")
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -66,26 +63,6 @@ var (
|
||||
pumpAmmDepositEventDiscriminator = calculateDiscriminator("event:DepositEvent")
|
||||
)
|
||||
|
||||
var (
|
||||
meteoraDlmmSwapDiscriminator = calculateDiscriminator("global:swap")
|
||||
meteoraDlmmSwap2Discriminator = calculateDiscriminator("global:swap2")
|
||||
meteoraDlmmSwapExactOutDiscriminator = calculateDiscriminator("global:swap_exact_out")
|
||||
meteoraDlmmSwapExactOut2Discriminator = calculateDiscriminator("global:swap_exact_out2")
|
||||
meteoraDlmmSwapWithPriceImpactDiscriminator = calculateDiscriminator("global:swap_with_price_impact")
|
||||
meteoraDlmmSwapWithPriceImpact2Discriminator = calculateDiscriminator("global:swap_with_price_impact2")
|
||||
meteoraDlmmSwapEventDiscriminator = calculateDiscriminator("event:Swap")
|
||||
meteoraDlmmAddLiquidityDiscriminator = calculateDiscriminator("global:add_liquidity")
|
||||
meteoraDlmmAddLiquidity2Discriminator = calculateDiscriminator("global:add_liquidity2")
|
||||
meteoraDlmmAddLiquidityByStrategyDiscriminator = calculateDiscriminator("global:add_liquidity_by_strategy")
|
||||
meteoraDlmmAddLiquidityByStrategy2Discriminator = calculateDiscriminator("global:add_liquidity_by_strategy2")
|
||||
meteoraDlmmRemoveLiquidityDiscriminator = calculateDiscriminator("global:remove_liquidity")
|
||||
meteoraDlmmRemoveLiquidity2Discriminator = calculateDiscriminator("global:remove_liquidity2")
|
||||
meteoraDlmmRemoveLiquidityByRangeDiscriminator = calculateDiscriminator("global:remove_liquidity_by_range")
|
||||
meteoraDlmmRemoveLiquidityByRange2Discriminator = calculateDiscriminator("global:remove_liquidity_by_range2")
|
||||
meteoraDlmmAddLiquidityEventDiscriminator = calculateDiscriminator("event:AddLiquidity")
|
||||
meteoraDlmmRemoveLiquidityEventDiscriminator = calculateDiscriminator("event:RemoveLiquidity")
|
||||
)
|
||||
|
||||
// Program PumpAmm program ID
|
||||
|
||||
var budgGetProgram = solana.MustPublicKeyFromBase58("ComputeBudget111111111111111111111111111111")
|
||||
@@ -98,5 +75,3 @@ var createAccountWithSeedDiscriminator = uint32(3)
|
||||
var systemProgram = solana.MustPublicKeyFromBase58("11111111111111111111111111111111")
|
||||
|
||||
var raydiumLaunchLabProgramID = solana.MustPublicKeyFromBase58("LanMV9sAd7wArD4vJFi2qDdfnVhFxYSUg6eADduJ3uj")
|
||||
|
||||
var eventDiscriminator = [8]byte{228, 69, 165, 46, 81, 203, 154, 29}
|
||||
|
||||
1188
metaoradlmm.go
1188
metaoradlmm.go
File diff suppressed because it is too large
Load Diff
44
parser.go
44
parser.go
@@ -8,38 +8,11 @@ import (
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
var defaultSwapPrograms = map[solana.PublicKey]swapParser{
|
||||
var swapPrograms = map[solana.PublicKey]swapParser{
|
||||
pumpAmmProgram: pumpAmmParser,
|
||||
pumpProgram: pumpParser,
|
||||
}
|
||||
|
||||
var swapPrograms = cloneSwapPrograms(defaultSwapPrograms)
|
||||
|
||||
type ParserOption func(*parserConfig)
|
||||
|
||||
type parserConfig struct {
|
||||
enableMeteoraDlmm bool
|
||||
}
|
||||
|
||||
func InitParser(opts ...ParserOption) {
|
||||
cfg := parserConfig{}
|
||||
for _, opt := range opts {
|
||||
opt(&cfg)
|
||||
}
|
||||
|
||||
programs := cloneSwapPrograms(defaultSwapPrograms)
|
||||
if cfg.enableMeteoraDlmm {
|
||||
programs[meteoraDlmmProgram] = metaoradlmmParser
|
||||
}
|
||||
swapPrograms = programs
|
||||
}
|
||||
|
||||
func WithMeteoraDlmm() ParserOption {
|
||||
return func(cfg *parserConfig) {
|
||||
cfg.enableMeteoraDlmm = true
|
||||
}
|
||||
}
|
||||
|
||||
var actionPrograms = map[solana.PublicKey]actionParser{
|
||||
systemProgram: systemParser,
|
||||
budgGetProgram: budgetParser,
|
||||
@@ -61,13 +34,6 @@ func (tx *Tx) Parser() error {
|
||||
return errors.New("rawTx is nil")
|
||||
}
|
||||
accountList := tx.rawTx.getAccountList()
|
||||
if tx.rawTx.Meta.Err == nil {
|
||||
for _, acc := range tx.rawTx.Transaction.Message.Instructions {
|
||||
if accountList[acc.ProgramIDIndex] == solana.VoteProgramID {
|
||||
tx.Vote = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tx.TxHash = (*[64]byte)((tx.rawTx.Transaction.Signatures[0][:]))
|
||||
tx.Signer = tx.rawTx.GetSigner()
|
||||
@@ -151,11 +117,3 @@ func (tx *Tx) Parser() error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func cloneSwapPrograms(src map[solana.PublicKey]swapParser) map[solana.PublicKey]swapParser {
|
||||
dst := make(map[solana.PublicKey]swapParser, len(src))
|
||||
for k, v := range src {
|
||||
dst[k] = v
|
||||
}
|
||||
return dst
|
||||
}
|
||||
|
||||
75
tx.go
75
tx.go
@@ -33,18 +33,6 @@ type Swap struct {
|
||||
UserBaseBalance decimal.Decimal
|
||||
UserQuoteBalance decimal.Decimal
|
||||
EntryContract solana.PublicKey
|
||||
|
||||
//For meteora dlmm
|
||||
StartBinId int32
|
||||
EndBinId int32
|
||||
BinChanges []DlmmBinLiquidityChange
|
||||
}
|
||||
|
||||
type DlmmBinLiquidityChange struct {
|
||||
BinId int32
|
||||
AmountX decimal.Decimal
|
||||
AmountY decimal.Decimal
|
||||
BpsToRemove uint16
|
||||
}
|
||||
|
||||
type platformInfo struct {
|
||||
@@ -65,7 +53,6 @@ type SolTransfer struct {
|
||||
|
||||
type Tx struct {
|
||||
rawTx *RawTx
|
||||
Vote bool
|
||||
Signer solana.PublicKey
|
||||
Err interface{} `json:"err,omitempty"`
|
||||
Swaps []Swap `json:"swaps,omitempty"`
|
||||
@@ -92,10 +79,6 @@ type Tx struct {
|
||||
// todo pool info ??
|
||||
}
|
||||
|
||||
func (tx *Tx) GetRawTx() *RawTx {
|
||||
return tx.rawTx
|
||||
}
|
||||
|
||||
func (tx *Tx) SetRawTx(t *RawTx) {
|
||||
tx.rawTx = t
|
||||
}
|
||||
@@ -141,33 +124,16 @@ func (tx *Tx) CheckPlatform(swap Swap) (string, decimal.Decimal) {
|
||||
platformFee = info.PlatformFee
|
||||
break
|
||||
}
|
||||
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
|
||||
}
|
||||
if swap.Event == "buy" && swap.Program == SolProgramRaydiumLaunchLabBonk {
|
||||
for _, p := range tx.Platform {
|
||||
switch p.Platform {
|
||||
case PlatformAxiom:
|
||||
if !checkBonkAxiomBuy(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
|
||||
}
|
||||
case PlatformGMGN:
|
||||
if !checkBonkGmgnBuy(rawTx) {
|
||||
platform = PlatformFake
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -218,29 +184,6 @@ 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 {
|
||||
|
||||
Reference in New Issue
Block a user