Skip to content

Commit 6160c62

Browse files
committed
fix: alert failed latestRounData only if repeated error
1 parent ac97887 commit 6160c62

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

models/aggregated_block_feed/base_price_feed/call_and_process.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ package base_price_feed
22

33
import (
44
"encoding/hex"
5+
"fmt"
56
"math/big"
7+
"time"
68

79
"github.com/Gearbox-protocol/sdk-go/artifacts/multicall"
810
"github.com/Gearbox-protocol/sdk-go/artifacts/redstone"
@@ -30,14 +32,17 @@ func (mdl *BasePriceFeed) GetCalls(blockNum int64) (calls []multicall.Multicall2
3032
}}, true
3133
}
3234

35+
var failedLatestRoundDataHandler = log.SendMsgIfCountMoreThan(time.Minute*30, 4) // if for the same feed, failed 4 times in 30 mins
36+
3337
// used in yearn and curve
3438
func ParseQueryRoundData(returnData []byte, isPriceInUSD bool, feed string, blockNum int64) *schemas.PriceFeed {
3539
priceFeedABI := core.GetAbi("PriceFeed")
3640
roundData := schemas.LatestRounData{}
3741
value, err := priceFeedABI.Unpack("latestRoundData", returnData)
3842
if err != nil {
3943
if !utils.Contains([]string{"0x7B7C81748f311Cf3B9dfe90Ec7F23e9F06813323", "0x2E65c16Fe6CFd0519Ae1F80448FCa0E0B07c1911"}, feed) { // only for curve
40-
log.Warnf("For feed(%s) can't get the latestRounData: %s at %d", feed, err, blockNum)
44+
msg := fmt.Sprintf("For feed(%s) can't get the latestRounData: %s at %d", feed, err, blockNum)
45+
failedLatestRoundDataHandler(feed, msg)
4146
}
4247
return nil
4348
}

0 commit comments

Comments
 (0)