diff --git a/adapters/logs.go b/adapters/logs.go index ebcee76..987b196 100644 --- a/adapters/logs.go +++ b/adapters/logs.go @@ -17,7 +17,7 @@ type TransferLogsIndexer interface { } type LPLogsIndexer interface { - Address() common.Address + Address() []common.Address IndexLogs(ctx context.Context, chainID *big.Int, client *ethclient.Client, logs []types.Log) ([]LPTransfer, error) ProcessLog(ctx context.Context, chainID *big.Int, client *ethclient.Client, vLog types.Log) (*LPTransfer, error) } diff --git a/adapters/projects/izumi/transfer_event.go b/adapters/projects/izumi/transfer_event.go index 754ddc2..c81b280 100644 --- a/adapters/projects/izumi/transfer_event.go +++ b/adapters/projects/izumi/transfer_event.go @@ -23,20 +23,20 @@ var ( // TransferIndexer is an implementation of LogsIndexer for ERC20 transfer logs. type TransferIndexer struct { - token common.Address + tokens []common.Address whitelist map[string]struct{} } // NewTransferIndexer creates a new TransferIndexer. -func NewTransferIndexer(token common.Address, whitelist map[string]struct{}) *TransferIndexer { +func NewTransferIndexer(tokens []common.Address, whitelist map[string]struct{}) *TransferIndexer { return &TransferIndexer{ - token: token, + tokens: tokens, whitelist: whitelist, } } -func (indexer *TransferIndexer) Address() common.Address { - return indexer.token +func (indexer *TransferIndexer) Address() []common.Address { + return indexer.tokens } // IndexLogs processes logs for ERC20 transfers. @@ -78,7 +78,7 @@ func (indexer *TransferIndexer) ProcessLog(ctx context.Context, chainID *big.Int } // Initialize the LiquidityManager contract caller - liquidityManager, err := izumi.NewIzumiCaller(indexer.token, client) + liquidityManager, err := izumi.NewIzumiCaller(vLog.Address, client) if err != nil { return nil, err } diff --git a/adapters/projects/ritsu/transfer_event.go b/adapters/projects/ritsu/transfer_event.go index 93ea093..2bda05f 100644 --- a/adapters/projects/ritsu/transfer_event.go +++ b/adapters/projects/ritsu/transfer_event.go @@ -18,24 +18,25 @@ import ( var ( logTransferSigHash = crypto.Keccak256Hash([]byte("Transfer(address,address,uint256)")) + logStakeSigHash = crypto.Keccak256Hash([]byte("Stake(address,uint256,address)")) ) // TransferIndexer is an implementation of LogsIndexer for ERC20 transfer logs. type TransferIndexer struct { - token common.Address + tokens []common.Address whitelist map[string]struct{} } // NewTransferIndexer creates a new TransferIndexer. -func NewTransferIndexer(token common.Address, whitelist map[string]struct{}) *TransferIndexer { +func NewTransferIndexer(tokens []common.Address, whitelist map[string]struct{}) *TransferIndexer { return &TransferIndexer{ - token: token, + tokens: tokens, whitelist: whitelist, } } -func (indexer *TransferIndexer) Address() common.Address { - return indexer.token +func (indexer *TransferIndexer) Address() []common.Address { + return indexer.tokens } // IndexLogs processes logs for ERC20 transfers. @@ -67,7 +68,16 @@ func (indexer *TransferIndexer) ProcessLog(ctx context.Context, chainID *big.Int if !exists { return nil, nil } - from := common.BytesToAddress(vLog.Topics[1].Bytes()[12:]) + txReceipt, err := client.TransactionReceipt(ctx, vLog.TxHash) + if err != nil { + return nil, err + } + from := adapters.ZeroAddress + for _, log := range txReceipt.Logs { + if log.Topics[0].Hex() == logStakeSigHash.Hex() { + from = common.BytesToAddress(log.Topics[2].Bytes()[12:]) + } + } // Unpack the transfer event var transferEvent struct { @@ -84,7 +94,7 @@ func (indexer *TransferIndexer) ProcessLog(ctx context.Context, chainID *big.Int } // Initialize the LP token caller - token, err := ritsu.NewRitsuCaller(indexer.token, client) + token, err := ritsu.NewRitsuCaller(vLog.Address, client) if err != nil { return nil, err } diff --git a/cmd/lp.go b/cmd/lp.go index dd81b98..effca23 100644 --- a/cmd/lp.go +++ b/cmd/lp.go @@ -9,16 +9,24 @@ import ( func processRitsuLPIndexer(client *ethclient.Client, blockNumber int64) error { whitelist := map[string]struct{}{ - common.HexToAddress("0x67Cab37067309B664CFB12769FffA2bdc41D8EDe").Hex(): {}, + common.HexToAddress("0xaE7850cBbA0d7303eD06661c9B06f4A5127Ca75D").Hex(): {}, + common.HexToAddress("0xd7506E9Ebac0Ff14Ce3C600DC6Fd94240e5612D4").Hex(): {}, } - processor := ritsu.NewTransferIndexer(common.HexToAddress("0x7c38E9389B27668280E5aaAc372eBCb2ECc1c5E0"), whitelist) + tokens := []common.Address{ + common.HexToAddress("0x7c38E9389B27668280E5aaAc372eBCb2ECc1c5E0"), + common.HexToAddress("0x6c7839E0CE8AdA360a865E18a111A462d08DC15a"), + } + processor := ritsu.NewTransferIndexer(tokens, whitelist) return processLPLogIndexer(client, processor, blockNumber) } func processIziLPIndexer(client *ethclient.Client, blockNumber int64) error { whitelist := map[string]struct{}{ - common.HexToAddress("0x67Cab37067309B664CFB12769FffA2bdc41D8EDe").Hex(): {}, + common.HexToAddress("0x88867BF3bB3321d8c7Da71a8eAb70680037068E4").Hex(): {}, + } + tokens := []common.Address{ + common.HexToAddress("0x33531bDBFE34fa6Fd5963D0423f7699775AacaaF"), } - processor := izumi.NewTransferIndexer(common.HexToAddress("0x33531bDBFE34fa6Fd5963D0423f7699775AacaaF"), whitelist) + processor := izumi.NewTransferIndexer(tokens, whitelist) return processLPLogIndexer(client, processor, blockNumber) } diff --git a/cmd/process_log.go b/cmd/process_log.go index 1c4d17c..01306ef 100644 --- a/cmd/process_log.go +++ b/cmd/process_log.go @@ -7,7 +7,6 @@ import ( "math/big" "github.com/ethereum/go-ethereum" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/ethclient" "github.com/taikoxyz/trailblazer-adapters/adapters" ) @@ -45,7 +44,7 @@ func processLPLogIndexer(client *ethclient.Client, processor adapters.LPLogsInde return err } query := ethereum.FilterQuery{ - Addresses: []common.Address{processor.Address()}, + Addresses: processor.Address(), FromBlock: big.NewInt(blockNumber), ToBlock: big.NewInt(blockNumber), }