diff --git a/parser.go b/parser.go index 486fcdc..75d6bfc 100644 --- a/parser.go +++ b/parser.go @@ -40,6 +40,7 @@ func (tx *Tx) Parser() error { tx.Block = tx.rawTx.Slot tx.BlockIndex = uint64(tx.rawTx.IndexWithinBlock) 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.AfterSOLBalance = decimal.NewFromUint64(tx.rawTx.Meta.PostBalances[0]).Div(decimal.NewFromInt(1e9)) diff --git a/system.go b/system.go index 2f36525..fbf3a17 100644 --- a/system.go +++ b/system.go @@ -31,9 +31,16 @@ func TransferParser(result *RawTx, instruction Instruction, offset [2]uint, tx * } 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]] + 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 platform, ok := platformFeeAddresses[to] if ok { diff --git a/tx.go b/tx.go index 47a18ba..3901c86 100644 --- a/tx.go +++ b/tx.go @@ -45,15 +45,24 @@ type mevInfo struct { MevAgentFee decimal.Decimal } +type SolTransfer struct { + From solana.PublicKey + To solana.PublicKey + Amount decimal.Decimal +} + type Tx struct { - rawTx *RawTx - Signer solana.PublicKey - Err interface{} `json:"err,omitempty"` - Swaps []Swap `json:"swaps,omitempty"` - Block uint64 `json:"block"` - BlockIndex uint64 `json:"index"` - TxHash *[64]byte `json:"-"` - BlockAt int64 `json:"block_at"` + rawTx *RawTx + Signer solana.PublicKey + Err interface{} `json:"err,omitempty"` + Swaps []Swap `json:"swaps,omitempty"` + SolTransfer []SolTransfer `json:"sol_transfer,omitempty"` + Block uint64 `json:"block"` + BlockIndex uint64 `json:"index"` + TxHash *[64]byte `json:"-"` + BlockAt int64 `json:"block_at"` + + CuFee decimal.Decimal `json:"cu_fee"` cachedTxHash string