From ec7ef9ca5b03f1d705e0c4bd4b7c016493d61933 Mon Sep 17 00:00:00 2001 From: Dat Luong Date: Tue, 9 Apr 2024 14:01:58 +0700 Subject: [PATCH 1/4] chore: add comment --- pkg/mev/pkg.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/pkg/mev/pkg.go b/pkg/mev/pkg.go index 0b8cb19..ab33010 100644 --- a/pkg/mev/pkg.go +++ b/pkg/mev/pkg.go @@ -72,6 +72,10 @@ type IBundleSender interface { } type IGasBundleEstimator interface { + // EstimateBundleGas is used to estimate the gas for a bundle of transactions + // Note that this method is expected only works with custom ethereum node which + // supports estimate bundles gas via CallMsgs, + // and using eth_estimateGasBundle method. EstimateBundleGas( ctx context.Context, messages []ethereum.CallMsg, From bc8fe58c7edd931ed67cb38bb71ae017a9957422 Mon Sep 17 00:00:00 2001 From: Dat Luong Date: Tue, 2 Apr 2024 16:28:03 +0700 Subject: [PATCH 2/4] feat: add get all logs for a pending tx --- pkg/types/pendingtx.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/types/pendingtx.go b/pkg/types/pendingtx.go index 91c1e39..194b693 100644 --- a/pkg/types/pendingtx.go +++ b/pkg/types/pendingtx.go @@ -78,3 +78,16 @@ type MinedBlock struct { BlockTime int64 `json:"block_time"` Transactions []Transaction `json:"transactions"` } + +func (m Message) GetAllLogs() []*types.Log { + logs := m.InternalTx.getLogs() + return logs +} + +func (c CallFrame) getLogs() []*types.Log { + results := c.Logs + for index := range c.Calls { + results = append(results, c.Calls[index].getLogs()...) + } + return results +} From 03bb7c1e9ef014f777831e36fa3408277aadf901 Mon Sep 17 00:00:00 2001 From: Dat Luong Date: Thu, 4 Apr 2024 11:27:50 +0700 Subject: [PATCH 3/4] feat: add getRelatedPool --- pkg/types/pendingtx.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pkg/types/pendingtx.go b/pkg/types/pendingtx.go index 194b693..c4d7ba9 100644 --- a/pkg/types/pendingtx.go +++ b/pkg/types/pendingtx.go @@ -2,6 +2,7 @@ package types import ( "math/big" + "strings" "github.com/KyberNetwork/tradinglib/pkg/mev" "github.com/ethereum/go-ethereum/common" @@ -91,3 +92,15 @@ func (c CallFrame) getLogs() []*types.Log { } return results } + +// GetRelatedPools returns all pools related to the log +// A pool might appear from log.Address, or log.Topics. +func GetRelatedPools(log *types.Log) []string { + pools := make([]string, 0, len(log.Topics)+1) + for _, topic := range log.Topics { + pools = append(pools, strings.ToLower(topic.Hex())) + } + pools = append(pools, strings.ToLower(log.Address.Hex())) + + return pools +} From 2dd7d48e48e598969641f64cd0e57f77eea455fc Mon Sep 17 00:00:00 2001 From: Dat Luong Date: Wed, 10 Apr 2024 16:16:12 +0700 Subject: [PATCH 4/4] chore: update comment usage --- pkg/types/pendingtx.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkg/types/pendingtx.go b/pkg/types/pendingtx.go index c4d7ba9..be139c2 100644 --- a/pkg/types/pendingtx.go +++ b/pkg/types/pendingtx.go @@ -95,6 +95,8 @@ func (c CallFrame) getLogs() []*types.Log { // GetRelatedPools returns all pools related to the log // A pool might appear from log.Address, or log.Topics. +// Currently, support univ2, balancer poolType. +// Others should be dig and update this function if needed. func GetRelatedPools(log *types.Log) []string { pools := make([]string, 0, len(log.Topics)+1) for _, topic := range log.Topics {