73 lines
2.2 KiB
Go
73 lines
2.2 KiB
Go
package shreder
|
|
|
|
import (
|
|
"log/slog"
|
|
"os"
|
|
"time"
|
|
|
|
"github.com/shopspring/decimal"
|
|
)
|
|
|
|
const (
|
|
TokenDecimals = 6
|
|
SolDecimals = 9
|
|
)
|
|
|
|
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)
|
|
}
|
|
|
|
type TxSignal struct {
|
|
Source string `json:"source"`
|
|
Label string `json:"label"`
|
|
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"`
|
|
IsCashbackEnabled bool `json:"is_cashback_enabled"`
|
|
CUPrice decimal.Decimal `json:"cu_price"`
|
|
CULimit uint32 `json:"cu_limit"`
|
|
SWQoSAgent string `json:"swqos_agent"`
|
|
SWQoSTips decimal.Decimal `json:"swqos_tips"`
|
|
TableCnt int `json:"table_cnt"`
|
|
|
|
ExactSOL bool `json:"exact_in"`
|
|
|
|
//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"`
|
|
//
|
|
LbPairAddress string `json:"lb_pair_address"`
|
|
|
|
// parsed values
|
|
Token0AmountUint64 uint64 `json:"-"`
|
|
Token1AmountUint64 uint64 `json:"-"`
|
|
|
|
ParseStart time.Time `json:"parse_start"`
|
|
ParseEnd time.Time `json:"parse_end"`
|
|
}
|
|
|
|
type TxSignalBatch = []*TxSignal
|