Skip to content

Commit

Permalink
update v5 1inch
Browse files Browse the repository at this point in the history
  • Loading branch information
ngocthanh1389 committed Mar 26, 2024
1 parent 926b5e5 commit c3b3f9d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 27 deletions.
21 changes: 3 additions & 18 deletions internal/server/backfill/dune_worker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
Expand All @@ -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{}
Expand All @@ -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
}

Expand All @@ -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,
Expand Down
18 changes: 9 additions & 9 deletions pkg/dune/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

0 comments on commit c3b3f9d

Please sign in to comment.