Skip to content

Commit

Permalink
feat: redstone price feed token should be token for which that feed i…
Browse files Browse the repository at this point in the history
…s added
  • Loading branch information
harsh-98 committed Jan 7, 2025
1 parent c0e0ab7 commit 0783cf4
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pkg/priceFetcher/gearbox_oracle_v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func RedstoneDetails(feed common.Address, client core.ClientI) (feedToken common
}()
return
}
func (pOracle *GearboxOraclev3) GetPF01AndFeedType(feed common.Address, blockNum int64, client core.ClientI) {
func (pOracle *GearboxOraclev3) GetPF01AndFeedType(token common.Address, feed common.Address, blockNum int64, client core.ClientI) {
if _, ok := pOracle.feedToInfo[feed]; ok {
return
}
Expand Down Expand Up @@ -170,12 +170,22 @@ func (pOracle *GearboxOraclev3) GetPF01AndFeedType(feed common.Address, blockNum
}
} else if pfType == core.V3_PENDLE_PT_TWAP_ORACLE {
obj.PF0 = fn(feed, "741bef1a") // priceFeed
pOracle.GetPF01AndFeedType(obj.PF0, blockNum, client)
pOracle.GetPF01AndFeedType(core.NULL_ADDR, obj.PF0, blockNum, client)
if utils.Contains([]int{core.V3_BACKEND_COMPOSITE_REDSTONE_ORACLE, core.V3_REDSTONE_ORACLE}, pOracle.GetFeedInfo(obj.PF0).Type) {
obj.Type = core.V3_PULL_UNDERLYING_ORACLE
}
} else if pfType == core.V3_ERC4626_VAULT_ORACLE { // for stkUSDS on mainnet.
obj.PF0 = fn(feed, "741bef1a") // priceFeed
lpToken := fn(feed, "82c63066") // lpToken
pOracle.GetPF01AndFeedType(lpToken, obj.PF0, blockNum, client)
if utils.Contains([]int{core.V3_BACKEND_COMPOSITE_REDSTONE_ORACLE, core.V3_REDSTONE_ORACLE}, pOracle.GetFeedInfo(obj.PF0).Type) {
obj.Type = core.V3_PULL_UNDERLYING_ORACLE
}
} else if pfType == core.V3_REDSTONE_ORACLE {
token, signThreshold, dataId := RedstoneDetails(feed, pOracle.Node.Client)
onChainToken, signThreshold, dataId := RedstoneDetails(feed, pOracle.Node.Client)
if token == core.NULL_ADDR {
token = onChainToken
}
//
obj.FeedToken = token
obj.SignThreshold = signThreshold
Expand All @@ -199,7 +209,7 @@ func (pOracle *GearboxOraclev3) addtokenToType(blockNum int64, feed common.Addre
if pOracle.tokenToType[token] == nil {
pOracle.tokenToType[token] = map[bool][]typeAndBlock{}
}
pOracle.GetPF01AndFeedType(feed, blockNum, pOracle.Node.Client)
pOracle.GetPF01AndFeedType(token, feed, blockNum, pOracle.Node.Client)
//
info := pOracle.feedToInfo[feed]
pOracle.tokenToType[token][reserve] = append(pOracle.tokenToType[token][reserve], info.typeAndBlock)
Expand Down

0 comments on commit 0783cf4

Please sign in to comment.