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

(cherry picked from commit 6bad4d3)

# Conflicts:
#	go.mod
#	go.sum
  • Loading branch information
RafilxTenfen authored and mergify[bot] committed Oct 27, 2022
1 parent 5fec99c commit 340effb
Show file tree
Hide file tree
Showing 5 changed files with 109 additions and 8 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
18 changes: 16 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,23 @@ 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
github.com/umee-network/umee/v3 v3.0.0-rc1
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
)

Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
24 changes: 20 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand Down Expand Up @@ -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=
Expand All @@ -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=
Expand Down Expand Up @@ -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=
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 340effb

Please sign in to comment.