Skip to content

Commit

Permalink
feat: update price feeder and umee versions (#399)
Browse files Browse the repository at this point in the history
- Updates the versions of umee and price-feeder
  • Loading branch information
RafilxTenfen authored Oct 27, 2022
1 parent 77dc2e1 commit 6bad4d3
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 17 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ Ref: https://keepachangelog.com/en/1.0.0/

## [Unreleased]

### Improvements

- [#399](https://github.com/umee-network/peggo/pull/399) Update price-feeder to v101 and umee to v3.1.0.

## [v1.3.0](https://github.com/umee-network/peggo/releases/tag/v1.3.0) - 2022-10-26

### Improvements
Expand Down
3 changes: 2 additions & 1 deletion cmd/peggo/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func getOrchestratorCmd() *cobra.Command {
trapSignal(cancel)

providers := konfig.Strings(flagOracleProviders)
o, err := oracle.New(ctx, logger, stringsToProviderName(providers))
o, err := oracle.New(ctx, logger.With().Str("module", "oracle").Logger(), stringsToProviderName(providers))
if err != nil {
return err
}
Expand Down Expand Up @@ -298,6 +298,7 @@ func getOrchestratorCmd() *cobra.Command {
umeepfprovider.ProviderBinance.String(),
umeepfprovider.ProviderBitget.String(),
umeepfprovider.ProviderMexc.String(),
umeepfprovider.ProviderCrypto.String(),
}

allProviders := append([]string{
Expand Down
10 changes: 5 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ require (
github.com/spf13/viper v1.13.0
github.com/stretchr/testify v1.8.1
github.com/tendermint/tendermint v0.34.22
github.com/umee-network/umee/price-feeder v1.0.1-0.20220919160536-0c0db8c7c112
github.com/umee-network/umee/price-feeder v1.0.1-0.20221027015322-96357449c737
github.com/umee-network/umee/v3 v3.1.0
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde
golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0
golang.org/x/term v0.1.0
google.golang.org/grpc v1.50.1
gopkg.in/yaml.v2 v2.4.0
Expand All @@ -51,7 +51,7 @@ require (
github.com/Djarvur/go-err113 v0.0.0-20210108212216-aea10b59be24 // indirect
github.com/GaijinEntertainment/go-exhaustruct/v2 v2.3.0 // indirect
github.com/Masterminds/semver v1.5.0 // indirect
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/Microsoft/go-winio v0.6.0 // indirect
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 // indirect
github.com/OpenPeeDeeP/depguard v1.1.1 // indirect
github.com/StackExchange/wmi v1.2.1 // indirect
Expand Down Expand Up @@ -182,7 +182,7 @@ require (
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hdevalence/ed25519consensus v0.0.0-20220222234857-c00d1f31bab3 // indirect
github.com/hexops/gotextdiff v1.0.3 // indirect
github.com/ignite/cli v0.24.0 // indirect
github.com/ignite/cli v0.25.1 // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/improbable-eng/grpc-web v0.15.0 // indirect
github.com/inconshreveable/mousetrap v1.0.1 // indirect
Expand Down Expand Up @@ -334,7 +334,7 @@ require (
)

replace (
github.com/Gravity-Bridge/Gravity-Bridge/module => github.com/umee-network/Gravity-Bridge/module v1.5.3-umee-2
github.com/Gravity-Bridge/Gravity-Bridge/module => github.com/umee-network/Gravity-Bridge/module v1.5.3-umee-1
github.com/cosmos/cosmos-sdk => github.com/umee-network/cosmos-sdk v0.46.3-umee
github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.8.1
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
Expand Down
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ github.com/GaijinEntertainment/go-exhaustruct/v2 v2.3.0/go.mod h1:b3g59n2Y+T5xmc
github.com/Knetic/govaluate v3.0.1-0.20171022003610-9aa49832a739+incompatible/go.mod h1:r7JcOSlj0wfOMncg0iLm8Leh48TZaKVeNIfJntJ2wa0=
github.com/Masterminds/semver v1.5.0 h1:H65muMkzWKEuNDnfl9d70GUjFniHKHRbFPGBuZ3QEww=
github.com/Masterminds/semver v1.5.0/go.mod h1:MB6lktGJrhw8PrUyiEoblNEGEQ+RzHPF078ddwwvV3Y=
github.com/Microsoft/go-winio v0.5.2 h1:a9IhgEQBCUEk6QCdml9CiJGhAws+YwffDHEMp1VMrpA=
github.com/Microsoft/go-winio v0.5.2/go.mod h1:WpS1mjBmmwHBEWmogvA2mj8546UReBk4v8QkMxJ6pZY=
github.com/Microsoft/go-winio v0.6.0 h1:slsWYD/zyx7lCXoZVlvQrj0hPTM1HI4+v1sIda2yDvg=
github.com/Microsoft/go-winio v0.6.0/go.mod h1:cTAf44im0RAYeL23bpB+fzCyDH2MJiz2BO69KH/soAE=
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5 h1:TngWCqHvy9oXAN6lEVMRuU21PR1EtLVZJmdB18Gu3Rw=
github.com/Nvveen/Gotty v0.0.0-20120604004816-cd527374f1e5/go.mod h1:lmUJ/7eu/Q8D7ML55dXQrVaamCz2vxCfdQBasLZfHKk=
github.com/OneOfOne/xxhash v1.2.2 h1:KMrpdQIwFcEqXDklaen+P1axHaj9BSKzvpUUfnHldSE=
Expand Down Expand Up @@ -803,8 +803,8 @@ github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ=
github.com/huin/goutil v0.0.0-20170803182201-1ca381bf3150/go.mod h1:PpLOETDnJ0o3iZrZfqZzyLl6l7F3c6L1oWn7OICBi6o=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ignite/cli v0.24.0 h1:2cggSIsT4MT9IIS4/8XqlwgekI0YWPMYeULLGrTgCUY=
github.com/ignite/cli v0.24.0/go.mod h1:XlqM9HK751rcKZg7RfrP9KiJRAVi4XfZskhGnHPgLr0=
github.com/ignite/cli v0.25.1 h1:Ake0dLhFeb5cid3jdqkknghwF86FeUm9a+pqSK0VI8I=
github.com/ignite/cli v0.25.1/go.mod h1:EcKz1T5hVkyQsEhdgK6Ka/YEgZvDmqk93c7JLUCMPW0=
github.com/imdario/mergo v0.3.13 h1:lFzP57bqS/wsqKssCGmtLAb8A0wKjLGrve2q3PPVcBk=
github.com/imdario/mergo v0.3.13/go.mod h1:4lJ1jqUDcsbIECGy0RUJAXNIhg+6ocWgb1ALK2O4oXg=
github.com/improbable-eng/grpc-web v0.15.0 h1:BN+7z6uNXZ1tQGcNAuaU1YjsLTApzkjt2tzCixLaUPQ=
Expand Down Expand Up @@ -1393,14 +1393,14 @@ github.com/ultraware/funlen v0.0.3 h1:5ylVWm8wsNwH5aWo9438pwvsK0QiqVuUrt9bn7S/iL
github.com/ultraware/funlen v0.0.3/go.mod h1:Dp4UiAus7Wdb9KUZsYWZEWiRzGuM2kXM1lPbfaF6xhA=
github.com/ultraware/whitespace v0.0.5 h1:hh+/cpIcopyMYbZNVov9iSxvJU3OYQg78Sfaqzi/CzI=
github.com/ultraware/whitespace v0.0.5/go.mod h1:aVMh/gQve5Maj9hQ/hg+F75lr/X5A89uZnzAmWSineA=
github.com/umee-network/Gravity-Bridge/module v1.5.3-umee-2 h1:qb/enEHRxoPi26mZ4B5FDhaI8r7MAgaITJs35wdDXmY=
github.com/umee-network/Gravity-Bridge/module v1.5.3-umee-2/go.mod h1:UN4ehDuy5PA1YY7juvBMMulyiKv7uBMLUbTV/vONzH0=
github.com/umee-network/Gravity-Bridge/module v1.5.3-umee-1 h1:a4OGAGfmZ+jcHH//HuQCLeDYpLy3282t3deVKRPt+RU=
github.com/umee-network/Gravity-Bridge/module v1.5.3-umee-1/go.mod h1:UN4ehDuy5PA1YY7juvBMMulyiKv7uBMLUbTV/vONzH0=
github.com/umee-network/bech32-ibc v0.3.0 h1:WP0w6hG/B9WJ5hfUNx7Hd9pE0MJR/Lp9Y1NPjh03/40=
github.com/umee-network/bech32-ibc v0.3.0/go.mod h1:PqMePY74J6wqJH7Yai1l94rPsEe6QVa9X8gt5/M5nIo=
github.com/umee-network/cosmos-sdk v0.46.3-umee h1:q1tSnFHyxAc/EdJRPHVawvLWrMRVB1NMk/qgTvMrnRo=
github.com/umee-network/cosmos-sdk v0.46.3-umee/go.mod h1:AynIAjXwtS3T/ApdhNCz/7/KGMbZSUBbKRTcbukb2ic=
github.com/umee-network/umee/price-feeder v1.0.1-0.20220919160536-0c0db8c7c112 h1:djYVbmSzcYaO+pVwZW0aljmbuTPW0RcI/w/JP48y/v4=
github.com/umee-network/umee/price-feeder v1.0.1-0.20220919160536-0c0db8c7c112/go.mod h1:gN6k2Y54HswN8qhSsqT3KIrNwIAp7nZrngRmYeXKUxg=
github.com/umee-network/umee/price-feeder v1.0.1-0.20221027015322-96357449c737 h1:8NZaHAl6/Xoss6qfsUvxc6o9JZdPQzUS6ku87UvhJeQ=
github.com/umee-network/umee/price-feeder v1.0.1-0.20221027015322-96357449c737/go.mod h1:qtGLqvFnz9I9gJBpI3918hEIZZbeqJ3r2yJW/1fK8mM=
github.com/umee-network/umee/v3 v3.1.0 h1:2+Qifi/xfyKbexk76mHuZaMoztueILkBiMc64TJwJRI=
github.com/umee-network/umee/v3 v3.1.0/go.mod h1:8hTD7AzHlrNU3yNtmMAL2BJN4Hy1sWSoangVu3vAdOQ=
github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA=
Expand Down Expand Up @@ -1663,8 +1663,8 @@ golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJ
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde h1:ejfdSekXMDxDLbRrJMwUk6KnSLZ2McaUCVcIKM+N6jc=
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0 h1:cu5kTvlzcw1Q5S9f5ip1/cpiB4nXvw1XYzFPGgzLUOY=
golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
Expand Down
68 changes: 67 additions & 1 deletion orchestrator/oracle/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,72 @@ func (o *Oracle) loadAvailablePairs() {
}
}

// GetComputedPrices gets the candle and ticker prices and computes it.
// It returns candles' TVWAP if possible, if not possible (not available
// or due to some staleness) it will use the most recent ticker prices
// and the VWAP formula instead.
func GetComputedPrices(
logger zerolog.Logger,
providerCandles pfprovider.AggregatedProviderCandles,
providerPrices pfprovider.AggregatedProviderPrices,
providerPairs map[pfprovider.Name][]pftypes.CurrencyPair,
deviations map[string]sdk.Dec,
) (prices map[string]sdk.Dec, err error) {
// convert any non-USD denominated candles into USD
convertedCandles, err := pforacle.ConvertCandlesToUSD(
logger,
providerCandles,
providerPairs,
deviations,
)
if err != nil {
return nil, err
}

// filter out any erroneous candles
filteredCandles, err := pforacle.FilterCandleDeviations(
logger,
convertedCandles,
deviations,
)
if err != nil {
return nil, err
}

// attempt to use candles for TVWAP calculations
tvwapPrices, err := pforacle.ComputeTVWAP(filteredCandles)
if err != nil {
return nil, err
}

// If TVWAP candles are not available or were filtered out due to staleness,
// use most recent prices & VWAP instead.
if len(tvwapPrices) == 0 {
convertedTickers, err := pforacle.ConvertTickersToUSD(
logger,
providerPrices,
providerPairs,
deviations,
)
if err != nil {
return nil, err
}

filteredProviderPrices, err := pforacle.FilterTickerDeviations(
logger,
convertedTickers,
deviations,
)
if err != nil {
return nil, err
}

return pforacle.ComputeVWAP(filteredProviderPrices), nil
}

return tvwapPrices, nil
}

// setPrices retrieves all the prices and candles from our set of providers as
// determined in the config. If candles are available, uses TVWAP in order
// to determine prices. If candles are not available, uses the most recent prices
Expand Down Expand Up @@ -305,7 +371,7 @@ func (o *Oracle) setPrices() error {

deviationTreshold := sdk.NewDecFromIntWithPrec(sdkmath.NewInt(15), 1)

computedPrices, err := pforacle.GetComputedPrices(
computedPrices, err := GetComputedPrices(
o.logger,
providerCandles,
providerPrices,
Expand Down

0 comments on commit 6bad4d3

Please sign in to comment.