Skip to content

Commit

Permalink
fix(price-feeder): add minimum candle volume (#1634)
Browse files Browse the repository at this point in the history
  • Loading branch information
adamewozniak authored Dec 1, 2022
1 parent dfa05ca commit c11c191
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion price-feeder/oracle/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ import (
"github.com/umee-network/umee/price-feeder/oracle/provider"
)

var minimumTimeWeight = sdk.MustNewDecFromStr("0.2")
var (
minimumTimeWeight = sdk.MustNewDecFromStr("0.2000")
minimumCandleVolume = sdk.MustNewDecFromStr("0.0001")
)

const (
// tvwapCandlePeriod represents the time period we use for tvwap in minutes
Expand Down Expand Up @@ -110,6 +113,11 @@ func ComputeTVWAP(prices provider.AggregatedProviderCandles) (map[string]sdk.Dec
if timePeriod < candle.TimeStamp {
// timeDiff = now - candle.TimeStamp
timeDiff := sdk.NewDec(now - candle.TimeStamp)
// set minimum candle volume for low-trading assets
if candle.Volume.Equal(sdk.ZeroDec()) {
candle.Volume = minimumCandleVolume
}

// volume = candle.Volume * (weightUnit * (period - timeDiff) + minimumTimeWeight)
volume := candle.Volume.Mul(
weightUnit.Mul(period.Sub(timeDiff).Add(minimumTimeWeight)),
Expand Down

0 comments on commit c11c191

Please sign in to comment.