Skip to content

Commit 66e4cd1

Browse files
committed
fix: routing
1 parent dcde579 commit 66e4cd1

File tree

6 files changed

+11
-23
lines changed

6 files changed

+11
-23
lines changed

cmd/debts/main.go

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@ import (
2121
"go.uber.org/fx"
2222
)
2323

24-
func StartServer(lc fx.Lifecycle, debtEng ds.DebtEngineI, config *config.Config, shutdowner fx.Shutdowner, client core.ClientI) {
25-
log.NewAMQPService(config.AMQPEnable, config.AMQPUrl, log.LoggingConfig{
26-
ChainId: core.GetChainId(client),
27-
Exchange: "TelegramBot",
28-
}, config.AppName)
24+
func StartServer(lc fx.Lifecycle, debtEng ds.DebtEngineI, cfg *config.Config, shutdowner fx.Shutdowner, client core.ClientI) {
25+
log.InitLogging(cfg.AppName, core.GetChainId(client), cfg.CommonEnvs, cfg.EthProvider)
2926
// Starting server
3027
lc.Append(fx.Hook{
3128
// To mitigate the impact of deadlocks in application startup and

cmd/main.go

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,7 @@ import (
3232
// }
3333

3434
func StartServer(lc fx.Lifecycle, engine ds.EngineI, cfg *config.Config, client core.ClientI) {
35-
log.NewAMQPService(
36-
cfg.AMQPEnable,
37-
cfg.AMQPUrl,
38-
log.LoggingConfig{
39-
Exchange: "TelegramBot",
40-
ChainId: core.GetChainId(client),
41-
RiskEndpoint: cfg.RiskEndpoint,
42-
RiskSecret: cfg.RiskSecret,
43-
},
44-
cfg.AppName,
45-
)
35+
log.InitLogging(cfg.AppName, core.GetChainId(client), cfg.CommonEnvs, cfg.EthProvider)
4636
// Starting server
4737
lc.Append(fx.Hook{
4838
// To mitigate the impact of deadlocks in application startup and

debts/engine.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,10 +193,10 @@ func (eng *DebtEngine) createTvlSnapshots(blockNum int64, caTotalValueInUSD floa
193193
underlyingToken := state.(*schemas.PoolState).UnderlyingToken
194194
//
195195
version := schemas.V1PF
196-
if eng.tokenLastPrice[schemas.V2PF] != nil {
196+
if eng.tokenLastPrice[schemas.V2PF] != nil && eng.tokenLastPrice[schemas.V2PF][underlyingToken] != nil {
197197
version = schemas.V2PF
198198
}
199-
if eng.tokenLastPrice[schemas.V3PF_MAIN] != nil {
199+
if eng.tokenLastPrice[schemas.V3PF_MAIN] != nil && eng.tokenLastPrice[schemas.V2PF][underlyingToken] != nil {
200200
version = schemas.V3PF_MAIN
201201
}
202202
//

debts/index.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ func (eng *DebtEngine) ProcessBackLogs() {
7777
minSynced := lastSync.Min()
7878
// lastDebtSynced = 227143579
7979
log.Info("Debt engine started, from", minSynced)
80-
eng.loadLastTvlSnapshot()
80+
eng.loadLastTvlSnapshot(lastSync.Tvl)
8181
eng.loadLastCSS(minSynced)
8282
eng.loadLastRebaseDetails(minSynced)
8383
eng.loadTokenLastPrice(minSynced)
@@ -100,11 +100,12 @@ func (eng *DebtEngine) ProcessBackLogs() {
100100
}
101101
eng.processBlocksInBatch(minSynced, adaptersSyncedTill, lastSync)
102102
}
103-
func (eng *DebtEngine) loadLastTvlSnapshot() {
103+
func (eng *DebtEngine) loadLastTvlSnapshot(lastTvlBlock int64) {
104104
lastTvlSnapshot := &schemas.TvlSnapshots{}
105105
if err := eng.db.Raw(`SELECT * FROM tvl_snapshots ORDER BY block_num DESC LIMIT 1`).Find(lastTvlSnapshot).Error; err != nil {
106106
log.Fatal(err)
107107
}
108+
lastTvlSnapshot.BlockNum = utils.Min(lastTvlBlock, lastTvlSnapshot.BlockNum)
108109
eng.lastTvlSnapshot = lastTvlSnapshot
109110
}
110111

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.20
44

55
require (
6-
github.com/Gearbox-protocol/sdk-go v0.0.0-20250320003540-9953f5c38c6b
6+
github.com/Gearbox-protocol/sdk-go v0.0.0-20250320044345-a15835e16419
77
github.com/ethereum/go-ethereum v1.13.14
88
github.com/go-playground/validator/v10 v10.4.1
99
github.com/google/go-cmp v0.5.9

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ contrib.go.opencensus.io/exporter/ocagent v0.6.0/go.mod h1:zmKjrJcdo0aYcVS7bmEeS
55
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
66
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
77
github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=
8-
github.com/Gearbox-protocol/sdk-go v0.0.0-20250320003540-9953f5c38c6b h1:l3pNJGDpRDmSkqoh/zI048M4uvqC0mt5fPKrpNp/X7o=
9-
github.com/Gearbox-protocol/sdk-go v0.0.0-20250320003540-9953f5c38c6b/go.mod h1:jRBSOG94bpGc5ci8EWIPUVXZdaGEaekMNmhajbmWFVU=
8+
github.com/Gearbox-protocol/sdk-go v0.0.0-20250320044345-a15835e16419 h1:OM2EtfbfEsNndye2ysx6Z8lf4tVqY4Ps0IxPWSG1/hs=
9+
github.com/Gearbox-protocol/sdk-go v0.0.0-20250320044345-a15835e16419/go.mod h1:jRBSOG94bpGc5ci8EWIPUVXZdaGEaekMNmhajbmWFVU=
1010
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
1111
github.com/Microsoft/go-winio v0.6.1/go.mod h1:LRdKpFKfdobln8UmuiYcKPot9D2v6svN5+sAH+4kjUM=
1212
github.com/OffchainLabs/go-ethereum v1.13.4-0.20240313010929-e5d8587e7227 h1:+/3TrD+q+BP36jGj2Bycdmrc/joKLNbc5ImePQzKRLM=

0 commit comments

Comments
 (0)