Files
libsam/pkg/shreder/tx.go

67 lines
1.8 KiB
Go
Raw Normal View History

2025-12-30 11:03:11 +08:00
package shreder
2025-12-26 10:57:37 +08:00
import (
2026-01-05 12:45:32 +08:00
"log/slog"
"os"
2025-12-26 10:57:37 +08:00
"time"
"github.com/shopspring/decimal"
)
2025-12-30 11:03:11 +08:00
const (
TokenDecimals = 6
SolDecimals = 9
)
2026-01-05 12:45:32 +08:00
var (
logger *slog.Logger
)
func init() {
handler := slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: slog.LevelInfo})
logger = slog.New(handler)
}
func SetLogLevel(level slog.Level) {
handler := slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: level})
logger = slog.New(handler)
}
2025-12-26 10:57:37 +08:00
type TxSignal struct {
2025-12-26 11:34:45 +08:00
Source string `json:"source"`
2026-01-06 16:42:07 +08:00
Label string `json:"label"`
2025-12-26 11:34:45 +08:00
TxHash string `json:"tx_hash"`
Maker string `json:"maker"`
Token0Address string `json:"token0_address"`
Token1Address string `json:"token1_address"`
Token0Amount decimal.Decimal `json:"token0_amount"`
Token1Amount decimal.Decimal `json:"token1_amount"`
Block uint64 `json:"block"`
BlockAt time.Time `json:"block_at"`
BlockIndex uint64 `json:"block_index"`
Event string `json:"event"`
Program string `json:"program"`
IsProcessed bool `json:"is_processed"`
IsToken2022 bool `json:"is_token2022"`
IsMayhemMode bool `json:"is_mayhem_mode"`
2026-02-03 17:36:59 +08:00
CUPrice decimal.Decimal `json:"cu_price"`
2025-12-26 10:57:37 +08:00
2025-12-30 11:03:11 +08:00
ExactSOL bool `json:"exact_in"`
2026-01-22 14:32:45 +08:00
//Just for metaora DLMM
// ActiveBin is the active bin id provided by swap_with_price_impact(2).
ActiveBin int32 `json:"active_bin"`
// MaxPriceImpactBps is the price impact guard for swap_with_price_impact(2).
MaxPriceImpactBps uint16 `json:"max_price_impact_bps"`
2025-12-26 11:34:45 +08:00
// parsed values
2026-02-03 17:36:59 +08:00
CUPriceUint64 uint64 `json:"-"`
2025-12-26 11:34:45 +08:00
Token0AmountUint64 uint64 `json:"-"`
Token1AmountUint64 uint64 `json:"-"`
2026-01-07 21:15:54 +08:00
ParseStart time.Time `json:"parse_start"`
ParseEnd time.Time `json:"parse_end"`
2025-12-26 10:57:37 +08:00
}
2025-12-26 11:13:31 +08:00
type TxSignalBatch = []*TxSignal