Skip to content

Commit

Permalink
add arb tx's TODO: (3) checking for duplicate denoms
Browse files Browse the repository at this point in the history
  • Loading branch information
lostak committed Jun 15, 2022
1 parent d0239e9 commit 0a4280b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions x/txfees/keeper/txfee_filters/arb_tx.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ func IsArbTxLoose(tx sdk.Tx) bool {

swapInDenom := ""
lpTypesSeen := make(map[gammtypes.LiquidityChangeType]bool, 2)
denomsSeen := make(map[string]int)

for _, m := range msgs {
// (4) Check that the tx doesn't have both JoinPool & ExitPool msgs
Expand All @@ -46,6 +47,18 @@ func IsArbTxLoose(tx sdk.Tx) bool {
return true
}
swapInDenom = swapMsg.TokenInDenom()

// (3) record all denoms seen across all swaps, and see if any duplicates.
// arb if denom has been in 3 or more tx
// 2 is fine: A -> B then B -> C
// 3 or more is arb: A->B, B->C, C->D, D->B
denomPath := swapMsg.TokenDenomsOnPath()
for _, denom := range denomPath {
denomsSeen[denom]++
if denomsSeen[denom] > 2 {
return true
}
}
}

return false
Expand Down

1 comment on commit 0a4280b

@lostak
Copy link
Author

@lostak lostak commented on 0a4280b Jun 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#741 #723
Implemented TODO @ValarDragon

Please sign in to comment.