Skip to content

Commit

Permalink
fix: missed pool addr for lmrewards' diesel balance
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh-98 committed Apr 19, 2024
1 parent 3541f50 commit f4dd948
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/Gearbox-protocol/third-eye
go 1.20

require (
github.com/Gearbox-protocol/sdk-go v0.0.0-20240413224015-2cc43734767c
github.com/Gearbox-protocol/sdk-go v0.0.0-20240419003848-461298b9694b
github.com/ethereum/go-ethereum v1.13.14
github.com/go-playground/validator/v10 v10.4.1
github.com/google/go-cmp v0.5.9
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ contrib.go.opencensus.io/exporter/ocagent v0.6.0/go.mod h1:zmKjrJcdo0aYcVS7bmEeS
github.com/BurntSushi/toml v0.3.1 h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/DataDog/zstd v1.4.5 h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=
github.com/Gearbox-protocol/sdk-go v0.0.0-20240413224015-2cc43734767c h1:xwXE3Abj582rRK/sl63Er04b5VNwRyOErIGwsyWp2H4=
github.com/Gearbox-protocol/sdk-go v0.0.0-20240413224015-2cc43734767c/go.mod h1:GqBi61WLtfKxqYFle+ePGkWAOf5lKtgQBTOjGJwkgn0=
github.com/Gearbox-protocol/sdk-go v0.0.0-20240419003848-461298b9694b h1:Win10vc2jgMp+Qt//UFpDsk3gaoAUZ8J7VOW4ihQSfQ=
github.com/Gearbox-protocol/sdk-go v0.0.0-20240419003848-461298b9694b/go.mod h1:GqBi61WLtfKxqYFle+ePGkWAOf5lKtgQBTOjGJwkgn0=
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
github.com/Microsoft/go-winio v0.6.1 h1:9/kr64B9VUZrLm5YYwbGtUJnMgqWVOdUAXu6Migciow=
Expand Down
3 changes: 2 additions & 1 deletion models/credit_manager/cm_common/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func (mdl *CommonCMAdapter) CalculateCMStat(blockNum int64, state dc.CMCallData)
mdl.State.IsWETH = dc.IsWETH(mdl.Client, state.Underlying)
//
bororwAmountForBlock := mdl.GetBorrowAmountForBlockAndClear()
// add borrowed amount
mdl.State.TotalBorrowedBI = core.AddCoreAndInt(mdl.State.TotalBorrowedBI, bororwAmountForBlock)
mdl.State.TotalBorrowed = utils.GetFloat64Decimal(mdl.State.TotalBorrowedBI.Convert(), mdl.GetUnderlyingDecimal())
//
Expand All @@ -28,7 +29,7 @@ func (mdl *CommonCMAdapter) CalculateCMStat(blockNum int64, state dc.CMCallData)
new(big.Int).Sub(pnl.Profit, pnl.Loss),
))
mdl.State.TotalRepaid = utils.GetFloat64Decimal(mdl.State.TotalRepaidBI.Convert(), mdl.GetUnderlyingDecimal())
//
// repaying here, so subtract
mdl.State.TotalBorrowedBI = core.SubCoreAndInt(mdl.State.TotalBorrowedBI, pnl.BorrowedAmount)
mdl.State.TotalBorrowed = utils.GetFloat64Decimal(mdl.State.TotalBorrowedBI.Convert(), mdl.GetUnderlyingDecimal())
mdl.State.TotalLossesBI = core.AddCoreAndInt(mdl.State.TotalLossesBI, pnl.Loss)
Expand Down
7 changes: 2 additions & 5 deletions models/pool_lmrewards/v3/diesel_balance.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,8 @@ func (mdl *LMRewardsv3) updateDieselBalances(farmAddr, from, to string, amount *
DieselBalance: (*core.BigInt)(new(big.Int)),
}
}
farmAndItsUsers[from].updated = true
farmAndItsUsers[to].DieselBalance = (*core.BigInt)(new(big.Int).Add(
farmAndItsUsers[to].DieselBalance.Convert(),
amount,
))
farmAndItsUsers[to].updated = true
farmAndItsUsers[to].DieselBalance = core.AddCoreAndInt(farmAndItsUsers[to].DieselBalance, amount)
}
}
}
2 changes: 1 addition & 1 deletion models/pool_lmrewards/v3/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (mdl *LMRewardsv3) GetAllAddrsForLogs() (addrs []common.Address) {
//
for addr, farm := range mdl.farms {
addrs = append(addrs, common.HexToAddress(addr))
addrs = append(addrs, common.HexToAddress(farm.Farm))
addrs = append(addrs, common.HexToAddress(farm.Pool))
}
return addrs
}

0 comments on commit f4dd948

Please sign in to comment.