Skip to content

Commit

Permalink
chore: bump github.com/umee-network/umee/price-feeder from 0.2.1 to 0…
Browse files Browse the repository at this point in the history
….2.4 (#322)

Bumps [github.com/umee-network/umee/price-feeder](https://github.com/umee-network/umee) from 0.2.1 to 0.2.4.
<details>
<summary>Release notes</summary>
<p><em>Sourced from <a href="https://github.com/umee-network/umee/releases">github.com/umee-network/umee/price-feeder's releases</a>.</em></p>
<blockquote>
<h2>price-feeder/v0.2.4</h2>
<h2>Changelog</h2>
<p>a373b4b feat: multi-quote deviation logic (backport <a href="https://github-redirect.dependabot.com/umee-network/umee/issues/1110">#1110</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/1132">#1132</a>)
b666930 feat!: price-feeder: add the ability to configure asset deviation thresholds (backport <a href="https://github-redirect.dependabot.com/umee-network/umee/issues/998">#998</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/1133">#1133</a>)</p>
<h2>price-feeder/v0.2.3</h2>
<h2>Changelog</h2>
<p>cf4ea5c feat: add cache for chain height  (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/1069">#1069</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/1081">#1081</a>)</p>
<h2>price-feeder/v0.2.2</h2>
<h2>Changelog</h2>
<p>90b8ee3 fix: gorelease from 1.18 compat to 1.17 (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/1059">#1059</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/1060">#1060</a>)
e50d617 feat!: cache get params for 200 blocks (backport <a href="https://github-redirect.dependabot.com/umee-network/umee/issues/1050">#1050</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/1054">#1054</a>)
643f58c build(deps): Bump gopkg.in/yaml.v3 from 3.0.0 to 3.0.1 (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/983">#983</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/994">#994</a>)
f296194 build(deps): Bump github.com/spf13/viper from 1.11.0 to 1.12.0 (backport <a href="https://github-redirect.dependabot.com/umee-network/umee/issues/972">#972</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/982">#982</a>)
762d637 chore: price-feeder: oracle package cleanup (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/978">#978</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/980">#980</a>)
72a9d14 chore: update price feeder releaser to use 1.18 (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/976">#976</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/979">#979</a>)
fc5fdf3 build(deps): Bump github.com/ory/dockertest/v3 from 3.9.0 to 3.9.1 (backport <a href="https://github-redirect.dependabot.com/umee-network/umee/issues/970">#970</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/974">#974</a>)
4ba112b feat: Require stablecoins to be converted to USD (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/925">#925</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/938">#938</a>)
fdb7e61 chore: update upstream gravity module to fix halt bug (backport <a href="https://github-redirect.dependabot.com/umee-network/umee/issues/932">#932</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/934">#934</a>)
7fbc4e8 build(deps): Bump github.com/golangci/golangci-lint (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/920">#920</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/922">#922</a>)
6df332a build(deps): Bump github.com/golangci/golangci-lint from 1.46.0 to 1.46.1 (backport <a href="https://github-redirect.dependabot.com/umee-network/umee/issues/899">#899</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/912">#912</a>)
af70099 build(deps): Bump github.com/spf13/cast from 1.4.1 to 1.5.0 (backport <a href="https://github-redirect.dependabot.com/umee-network/umee/issues/895">#895</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/906">#906</a>)
0712ff2 chore: add script to tidy all go modules (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/888">#888</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/910">#910</a>)
3f77a12 build(deps): Bump github.com/prometheus/client_golang from 1.12.1 to 1.12.2 in /price-feeder (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/907">#907</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/908">#908</a>)
65b5c9f chore: go mod tidy --compat=1.17 (backport <a href="https://github-redirect.dependabot.com/umee-network/umee/issues/884">#884</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/887">#887</a>)
f2b259b build(deps): Bump github.com/go-playground/validator/v10 (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/855">#855</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/856">#856</a>)
5f63faf build(deps): Bump github.com/umee-network/umee/v2 from 2.0.0 to 2.0.1 in /price-feeder (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/842">#842</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/850">#850</a>)
da1ad8b build(deps): Bump github.com/armon/go-metrics from 0.3.10 to 0.3.11 in /price-feeder (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/848">#848</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/849">#849</a>)
de5c057 build(deps): Bump github.com/cosmos/cosmos-sdk from 0.45.3 to 0.45.4 in /price-feeder (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/843">#843</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/851">#851</a>)
a807651 build(deps): Bump github.com/prometheus/common from 0.33.0 to 0.34.0 in /price-feeder (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/824">#824</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/825">#825</a>)
ddf9694 build(deps): Bump github.com/cosmos/cosmos-sdk from 0.45.2 to 0.45.3 in /price-feeder (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/805">#805</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/807">#807</a>)
af7e7c1 chore: format once with gofumpt (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/797">#797</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/800">#800</a>)
cab1385 build(deps): Bump actions/upload-artifact from 2 to 3 (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/790">#790</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/794">#794</a>)
474ae4d docs: price-feeder v0.2.1 changelog update (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/779">#779</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/780">#780</a>)</p>
</blockquote>
</details>
<details>
<summary>Commits</summary>
<ul>
<li><a href="https://github.com/umee-network/umee/commit/a373b4bed9944c641a5d41678f1600a8639d2e19"><code>a373b4b</code></a> feat: multi-quote deviation logic (backport <a href="https://github-redirect.dependabot.com/umee-network/umee/issues/1110">#1110</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/1132">#1132</a>)</li>
<li><a href="https://github.com/umee-network/umee/commit/b666930fdc4831b3de59f3ac3cf674838e910a61"><code>b666930</code></a> feat!: price-feeder: add the ability to configure asset deviation thresholds ...</li>
<li><a href="https://github.com/umee-network/umee/commit/cf4ea5c7bf95f2de017bfe6a7ef7498e0c15e604"><code>cf4ea5c</code></a> feat: add cache for chain height  (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/1069">#1069</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/1081">#1081</a>)</li>
<li><a href="https://github.com/umee-network/umee/commit/90b8ee3fd56157460f2431c22c051278bb0a8ae8"><code>90b8ee3</code></a> fix: gorelease from 1.18 compat to 1.17 (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/1059">#1059</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/1060">#1060</a>)</li>
<li><a href="https://github.com/umee-network/umee/commit/e50d61728dae0399c533356f367c6ae9b33d6759"><code>e50d617</code></a> feat!: cache get params for 200 blocks (backport <a href="https://github-redirect.dependabot.com/umee-network/umee/issues/1050">#1050</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/1054">#1054</a>)</li>
<li><a href="https://github.com/umee-network/umee/commit/643f58c38a657fa024c1785eb2a7ddf54bb9596f"><code>643f58c</code></a> build(deps): Bump gopkg.in/yaml.v3 from 3.0.0 to 3.0.1 (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/983">#983</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/994">#994</a>)</li>
<li><a href="https://github.com/umee-network/umee/commit/f2961940dce26c9c5b64fed2083593cdfc299374"><code>f296194</code></a> build(deps): Bump github.com/spf13/viper from 1.11.0 to 1.12.0 (backport <a href="https://github-redirect.dependabot.com/umee-network/umee/issues/972">#972</a>...</li>
<li><a href="https://github.com/umee-network/umee/commit/762d637dd70b87682959bb23dd5e7352e5d5319d"><code>762d637</code></a> chore: price-feeder: oracle package cleanup (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/978">#978</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/980">#980</a>)</li>
<li><a href="https://github.com/umee-network/umee/commit/72a9d1456c0067022776753774b4de52c400e58c"><code>72a9d14</code></a> chore: update price feeder releaser to use 1.18 (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/976">#976</a>) (<a href="https://github-redirect.dependabot.com/umee-network/umee/issues/979">#979</a>)</li>
<li><a href="https://github.com/umee-network/umee/commit/fc5fdf3de9a5ca0f91a6b7eb87f218997659a976"><code>fc5fdf3</code></a> build(deps): Bump github.com/ory/dockertest/v3 from 3.9.0 to 3.9.1 (backport ...</li>
<li>Additional commits viewable in <a href="https://github.com/umee-network/umee/compare/price-feeder/v0.2.1...price-feeder/v0.2.4">compare view</a></li>
</ul>
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=github.com/umee-network/umee/price-feeder&package-manager=go_modules&previous-version=0.2.1&new-version=0.2.4)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

</details>

(cherry picked from commit d9fa470)
  • Loading branch information
dependabot[bot] authored and mergify[bot] committed Jul 26, 2022
1 parent 38edbd0 commit 1db5c49
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 772 deletions.
2 changes: 1 addition & 1 deletion cmd/peggo/orchestrator.go
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ func getOrchestratorCmd() *cobra.Command {
return err
}

if err := o.SubscribeSymbols(oracle.BaseSymbolETH); err != nil {
if err := o.SubscribeSymbols(oracle.SymbolETH); err != nil {
return err
}

Expand Down
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/umee-network/peggo
go 1.17

require (
github.com/Gravity-Bridge/Gravity-Bridge/module v1.4.2-0.20220317234142-1c674cbc83ff
github.com/Gravity-Bridge/Gravity-Bridge/module v1.4.2-0.20220517191451-8d660b559b07
github.com/avast/retry-go v3.0.0+incompatible
github.com/cosmos/cosmos-sdk v0.45.5
github.com/cosmos/go-bip39 v1.0.0
Expand All @@ -22,7 +22,7 @@ require (
github.com/spf13/viper v1.12.0
github.com/stretchr/testify v1.8.0
github.com/tendermint/tendermint v0.34.19
github.com/umee-network/umee/price-feeder v0.2.1
github.com/umee-network/umee/price-feeder v0.2.4
github.com/umee-network/umee/v2 v2.0.2
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211
Expand Down Expand Up @@ -50,7 +50,7 @@ require (
github.com/Workiva/go-datastructures v1.0.53 // indirect
github.com/alexkohler/prealloc v1.0.0 // indirect
github.com/alingse/asasalint v0.0.10 // indirect
github.com/armon/go-metrics v0.3.10 // indirect
github.com/armon/go-metrics v0.3.11 // indirect
github.com/ashanbrown/forbidigo v1.3.0 // indirect
github.com/ashanbrown/makezero v1.1.1 // indirect
github.com/beorn7/perks v1.0.1 // indirect
Expand Down Expand Up @@ -108,7 +108,7 @@ require (
github.com/go-ole/go-ole v1.2.6 // indirect
github.com/go-playground/locales v0.14.0 // indirect
github.com/go-playground/universal-translator v0.18.0 // indirect
github.com/go-playground/validator/v10 v10.10.1 // indirect
github.com/go-playground/validator/v10 v10.11.0 // indirect
github.com/go-stack/stack v1.8.0 // indirect
github.com/go-toolsmith/astcast v1.0.0 // indirect
github.com/go-toolsmith/astcopy v1.0.0 // indirect
Expand Down Expand Up @@ -214,9 +214,9 @@ require (
github.com/phayes/checkstyle v0.0.0-20170904204023-bfd46e6a821d // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/polyfloyd/go-errorlint v1.0.0 // indirect
github.com/prometheus/client_golang v1.12.1 // indirect
github.com/prometheus/client_golang v1.12.2 // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.33.0 // indirect
github.com/prometheus/common v0.34.0 // indirect
github.com/prometheus/procfs v0.7.3 // indirect
github.com/quasilyte/go-ruleguard v0.3.16-0.20220213074421-6aa060fab41a // indirect
github.com/quasilyte/gogrep v0.0.0-20220120141003-628d8b3623b5 // indirect
Expand Down
745 changes: 12 additions & 733 deletions go.sum

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions mocks/gravity_queryclient.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion orchestrator/main_loops.go
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ func (p *gravityOrchestrator) BatchRequesterLoop(ctx context.Context) (err error
return fmt.Errorf("failed to get Ethereum gas estimate: %w", err)
}

usdEthPrice, err := p.oracle.GetPrice(oracle.BaseSymbolETH)
usdEthPrice, err := p.oracle.GetPrice(oracle.SymbolETH)
if err != nil {
return err
}
Expand Down
32 changes: 32 additions & 0 deletions orchestrator/oracle/currency.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package oracle

import (
"strings"

umeedpftypes "github.com/umee-network/umee/price-feeder/oracle/types"
)

const (
symbolUSD = "USD"
symbolUSDT = "USDT"
symbolDAI = "DAI"
)

var (
quoteStablecoins = []string{symbolUSD, symbolUSDT, symbolDAI}
)

// GetStablecoinsCurrencyPair return the currency pair of that symbol quoted by some
// stablecoins.
func GetStablecoinsCurrencyPair(baseSymbol string) []umeedpftypes.CurrencyPair {
currencyPairs := make([]umeedpftypes.CurrencyPair, len(quoteStablecoins))

for i, quote := range quoteStablecoins {
currencyPairs[i] = umeedpftypes.CurrencyPair{
Base: strings.ToUpper(baseSymbol),
Quote: quote,
}
}

return currencyPairs
}
62 changes: 32 additions & 30 deletions orchestrator/oracle/oracle.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package oracle
import (
"context"
"fmt"
"strings"
"sync"
"time"

Expand All @@ -17,11 +16,13 @@ import (
ummedpfsync "github.com/umee-network/umee/price-feeder/pkg/sync"
)

// We define tickerTimeout as the minimum timeout between each oracle loop.
const (
tickerTimeout = 1000 * time.Millisecond
// tickerTimeout is the minimum timeout between each oracle loop.
tickerTimeout = 1000 * time.Millisecond
// availablePairsReload is the amount of time to reload the providers available pairs.
availablePairsReload = 24 * time.Hour
BaseSymbolETH = "ETH"
// SymbolETH refers to the ethereum symbol.
SymbolETH = "ETH"
)

// Oracle implements the core component responsible for fetching exchange rates
Expand All @@ -34,6 +35,9 @@ type Oracle struct {
providers map[string]*Provider // providerName => Provider
prices map[string]sdk.Dec // baseSymbol => price ex.: UMEE, ETH => sdk.Dec
subscribedBaseSymbols map[string]struct{} // baseSymbol => nothing
// this field could be calculated each time by looping providers.subscribedPairs
// but the time to process is not worth the amount of memory
providerSubscribedPairs map[string][]umeedpftypes.CurrencyPair // providerName => []CurrencyPair
}

// Provider wraps the umee provider interface.
Expand All @@ -59,16 +63,23 @@ func New(ctx context.Context, logger zerolog.Logger, providersName []string) (*O
}
}

oracle := &Oracle{
logger: logger.With().Str("module", "oracle").Logger(),
closer: ummedpfsync.NewCloser(),
providers: providers,
subscribedBaseSymbols: map[string]struct{}{},
o := &Oracle{
logger: logger.With().Str("module", "oracle").Logger(),
closer: ummedpfsync.NewCloser(),
providers: providers,
subscribedBaseSymbols: map[string]struct{}{},
providerSubscribedPairs: map[string][]umeedpftypes.CurrencyPair{},
}
oracle.loadAvailablePairs()
go oracle.start(ctx)
o.loadAvailablePairs()
if err := o.subscribeProviders([]umeedpftypes.CurrencyPair{
{Base: symbolUSDT, Quote: symbolUSD},
{Base: symbolDAI, Quote: symbolUSD},
}); err != nil {
return nil, err
}
go o.start(ctx)

return oracle, nil
return o, nil
}

// GetPrices returns the price for the provided base symbols.
Expand Down Expand Up @@ -166,6 +177,7 @@ func (o *Oracle) subscribeProviders(currencyPairs []umeedpftypes.CurrencyPair) e

for _, pair := range pairsToSubscribe {
provider.subscribedPairs[pair.String()] = pair
o.providerSubscribedPairs[providerName] = append(o.providerSubscribedPairs[providerName], pair)

o.logger.Debug().Str("provider_name", providerName).
Str("pair_symbol", pair.String()).
Expand Down Expand Up @@ -237,7 +249,7 @@ func (o *Oracle) setPrices() error {
for providerName, provider := range o.providers {
providerName := providerName
provider := provider
subscribedPrices := umeedpftypes.MapPairsToSlice(provider.subscribedPairs)
subscribedPrices := o.providerSubscribedPairs[providerName]

g.Go(func() error {
var (
Expand Down Expand Up @@ -277,7 +289,13 @@ func (o *Oracle) setPrices() error {
o.logger.Debug().Err(err).Msg("failed to get ticker prices from provider")
}

computedPrices, err := ummedpforacle.GetComputedPrices(o.logger, providerCandles, providerPrices)
computedPrices, err := ummedpforacle.GetComputedPrices(
o.logger,
providerCandles,
providerPrices,
o.providerSubscribedPairs,
make(map[string]sdk.Dec, 0), // uses default deviation
)
if err != nil {
return err
}
Expand All @@ -293,19 +311,3 @@ func (o *Oracle) tick() error {

return nil
}

// GetStablecoinsCurrencyPair return the currency pair of that symbol quoted by some
// stablecoins.
func GetStablecoinsCurrencyPair(baseSymbol string) []umeedpftypes.CurrencyPair {
quotes := []string{"USD", "USDT", "DAI"}
currencyPairs := make([]umeedpftypes.CurrencyPair, len(quotes))

for i, quote := range quotes {
currencyPairs[i] = umeedpftypes.CurrencyPair{
Base: strings.ToUpper(baseSymbol),
Quote: quote,
}
}

return currencyPairs
}
2 changes: 1 addition & 1 deletion orchestrator/relayer/batch_relaying.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ func (s *gravityRelayer) IsBatchProfitable(
}

// First we get the cost of the transaction in USD
usdEthPrice, err := s.oracle.GetPrice(oracle.BaseSymbolETH)
usdEthPrice, err := s.oracle.GetPrice(oracle.SymbolETH)
if err != nil {
s.logger.Err(err).Msg("failed to get ETH price")
return false
Expand Down

0 comments on commit 1db5c49

Please sign in to comment.