From c3b3f9de2525f332bf46a59d6ed3563fea834e8f Mon Sep 17 00:00:00 2001 From: "minhthanh.vu" Date: Tue, 26 Mar 2024 17:28:31 +0700 Subject: [PATCH] update v5 1inch --- internal/server/backfill/dune_worker.go | 21 +++------------------ pkg/dune/client.go | 18 +++++++++--------- 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/internal/server/backfill/dune_worker.go b/internal/server/backfill/dune_worker.go index 36f1146..31ee99b 100644 --- a/internal/server/backfill/dune_worker.go +++ b/internal/server/backfill/dune_worker.go @@ -183,7 +183,7 @@ func OneInchDuneLogToTrade(l dune.OneInchDuneLog, version string) (storage.Trade if err != nil { return storage.TradeLog{}, err } - makerTokenAmount, takerTokenAmount, maker, makerAsset, takerAsset, eventHash := "", "", "", "", "", "" + maker, makerAsset, takerAsset, eventHash := "", "", "", "" switch version { case "v5": order := OneInchOrderV5{} @@ -193,12 +193,6 @@ func OneInchDuneLogToTrade(l dune.OneInchDuneLog, version string) (storage.Trade maker = order.Maker makerAsset = order.MakerAsset takerAsset = order.TakerAsset - if err := json.Unmarshal(l.Output0, &makerTokenAmount); err != nil { - return storage.TradeLog{}, err - } - if err := json.Unmarshal(l.Output1, &takerTokenAmount); err != nil { - return storage.TradeLog{}, err - } eventHash = OneInchV5EventHash default: order := OneInchOrderV6{} @@ -208,15 +202,6 @@ func OneInchDuneLogToTrade(l dune.OneInchDuneLog, version string) (storage.Trade maker = order.Maker.Hex() makerAsset = order.MakerAsset.Hex() takerAsset = order.TakerAsset.Hex() - var tmp storage.BigInt - if err := json.Unmarshal(l.Output0, &tmp); err != nil { - return storage.TradeLog{}, err - } - makerTokenAmount = tmp.String() - if err := json.Unmarshal(l.Output1, &tmp); err != nil { - return storage.TradeLog{}, err - } - takerTokenAmount = tmp.String() eventHash = OneInchV6EventHash } @@ -225,8 +210,8 @@ func OneInchDuneLogToTrade(l dune.OneInchDuneLog, version string) (storage.Trade Maker: maker, MakerToken: makerAsset, TakerToken: takerAsset, - MakerTokenAmount: makerTokenAmount, - TakerTokenAmount: takerTokenAmount, + MakerTokenAmount: l.Output0, + TakerTokenAmount: l.Output1, ContractAddress: l.ContractAddress, BlockNumber: l.BlockNumber, TxHash: l.TxHash, diff --git a/pkg/dune/client.go b/pkg/dune/client.go index 877c8de..a290039 100644 --- a/pkg/dune/client.go +++ b/pkg/dune/client.go @@ -166,13 +166,13 @@ func (c *Client) GetLastestExecuteResult(queryID int64, limit, offset uint64, ou } type OneInchDuneLog struct { - ContractAddress string `json:"contract_address"` - EventIndex uint64 `json:"evt_index"` - TxHash string `json:"call_tx_hash"` - BlockTime string `json:"call_block_time"` - BlockNumber uint64 `json:"call_block_number"` - Order string `json:"order"` - Output0 json.RawMessage `json:"output_0"` - Output1 json.RawMessage `json:"output_1"` - Output2 string `json:"output_2"` + ContractAddress string `json:"contract_address"` + EventIndex uint64 `json:"evt_index"` + TxHash string `json:"call_tx_hash"` + BlockTime string `json:"call_block_time"` + BlockNumber uint64 `json:"call_block_number"` + Order string `json:"order"` + Output0 string `json:"output_0"` + Output1 string `json:"output_1"` + Output2 string `json:"output_2"` }