add instr sol transfer and cufee

This commit is contained in:
thloyi
2026-01-05 11:46:54 +08:00
parent 91b70e23d6
commit dd76b04b19
3 changed files with 26 additions and 9 deletions

View File

@@ -40,6 +40,7 @@ func (tx *Tx) Parser() error {
tx.Block = tx.rawTx.Slot tx.Block = tx.rawTx.Slot
tx.BlockIndex = uint64(tx.rawTx.IndexWithinBlock) tx.BlockIndex = uint64(tx.rawTx.IndexWithinBlock)
tx.BlockAt = tx.rawTx.BlockTime tx.BlockAt = tx.rawTx.BlockTime
tx.CuFee = decimal.NewFromUint64(tx.rawTx.Meta.Fee)
tx.BeforeSolBalance = decimal.NewFromUint64(tx.rawTx.Meta.PreBalances[0]).Div(decimal.NewFromInt(1e9)) tx.BeforeSolBalance = decimal.NewFromUint64(tx.rawTx.Meta.PreBalances[0]).Div(decimal.NewFromInt(1e9))
tx.AfterSOLBalance = decimal.NewFromUint64(tx.rawTx.Meta.PostBalances[0]).Div(decimal.NewFromInt(1e9)) tx.AfterSOLBalance = decimal.NewFromUint64(tx.rawTx.Meta.PostBalances[0]).Div(decimal.NewFromInt(1e9))

View File

@@ -31,9 +31,16 @@ func TransferParser(result *RawTx, instruction Instruction, offset [2]uint, tx *
} }
var lamports uint64 = binary.LittleEndian.Uint64(decodeData) var lamports uint64 = binary.LittleEndian.Uint64(decodeData)
//from := result.accountList[result.Transaction.Message.Instructions[offset[0]].Accounts[0]] from := result.accountList[result.Transaction.Message.Instructions[offset[0]].Accounts[0]]
to := result.accountList[instruction.Accounts[1]] to := result.accountList[instruction.Accounts[1]]
if offset[1] == 0 {
tx.Transfer = append(tx.Transfer, SolTransfer{
From: from,
To: to,
Amount: decimal.NewFromInt(int64(lamports)), // solana decimals
})
}
// load platform by to address // load platform by to address
platform, ok := platformFeeAddresses[to] platform, ok := platformFeeAddresses[to]
if ok { if ok {

9
tx.go
View File

@@ -45,16 +45,25 @@ type mevInfo struct {
MevAgentFee decimal.Decimal MevAgentFee decimal.Decimal
} }
type SolTransfer struct {
From solana.PublicKey
To solana.PublicKey
Amount decimal.Decimal
}
type Tx struct { type Tx struct {
rawTx *RawTx rawTx *RawTx
Signer solana.PublicKey Signer solana.PublicKey
Err interface{} `json:"err,omitempty"` Err interface{} `json:"err,omitempty"`
Swaps []Swap `json:"swaps,omitempty"` Swaps []Swap `json:"swaps,omitempty"`
SolTransfer []SolTransfer `json:"sol_transfer,omitempty"`
Block uint64 `json:"block"` Block uint64 `json:"block"`
BlockIndex uint64 `json:"index"` BlockIndex uint64 `json:"index"`
TxHash *[64]byte `json:"-"` TxHash *[64]byte `json:"-"`
BlockAt int64 `json:"block_at"` BlockAt int64 `json:"block_at"`
CuFee decimal.Decimal `json:"cu_fee"`
cachedTxHash string cachedTxHash string
Platform map[string]platformInfo `json:"platform"` Platform map[string]platformInfo `json:"platform"`