Skip to content

Commit

Permalink
fix: retry feed for debt
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh-98 committed Sep 8, 2024
1 parent b1e2a6d commit 5b8f114
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
7 changes: 6 additions & 1 deletion debts/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ func (eng *DebtEngine) SessionDebtHandler(blockNum int64, session *schemas.Credi
// yearn price feed might be stale as a result difference btw dc and calculated values
// solution: fetch price again for all stale yearn feeds
if profile != nil {
yearnFeeds := eng.repo.GetYearnFeedAddrs()
yearnFeeds := eng.repo.GetRetryFeedForDebts()
for tokenAddr, details := range *sessionSnapshot.Balances {
if details.IsEnabled && details.HasBalanceMoreThanOne() {
lastPriceEvent := eng.getTokenPriceFeed(tokenAddr, schemas.VersionToPFVersion(session.Version, false)) // don't use reserve
Expand Down Expand Up @@ -504,6 +504,11 @@ func (eng *DebtEngine) SessionDataFromDC(version core.VersionType, blockNum int6
}

func (eng *DebtEngine) requestPriceFeed(blockNum int64, feed, token string, pfVersion schemas.MergedPFVersion) {
// defer func() {
// if err:= recover(); err != nil {
// log.Warn("err", err, "in getting yearn price feed in debt", feed, token, blockNum, pfVersion)
// }
// }()
// PFFIX
yearnPFContract, err := yearnPriceFeed.NewYearnPriceFeed(common.HexToAddress(feed), eng.client)
log.CheckFatal(err)
Expand Down
2 changes: 1 addition & 1 deletion ds/repo.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ type RepositoryI interface {
RecentMsgf(headers log.RiskHeader, msg string, args ...interface{})
//
// oracle and uni
GetYearnFeedAddrs() []string
GetRetryFeedForDebts() []string
//
LoadLastDebtSync() int64
LoadLastAdapterSync() int64
Expand Down
2 changes: 1 addition & 1 deletion ds/repo_dummy.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ func (DummyRepo) RecentMsgf(headers log.RiskHeader, msg string, args ...interfac
}

// oracle
func (DummyRepo) GetYearnFeedAddrs() []string {
func (DummyRepo) GetRetryFeedForDebts() []string {
return nil
}

Expand Down
11 changes: 9 additions & 2 deletions repository/handlers/kit_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,18 @@ func (repo AdapterKitHandler) GetAdaptersFromWrapper() (adapters []ds.SyncAdapte
return
}

func (repo AdapterKitHandler) GetYearnFeedAddrs() (addrs []string) {
func (repo AdapterKitHandler) GetRetryFeedForDebts() (addrs []string) {
feeds := repo.aggregatedBlockFeed.GetQueryFeeds()
addrs = make([]string, 0, len(feeds))
for _, adapter := range feeds {
addrs = append(addrs, adapter.GetAddress())
// ds.RedStonePF
// ds.CompositeRedStonePF

if utils.Contains([]string{ds.CurvePF,
ds.YearnPF,
ds.SingleAssetPF}, adapter.GetPFType()) {
addrs = append(addrs, adapter.GetAddress())
}
}
return
}
Expand Down

0 comments on commit 5b8f114

Please sign in to comment.