Skip to content

Commit

Permalink
feat: New example config for small cap assets (#1768)
Browse files Browse the repository at this point in the history
* New config

* fix multi provider conversions

---------

Co-authored-by: Adam Wozniak <[email protected]>
  • Loading branch information
rbajollari and adamewozniak authored Jan 31, 2023
1 parent 9ebde6a commit 8ac04d9
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 13 deletions.
1 change: 1 addition & 0 deletions price-feeder/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ var (
"BTC": {},
"ETH": {},
"ATOM": {},
"OSMO": {},
}
)

Expand Down
26 changes: 14 additions & 12 deletions price-feeder/oracle/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func ConvertCandlesToUSD(
}

conversionRates := make(map[string]sdk.Dec)
requiredConversions := make(map[provider.Name]types.CurrencyPair)
requiredConversions := make(map[provider.Name][]types.CurrencyPair)

for pairProviderName, pairs := range providerPairs {
for _, pair := range pairs {
Expand Down Expand Up @@ -103,23 +103,25 @@ func ConvertCandlesToUSD(
}

conversionRates[pair.Quote] = cvRate
requiredConversions[pairProviderName] = pair
requiredConversions[pairProviderName] = append(requiredConversions[pairProviderName], pair)
}
}
}

// Convert assets to USD.
for provider, assetMap := range candles {
conversionRate, ok := conversionRates[requiredConversions[provider].Quote]
if !ok {
continue
}
for asset, assetCandles := range assetMap {
if requiredConversions[provider].Base == asset {
for i := range assetCandles {
assetCandles[i].Price = assetCandles[i].Price.Mul(
conversionRate,
)
for _, requiredConversion := range requiredConversions[provider] {
conversionRate, ok := conversionRates[requiredConversion.Quote]
if !ok {
continue
}
for asset, assetCandles := range assetMap {
if requiredConversion.Base == asset {
for i := range assetCandles {
assetCandles[i].Price = assetCandles[i].Price.Mul(
conversionRate,
)
}
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion price-feeder/oracle/provider/osmosisv2.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,5 +353,5 @@ func (p *OsmosisV2Provider) GetAvailablePairs() (map[string]struct{}, error) {
// currencyPairToOsmosisV2Pair receives a currency pair and return osmosisv2
// ticker symbol atomusdt@ticker.
func currencyPairToOsmosisV2Pair(cp types.CurrencyPair) string {
return strings.ToUpper(cp.Base + "/" + cp.Quote)
return cp.Base + "/" + cp.Quote
}
124 changes: 124 additions & 0 deletions price-feeder/price-feeder.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,34 @@ threshold = "2"
base = "WBTC"
threshold = "1.5"

[[deviation_thresholds]]
base = "BNB"
threshold = "2"

[[deviation_thresholds]]
base = "JUNO"
threshold = "2"

[[deviation_thresholds]]
base = "OSMO"
threshold = "2"

[[deviation_thresholds]]
base = "BTC"
threshold = "1.5"

[[deviation_thresholds]]
base = "stATOM"
threshold = "2"

[[deviation_thresholds]]
base = "stOSMO"
threshold = "2"

[[deviation_thresholds]]
base = "IST"
threshold = "2"

[[currency_pairs]]
base = "UMEE"
providers = [
Expand Down Expand Up @@ -120,6 +148,102 @@ providers = [
]
quote = "USDT"

[[currency_pairs]]
base = "JUNO"
providers = [
"kraken",
]
quote = "USD"

[[currency_pairs]]
base = "JUNO"
providers = [
"bitget",
]
quote = "USDT"

[[currency_pairs]]
base = "JUNO"
providers = [
"osmosisv2",
]
quote = "ATOM"

[[currency_pairs]]
base = "CRO"
providers = [
"crypto",
"bitget",
"okx",
]
quote = "USDT"

[[currency_pairs]]
base = "BNB"
providers = [
"binanceus",
"bitget",
"okx",
]
quote = "USDT"

[[currency_pairs]]
base = "OSMO"
providers = [
"osmosisv2",
]
quote = "ATOM"

[[currency_pairs]]
base = "OSMO"
providers = [
"bitget",
]
quote = "USDT"

[[currency_pairs]]
base = "OSMO"
providers = [
"crypto",
]
quote = "USD"

[[currency_pairs]]
base = "BTC"
providers = [
"coinbase",
]
quote = "USD"

[[currency_pairs]]
base = "BTC"
providers = [
"huobi",
"kraken",
]
quote = "USDT"

[[currency_pairs]]
base = "stATOM"
providers = [
"osmosisv2",
]
quote = "ATOM"

[[currency_pairs]]
base = "stOSMO"
providers = [
"osmosisv2",
]
quote = "OSMO"

[[currency_pairs]]
base = "IST"
providers = [
"osmosisv2",
]
quote = "OSMO"

[account]
address = "umee15nejfgcaanqpw25ru4arvfd0fwy6j8clccvwx4"
chain_id = "umee-local-testnet"
Expand Down

0 comments on commit 8ac04d9

Please sign in to comment.