From dc7edce0163e252600e15e745728d7f476efec4c Mon Sep 17 00:00:00 2001 From: jeff <113397187+cyberhorsey@users.noreply.github.com> Date: Fri, 7 Jul 2023 12:48:09 -0700 Subject: [PATCH 1/4] fix(eventindexer): missing swap route (#14126) --- .../http/user_swapped_on_taiko.go | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 packages/eventindexer/http/user_swapped_on_taiko.go diff --git a/packages/eventindexer/http/user_swapped_on_taiko.go b/packages/eventindexer/http/user_swapped_on_taiko.go new file mode 100644 index 00000000000..c40c8bb9c55 --- /dev/null +++ b/packages/eventindexer/http/user_swapped_on_taiko.go @@ -0,0 +1,32 @@ +package http + +import ( + "net/http" + + "github.com/cyberhorsey/webutils" + "github.com/labstack/echo/v4" + "github.com/taikoxyz/taiko-mono/packages/eventindexer" +) + +func (srv *Server) UserSwappedOnTaiko(c echo.Context) error { + event, err := srv.eventRepo.FirstByAddressAndEventName( + c.Request().Context(), + c.QueryParam("address"), + eventindexer.EventNameSwap, + ) + if err != nil { + return webutils.LogAndRenderErrors(c, http.StatusUnprocessableEntity, err) + } + + var found bool = false + + if event != nil { + found = true + } + + return c.JSON(http.StatusOK, &galaxeAPIResponse{ + Data: galaxeData{ + IsOK: found, + }, + }) +} From 03eb96fad45365ace3b9662c27bd6bc4c972a676 Mon Sep 17 00:00:00 2001 From: jeff <113397187+cyberhorsey@users.noreply.github.com> Date: Fri, 7 Jul 2023 12:58:46 -0700 Subject: [PATCH 2/4] fix(eventindexer): route fix (#14127) --- packages/eventindexer/http/routes.go | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/eventindexer/http/routes.go b/packages/eventindexer/http/routes.go index f48c04de30a..98d1dcaa3f2 100644 --- a/packages/eventindexer/http/routes.go +++ b/packages/eventindexer/http/routes.go @@ -15,4 +15,5 @@ func (srv *Server) configureRoutes() { galaxeAPI.GET("/user-proposed-block", srv.UserProposedBlock) galaxeAPI.GET("/user-proved-block", srv.UserProvedBlock) galaxeAPI.GET("/user-bridged", srv.UserBridged) + galaxeAPI.GET("/user-swapped-on-taiko", srv.UserSwappedOnTaiko) } From 67ba5e44eca82c301dcd2a8d3c0909ac080a804c Mon Sep 17 00:00:00 2001 From: jeff <113397187+cyberhorsey@users.noreply.github.com> Date: Fri, 7 Jul 2023 14:51:38 -0700 Subject: [PATCH 3/4] feat(eventindexer): store swap sender correctly, plus check min amt (#14128) --- .../eventindexer/indexer/save_swap_event.go | 25 ++++++++++++++++--- packages/eventindexer/indexer/subscribe.go | 2 -- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/packages/eventindexer/indexer/save_swap_event.go b/packages/eventindexer/indexer/save_swap_event.go index 297bd9a7652..bc994b79d26 100644 --- a/packages/eventindexer/indexer/save_swap_event.go +++ b/packages/eventindexer/indexer/save_swap_event.go @@ -3,14 +3,20 @@ package indexer import ( "context" "encoding/json" + "fmt" "math/big" + "github.com/ethereum/go-ethereum/common" "github.com/pkg/errors" log "github.com/sirupsen/logrus" "github.com/taikoxyz/taiko-mono/packages/eventindexer" "github.com/taikoxyz/taiko-mono/packages/eventindexer/contracts/swap" ) +var ( + minTradeAmount = big.NewInt(10000000000000000) +) + func (svc *Service) saveSwapEvents( ctx context.Context, chainID *big.Int, @@ -24,8 +30,6 @@ func (svc *Service) saveSwapEvents( for { event := events.Event - log.Infof("new Swap event for sender: %v", event.Sender.Hex()) - if err := svc.saveSwapEvent(ctx, chainID, event); err != nil { eventindexer.SwapEventsProcessedError.Inc() @@ -43,6 +47,21 @@ func (svc *Service) saveSwapEvent( chainID *big.Int, event *swap.SwapSwap, ) error { + log.Infof("swap event for sender 0x%v, amount: %v", + common.Bytes2Hex(event.Raw.Topics[2].Bytes()[12:]), + event.Amount0In.String(), + ) + + // we only want events with > 0.1 ETH swap + if event.Amount0In.Cmp(minTradeAmount) <= 0 && event.Amount1Out.Cmp(minTradeAmount) <= 0 { + log.Infof("skipping skip event, min trade too low. amountIn: %v, amountOut: %v", + event.Amount0In.String(), + event.Amount1Out.String(), + ) + + return nil + } + marshaled, err := json.Marshal(event) if err != nil { return errors.Wrap(err, "json.Marshal(event)") @@ -53,7 +72,7 @@ func (svc *Service) saveSwapEvent( Data: string(marshaled), ChainID: chainID, Event: eventindexer.EventNameSwap, - Address: event.Sender.Hex(), + Address: fmt.Sprintf("0x%v", common.Bytes2Hex(event.Raw.Topics[2].Bytes()[12:])), }) if err != nil { return errors.Wrap(err, "svc.eventRepo.Save") diff --git a/packages/eventindexer/indexer/subscribe.go b/packages/eventindexer/indexer/subscribe.go index 23dd4fb9042..9b181a79aae 100644 --- a/packages/eventindexer/indexer/subscribe.go +++ b/packages/eventindexer/indexer/subscribe.go @@ -332,8 +332,6 @@ func (svc *Service) subscribeSwap(ctx context.Context, chainID *big.Int, errChan errChan <- errors.Wrap(err, "sub.Err()") case event := <-sink: go func() { - log.Infof("swap event for sender %v", event.Sender.Hex()) - if err := svc.saveSwapEvent(ctx, chainID, event); err != nil { eventindexer.SwapEventsProcessedError.Inc() From 6d7f2e0e93e860a2d8eeff28d8c92e10a9eda5c0 Mon Sep 17 00:00:00 2001 From: dave | d1onys1us <13951458+d1onys1us@users.noreply.github.com> Date: Sat, 8 Jul 2023 03:40:47 -0400 Subject: [PATCH 4/4] chore(website): update homepage blogs (#14125) --- packages/website/components/BlogSection.tsx | 30 ++++++++++----------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/website/components/BlogSection.tsx b/packages/website/components/BlogSection.tsx index 99d02c20b11..30f6eb3dbf4 100644 --- a/packages/website/components/BlogSection.tsx +++ b/packages/website/components/BlogSection.tsx @@ -1,4 +1,19 @@ const posts = [ + { + title: "Alpha-3 testnet update: stats & future plans", + href: "https://taiko.mirror.xyz/LBukIvc5nRfNdbzk3_bDZNkBRSmavFp_D90IkBYCuFk", + description: + "Alpha-3 has been drumming along for one month now! Let's take a look at what’s happened.", + date: "Jul 07, 2023", + datetime: "2023-07-07", + imageUrl: + "https://mirror-media.imgix.net/publication-images/4vqDxKbexLf3eX3d4GtRB.jpeg?height=512&width=1024&h=512&w=1024&auto=compress", + readingTime: "2 min", + author: { + name: "d1onys1us", + imageUrl: "https://avatars.githubusercontent.com/u/13951458?v=4", + }, + }, { title: "ZK-Roller-Coaster #8", href: "https://taiko.mirror.xyz/tOUCZgLRV9bKH24bxhahISpdhkQmqVyM-ZX-wMWtqkI", @@ -29,21 +44,6 @@ const posts = [ imageUrl: "https://avatars.githubusercontent.com/u/106527861?v=4", }, }, - { - title: "L2 MEV wat", - href: "https://taiko.mirror.xyz/VjNjFws6OOVez5YCDMwjy4BUiDqZBHYDvcW4-JZGDkc", - description: - "In this article, we “map” the current landscape of L2 MEV, thinking about different MEV consequences for different L2 designs. We also briefly overview different ways of L2s decentralization and how it might impact L2 MEV.", - date: "Jun 13, 2023", - datetime: "2023-06-13", - imageUrl: - "https://mirror-media.imgix.net/publication-images/Qgm0gbwbCQnU8bm5Y1dGB.png?height=512&width=1024&h=512&w=1024&auto=compress", - readingTime: "15 min", - author: { - name: "Lisa A.", - imageUrl: "https://avatars.githubusercontent.com/u/106527861?v=4", - }, - }, ]; export default function BlogSection() {