@@ -205,6 +205,12 @@ func (mdl *PriceOracle) getErc4626(oracle string) (pfType string, underlyingFeed
205205 }
206206 return
207207}
208+ func isChainLink (pf0 common.Address , client core.ClientI ) bool {
209+ con , err := priceFeed .NewPriceFeed (pf0 , client )
210+ log .CheckFatal (err )
211+ _ , err1 := con .PhaseId (nil )
212+ return err1 == nil
213+ }
208214
209215// https://github.com/Gearbox-protocol/integrations-v2/tree/faa9cfd4921c62165782dcdc196ff5a0c0e6075d/contracts/oracles
210216// https://github.com/Gearbox-protocol/oracles-v3/tree/2ac6d1ba1108df949222084791699d821096bc8c/contracts/oracles
@@ -244,10 +250,7 @@ func (mdl *PriceOracle) V3PriceFeedType(opts *bind.CallOpts, oracle, token strin
244250 if err != nil && strings .Contains (err .Error (), "execution reverted" ) {
245251 // this means that it can be from outside of gearbox protocol, like redstone own oracle.
246252 pf0Type := func () int {
247- con , err := priceFeed .NewPriceFeed (pf0 , mdl .Client )
248- log .CheckFatal (err )
249- _ , err1 := con .PhaseId (nil )
250- if err1 == nil {
253+ if isChainLink (pf0 , mdl .Client ) {
251254 return core .V3_CHAINLINK_ORACLE
252255 }
253256 return core .V3_CURVE_2LP_ORACLE
@@ -261,6 +264,14 @@ func (mdl *PriceOracle) V3PriceFeedType(opts *bind.CallOpts, oracle, token strin
261264 case core .V3_REDSTONE_ORACLE :
262265 return ds .CompositeRedStonePF , nil , nil
263266 case core .V3_CHAINLINK_ORACLE :
267+ pf1 := func () common.Address {
268+ pf , err := core .CallFuncGetSingleValue (mdl .Client , "ab0ca0e1" , common .HexToAddress (oracle ), 0 , nil ) // priceFeed0
269+ log .CheckFatal (err )
270+ return common .BytesToAddress (pf )
271+ }()
272+ if ! isChainLink (pf1 , mdl .Client ) {
273+ return ds .CurvePF , nil , nil
274+ }
264275 return ds .CompositeChainlinkPF , nil , nil
265276 default :
266277 return ds .CurvePF , nil , nil
0 commit comments