@@ -2,14 +2,18 @@ package curve_price_feed
22
33import (
44 "math/big"
5+ "strings"
56 "time"
67
78 "github.com/Gearbox-protocol/sdk-go/artifacts/multicall"
89 "github.com/Gearbox-protocol/sdk-go/core"
910 "github.com/Gearbox-protocol/sdk-go/core/schemas"
1011 "github.com/Gearbox-protocol/sdk-go/log"
12+ "github.com/Gearbox-protocol/sdk-go/utils"
1113 "github.com/Gearbox-protocol/third-eye/ds"
1214 "github.com/Gearbox-protocol/third-eye/models/aggregated_block_feed/base_price_feed"
15+ "github.com/Gearbox-protocol/third-eye/models/aggregated_block_feed/redstone_price_feed"
16+ "github.com/ethereum/go-ethereum/accounts/abi"
1317 "github.com/ethereum/go-ethereum/common"
1418)
1519
@@ -40,6 +44,25 @@ var curvePFLatestRoundDataTimer = map[string]log.TimerFn{}
4044func (adapter * CurvePriceFeed ) ProcessResult (blockNum int64 , results []multicall.Multicall2Result , _ string , force ... bool ) * schemas.PriceFeed {
4145 result := results [len (results )- 1 ]
4246 if ! result .Success {
47+ if core .GetBaseChainId (adapter .Client ) == 42793 {
48+ calls , _ := adapter .GetUnderlyingCalls (blockNum )
49+ mcabi := core .GetAbi ("MultiCall" )
50+ calldata , err := mcabi .Pack ("tryAggregate" , false , calls )
51+ log .CheckFatal (err )
52+
53+ rpc := strings .Split (adapter .Repo .GetCfg ().EthProvider , "," )
54+ multicallresult := redstone_price_feed .GetRedStoneResult (calldata , blockNum , rpc [0 ])
55+ value , err := core .GetAbi ("YearnPriceFeed" ).Unpack ("latestRoundData" , multicallresult )
56+ log .CheckFatal (err )
57+ price := * abi .ConvertType (value [1 ], new (* big.Int )).(* * big.Int )
58+ log .Info (price )
59+ return & schemas.PriceFeed {
60+ RoundId : 0 ,
61+ PriceBI : (* core .BigInt )(price ),
62+ Price : utils .GetFloat64Decimal (price , 8 ),
63+ BlockNumber : blockNum ,
64+ }
65+ }
4366 if adapter .GetVersion ().LessThan (core .NewVersion (300 )) { // failed and
4467 // if virtualprice of pool for this oracle is not within lowerBound and upperBound , ignore the price
4568 oracleAddr := common .HexToAddress (adapter .GetAddress ())
0 commit comments