add shreder sell decode
This commit is contained in:
45
pkg/shreder/tx.go
Normal file
45
pkg/shreder/tx.go
Normal file
@@ -0,0 +1,45 @@
|
||||
package shreder
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/shopspring/decimal"
|
||||
)
|
||||
|
||||
const (
|
||||
TokenDecimals = 6
|
||||
SolDecimals = 9
|
||||
)
|
||||
|
||||
type TxSignal struct {
|
||||
Source string `json:"source"`
|
||||
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"`
|
||||
TxFee decimal.Decimal `json:"tx_fee"`
|
||||
|
||||
ExactSOL bool `json:"exact_in"`
|
||||
|
||||
// parsed values
|
||||
Token0AmountUint64 uint64 `json:"-"`
|
||||
Token1AmountUint64 uint64 `json:"-"`
|
||||
}
|
||||
|
||||
func (t *TxSignal) Parse() *TxSignal {
|
||||
t.Token0AmountUint64 = t.Token0Amount.Mul(decimal.New(1, TokenDecimals)).BigInt().Uint64()
|
||||
t.Token1AmountUint64 = t.Token1Amount.Mul(decimal.New(1, SolDecimals)).BigInt().Uint64()
|
||||
return t
|
||||
}
|
||||
|
||||
type TxSignalBatch = []*TxSignal
|
||||
Reference in New Issue
Block a user