diff --git a/budget.go b/budget.go index 347a623..f2715ce 100644 --- a/budget.go +++ b/budget.go @@ -27,10 +27,11 @@ func budgetParser(tx *Tx, instr Instruction, _ InnerInstructions, offset [2]uint } } -func computeUnitLimitParser(offset [2]uint, _ *Tx, decodedData []byte) ([2]uint, error) { - if len(decodedData) < 8 { +func computeUnitLimitParser(offset [2]uint, tx *Tx, decodedData []byte) ([2]uint, error) { + if len(decodedData) < 4 { return increaseOffset(offset), nil } + tx.CuLimit = binary.BigEndian.Uint32(decodedData[:4]) return increaseOffset(offset), nil } diff --git a/parser.go b/parser.go index bc7fbc5..9bc2d35 100644 --- a/parser.go +++ b/parser.go @@ -91,6 +91,7 @@ func (tx *Tx) Parser() error { tx.BlockAt = tx.rawTx.BlockTime tx.CuFee = decimal.NewFromUint64(tx.rawTx.Meta.Fee) + tx.ComputeUnitsConsumed = tx.rawTx.Meta.ComputeUnitsConsumed 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/rawtx.go b/rawtx.go index 9bd0bcf..d4f1a55 100644 --- a/rawtx.go +++ b/rawtx.go @@ -146,16 +146,17 @@ func (tb *TokenBalance) ParseAccount() { } type Meta struct { - Err interface{} `json:"err"` - Fee uint64 `json:"fee"` - InnerInstructions []InnerInstructions `json:"innerInstructions"` - LoadedAddresses LoadedAddresses `json:"loadedAddresses"` - LogMessages []string `json:"logMessages"` - PostBalances []uint64 `json:"postBalances"` - PostTokenBalances []TokenBalance `json:"postTokenBalances"` - PreBalances []uint64 `json:"preBalances"` - PreTokenBalances []TokenBalance `json:"preTokenBalances"` - Rewards []interface{} `json:"rewards"` + Err interface{} `json:"err"` + Fee uint64 `json:"fee"` + InnerInstructions []InnerInstructions `json:"innerInstructions"` + LoadedAddresses LoadedAddresses `json:"loadedAddresses"` + LogMessages []string `json:"logMessages"` + PostBalances []uint64 `json:"postBalances"` + PostTokenBalances []TokenBalance `json:"postTokenBalances"` + PreBalances []uint64 `json:"preBalances"` + PreTokenBalances []TokenBalance `json:"preTokenBalances"` + Rewards []interface{} `json:"rewards"` + ComputeUnitsConsumed uint64 `json:"computeUnitsConsumed"` } type Header struct { NumReadonlySignedAccounts int `json:"numReadonlySignedAccounts"` @@ -805,7 +806,7 @@ func ConvertYellowstoneGrpcTransactionToSolanaTransaction(y *pb.SubscribeUpdateT } sTx.Meta.Fee = meta.Fee //sTx.Meta.InnerInstructions = meta.InnerInstructions - + sTx.Meta.ComputeUnitsConsumed = *meta.ComputeUnitsConsumed for _, innerInstr := range meta.InnerInstructions { var instrs []Instruction for _, instr := range innerInstr.Instructions { diff --git a/tx.go b/tx.go index fa93a6f..f07c8cb 100644 --- a/tx.go +++ b/tx.go @@ -47,6 +47,8 @@ type Swap struct { StartBinId int32 EndBinId int32 BinChanges []DlmmBinLiquidityChange + + ConsumeUnit uint64 } type DlmmBinLiquidityChange struct { @@ -98,6 +100,9 @@ type Tx struct { // update tokenInfo Token map[solana.PublicKey]TokenMeta `gorm:"-"` + ComputeUnitsConsumed uint64 `json:"compute_units_consumed"` + CuLimit uint32 `json:"cu_limit"` + // todo pool info ?? }