Skip to content

Commit 7f29aa8

Browse files
committed
fix: sort events in sdk-go
1 parent c782f51 commit 7f29aa8

File tree

4 files changed

+10
-12
lines changed

4 files changed

+10
-12
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ module github.com/Gearbox-protocol/third-eye
33
go 1.19
44

55
require (
6-
github.com/Gearbox-protocol/sdk-go v0.0.0-20231031010153-0c96fee0340d
6+
github.com/Gearbox-protocol/sdk-go v0.0.0-20231123040843-9f3cf2a7086b
77
github.com/ethereum/go-ethereum v1.10.17
88
github.com/go-playground/validator/v10 v10.4.1
99
github.com/google/go-cmp v0.5.8

go.sum

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,8 @@ github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ
4343
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
4444
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
4545
github.com/DATA-DOG/go-sqlmock v1.3.3/go.mod h1:f/Ixk793poVmq4qj/V1dPUg2JEAKC73Q5eFN3EC/SaM=
46-
github.com/Gearbox-protocol/sdk-go v0.0.0-20231006151232-7b803d31bbe7 h1:DSojCt4rvoQZiPok/h4vji0ix/dPloOOpsn8KVVe00Q=
47-
github.com/Gearbox-protocol/sdk-go v0.0.0-20231006151232-7b803d31bbe7/go.mod h1:GniLx/DU7tCT+QSlKt9REqUaF748X8rbDNR4vAd1m+Y=
48-
github.com/Gearbox-protocol/sdk-go v0.0.0-20231031010153-0c96fee0340d h1:VgEFE8GL9IP9vmcmP4Pm0bKRQ6h2VXrj2wyFDDtjDVg=
49-
github.com/Gearbox-protocol/sdk-go v0.0.0-20231031010153-0c96fee0340d/go.mod h1:GniLx/DU7tCT+QSlKt9REqUaF748X8rbDNR4vAd1m+Y=
46+
github.com/Gearbox-protocol/sdk-go v0.0.0-20231123040843-9f3cf2a7086b h1:b0/umiBjjuQAk8fw+PWa/LHcjBF/zNNWrSg+NcVRt64=
47+
github.com/Gearbox-protocol/sdk-go v0.0.0-20231123040843-9f3cf2a7086b/go.mod h1:GniLx/DU7tCT+QSlKt9REqUaF748X8rbDNR4vAd1m+Y=
5048
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
5149
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
5250
github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU=

models/pool/on_log.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -141,10 +141,10 @@ func (mdl *Pool) OnLog(txLog types.Log) {
141141
case core.Topic("WithdrawETH(address,address)"):
142142
pool := common.BytesToAddress(txLog.Topics[1][:]).Hex()
143143
user := common.BytesToAddress(txLog.Topics[2][:]).Hex()
144-
ind := txLog.TxIndex - 2
144+
ind := txLog.Index - 2
145145
blockNum := int64(txLog.BlockNumber)
146146
// for weth pool, WithdrawETH is emitted on weth gateway, so we track withdraETH on gateway for getting user
147-
mdl.gatewayHandler.checkWithdrawETH(blockNum, int64(ind), pool, user)
147+
mdl.gatewayHandler.checkWithdrawETH(txLog.TxHash.Hex(), blockNum, int64(ind), pool, user)
148148
case core.Topic("Transfer(address,address,uint256)"):
149149
from := common.BytesToAddress(txLog.Topics[1][:])
150150
to := common.BytesToAddress(txLog.Topics[2][:]).Hex()
@@ -153,9 +153,9 @@ func (mdl *Pool) OnLog(txLog types.Log) {
153153
if !(from == mdl.gatewayHandler.Gateway && to != mdl.gatewayHandler.UserCantBe.Hex()) {
154154
return
155155
}
156-
ind := txLog.TxIndex - 3
156+
ind := txLog.Index - 3
157157
blockNum := int64(txLog.BlockNumber)
158-
mdl.gatewayHandler.checkWithdrawETH(blockNum, int64(ind), mdl.Address, to)
158+
mdl.gatewayHandler.checkWithdrawETH(txLog.TxHash.Hex(), blockNum, int64(ind), mdl.Address, to)
159159
}
160160
}
161161

models/pool/weth_gateway_handler.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (g *GatewayHandler) getRemoveLiqEventsAndClear() []*schemas.PoolLedger {
5252
return events
5353
}
5454

55-
func (g *GatewayHandler) checkWithdrawETH(blockNum, ind int64, pool, user string) {
55+
func (g *GatewayHandler) checkWithdrawETH(txHash string, blockNum, ind int64, pool, user string) {
5656
if g.Gateway == core.NULL_ADDR {
5757
return
5858
}
@@ -61,8 +61,8 @@ func (g *GatewayHandler) checkWithdrawETH(blockNum, ind int64, pool, user string
6161
g.lastEntry.User = user
6262
} else {
6363
log.Fatalf(`WithdrawalWETH event on gateway@(%d,%d)
64-
but no matching last pool Remove Liquidity %s`,
65-
blockNum, ind, utils.ToJson(g.lastEntry))
64+
but no matching last pool Remove Liquidity %s. TxHash: %s`,
65+
blockNum, ind, utils.ToJson(g.lastEntry), txHash)
6666
}
6767
}
6868

0 commit comments

Comments
 (0)