Skip to content

Commit

Permalink
Merge pull request #36 from KyberNetwork/feat/add-comment
Browse files Browse the repository at this point in the history
chore: add comment and getAllLogs
  • Loading branch information
datluongductuan authored Apr 10, 2024
2 parents 89021a3 + 2dd7d48 commit 98bccde
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/mev/pkg.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
28 changes: 28 additions & 0 deletions pkg/types/pendingtx.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package types

import (
"math/big"
"strings"

"github.com/KyberNetwork/tradinglib/pkg/mev"
"github.com/ethereum/go-ethereum/common"
Expand Down Expand Up @@ -78,3 +79,30 @@ 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
}

// 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 {
pools = append(pools, strings.ToLower(topic.Hex()))
}
pools = append(pools, strings.ToLower(log.Address.Hex()))

return pools
}

0 comments on commit 98bccde

Please sign in to comment.