From 340effb366e279cb456e9f0258187c1e4f18edca Mon Sep 17 00:00:00 2001 From: Rafael Tenfen Date: Thu, 27 Oct 2022 11:12:00 -0300 Subject: [PATCH] feat: update price feeder and umee versions (#399) - Updates the versions of umee and price-feeder (cherry picked from commit 6bad4d3972bb01582c5100ac06e3d5a344efd807) # Conflicts: # go.mod # go.sum --- CHANGELOG.md | 4 +++ cmd/peggo/orchestrator.go | 3 +- go.mod | 18 ++++++++-- go.sum | 24 ++++++++++--- orchestrator/oracle/oracle.go | 68 ++++++++++++++++++++++++++++++++++- 5 files changed, 109 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 12fae1dc..55e77630 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/cmd/peggo/orchestrator.go b/cmd/peggo/orchestrator.go index 39c6da9b..15b74ce7 100644 --- a/cmd/peggo/orchestrator.go +++ b/cmd/peggo/orchestrator.go @@ -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 } @@ -298,6 +298,7 @@ func getOrchestratorCmd() *cobra.Command { umeepfprovider.ProviderBinance.String(), umeepfprovider.ProviderBitget.String(), umeepfprovider.ProviderMexc.String(), + umeepfprovider.ProviderCrypto.String(), } allProviders := append([]string{ diff --git a/go.mod b/go.mod index 7b2b4062..34bc8211 100644 --- a/go.mod +++ b/go.mod @@ -22,6 +22,7 @@ require ( github.com/spf13/cobra v1.5.0 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.13.0 +<<<<<<< HEAD github.com/stretchr/testify v1.8.0 github.com/tendermint/tendermint v0.34.21 github.com/umee-network/umee/price-feeder v1.0.1-0.20220919160536-0c0db8c7c112 @@ -29,6 +30,15 @@ require ( golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 golang.org/x/term v0.0.0-20220722155259-a9ba230a4035 google.golang.org/grpc v1.49.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.20221027015322-96357449c737 + github.com/umee-network/umee/v3 v3.1.0 + golang.org/x/sync v0.0.0-20220929204114-8fcdb60fdcc0 + golang.org/x/term v0.1.0 + google.golang.org/grpc v1.50.1 +>>>>>>> 6bad4d3 (feat: update price feeder and umee versions (#399)) gopkg.in/yaml.v2 v2.4.0 ) @@ -50,7 +60,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.0 // indirect github.com/StackExchange/wmi v1.2.1 // indirect @@ -180,7 +190,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.0 // indirect @@ -331,7 +341,11 @@ require ( replace ( github.com/Gravity-Bridge/Gravity-Bridge/module => github.com/umee-network/Gravity-Bridge/module v1.5.3-umee-1 +<<<<<<< HEAD github.com/cosmos/cosmos-sdk => github.com/umee-network/cosmos-sdk v0.46.1-umee +======= + github.com/cosmos/cosmos-sdk => github.com/umee-network/cosmos-sdk v0.46.3-umee +>>>>>>> 6bad4d3 (feat: update price feeder and umee versions (#399)) 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 github.com/osmosis-labs/bech32-ibc => github.com/umee-network/bech32-ibc v0.3.0-rc1.0.20220831212913-42baad053f6e diff --git a/go.sum b/go.sum index bff2a095..c4e2faaa 100644 --- a/go.sum +++ b/go.sum @@ -107,8 +107,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= @@ -797,8 +797,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= @@ -1381,6 +1381,7 @@ github.com/ultraware/whitespace v0.0.5 h1:hh+/cpIcopyMYbZNVov9iSxvJU3OYQg78Sfaqz 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-1 h1:a4OGAGfmZ+jcHH//HuQCLeDYpLy3282t3deVKRPt+RU= github.com/umee-network/Gravity-Bridge/module v1.5.3-umee-1/go.mod h1:UN4ehDuy5PA1YY7juvBMMulyiKv7uBMLUbTV/vONzH0= +<<<<<<< HEAD github.com/umee-network/bech32-ibc v0.3.0-rc1.0.20220831212913-42baad053f6e h1:RCxnO359ieolUDIT1cF7Ic3ms4epgmZxzNiz1a2IBeU= github.com/umee-network/bech32-ibc v0.3.0-rc1.0.20220831212913-42baad053f6e/go.mod h1:Prssr3u1p2ICcgkhtMaX55NZv7A7E2ernO6fKrpolSg= github.com/umee-network/cosmos-sdk v0.46.1-umee h1:htt48oCN/i0An5z8AS8ttXU3Dk7fiE/gWNvwQGGOJgs= @@ -1389,6 +1390,16 @@ github.com/umee-network/umee/price-feeder v1.0.1-0.20220919160536-0c0db8c7c112 h github.com/umee-network/umee/price-feeder v1.0.1-0.20220919160536-0c0db8c7c112/go.mod h1:gN6k2Y54HswN8qhSsqT3KIrNwIAp7nZrngRmYeXKUxg= github.com/umee-network/umee/v3 v3.0.0-rc1 h1:PfIRqzcwplMT/+xrIeTaXqqeXkT+xpk4r5yS2gSSMew= github.com/umee-network/umee/v3 v3.0.0-rc1/go.mod h1:Ynig8YxdUZGguEWVKQmSeI5B/cUGsE2S2JmR0PSs7KI= +======= +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.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= +>>>>>>> 6bad4d3 (feat: update price feeder and umee versions (#399)) github.com/urfave/cli v1.20.0/go.mod h1:70zkFmudgCuE/ngEzBv17Jvp/497gISqfk5gWijbERA= github.com/urfave/cli v1.22.1 h1:+mkCCcOFKPnCmVYVcURKps1Xe+3zP90gSYGNfRkjoIY= github.com/urfave/cli v1.22.1/go.mod h1:Gos4lmkARVdJ6EkW0WaNv/tZAAMe9V7XWyB60NtXRu0= @@ -1648,6 +1659,11 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4 h1:uVc8UZUe6tr40fFVnUP5Oj+veunVezqYl9z7DYw9xzw= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +<<<<<<< HEAD +======= +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= +>>>>>>> 6bad4d3 (feat: update price feeder and umee versions (#399)) 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= diff --git a/orchestrator/oracle/oracle.go b/orchestrator/oracle/oracle.go index 5d397a55..dc2af344 100644 --- a/orchestrator/oracle/oracle.go +++ b/orchestrator/oracle/oracle.go @@ -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 @@ -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,