Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions cmd/dcrdata/public/images/coinex-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions cmd/dcrdata/public/images/kucoin-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 5 additions & 2 deletions cmd/dcrdata/public/js/controllers/market_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,15 @@ const prettyDurations = {
}
const exchangeLinks = {
CurrencyPairDCRBTC: {
dcrdex: 'https://dex.decred.org'
dcrdex: 'https://dex.decred.org',
coinex: 'https://www.coinex.com/en/exchange/DCR-BTC'
},
CurrencyPairDCRUSDT: {
binance: 'https://www.binance.com/en/trade/DCR_USDT',
dcrdex: 'https://dex.decred.org',
mexc: 'https://www.mexc.com/exchange/DCR_USDT'
mexc: 'https://www.mexc.com/exchange/DCR_USDT',
kucoin: 'https://www.kucoin.com/trade/DCR-USDT',
coinex: 'https://www.coinex.com/en/exchange/DCR-USDT'
}
}
const CurrencyPairDCRUSDT = 'DCR-USDT'
Expand Down
8 changes: 8 additions & 0 deletions cmd/dcrdata/public/scss/icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,11 @@
.exchange-logo.mexc {
background: url("/images/mexc-logo.svg") no-repeat;
}

.exchange-logo.kucoin {
background: url("/images/kucoin-logo.svg") no-repeat;
}

.exchange-logo.coinex {
background: url("/images/coinex-logo.svg") no-repeat;
}
4 changes: 2 additions & 2 deletions cmd/dcrdata/views/extras.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<link rel="preload" href="/images/connected.svg?x=65tv3" as="image" type="image/svg+xml" />
<link rel="preload" href="/images/disconnected.svg?x=65tv3" as="image" type="image/svg+xml" />

<link href="/dist/css/style.b889c8b9b6831cd5.css" rel="stylesheet">
<link href="/dist/css/style.0fa8da7a4d68be40.css" rel="stylesheet">

<script src="/js/vendor/turbolinks.min.js?v=65DCG"></script>
</head>
Expand Down Expand Up @@ -193,7 +193,7 @@
data-turbolinks-suppress-warning
></script>
<script
src="/dist/js/app.a882ac4b6d92599f.bundle.js"
src="/dist/js/app.5d8354742872977b.bundle.js"
data-turbolinks-eval="false"
data-turbolinks-suppress-warning
></script>
Expand Down
19 changes: 6 additions & 13 deletions exchanges/bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -819,22 +819,15 @@ func (bot *ExchangeBot) cachedChartVersion(chartId string) int {

// processState is a helper function to process a slice of ExchangeState into a
// price, and optionally a volume sum, and perform some cleanup along the way.
// If volumeAveraged is false, all exchanges are given equal weight in the avg.
// If exchange is invalid, a bool false is returned as a last return value.
func (bot *ExchangeBot) processState(token, code string, states map[CurrencyPair]*ExchangeState, volumeAveraged bool) (float64, float64, bool) {
func (bot *ExchangeBot) processState(token, code string, states map[CurrencyPair]*ExchangeState) (float64, float64, bool) {
oldestValid := time.Now().Add(-bot.RequestExpiry)
if bot.Exchanges[token].LastUpdate().Before(oldestValid) {
return 0, 0, false
}

var priceAccumulator, volSum float64
for currencyPair, state := range states {
volume := 1.0
if volumeAveraged {
volume = state.Volume
}
volSum += volume

// Convert price to bot.Index.
price := state.Price
switch currencyPair {
Expand All @@ -843,13 +836,13 @@ func (bot *ExchangeBot) processState(token, code string, states map[CurrencyPair
case CurrencyPairDCRUSDT:
price = bot.indexPrice(USDTIndex, code) * price
}
if price == 0 { // missing index price for currencyPair.
return 0, 0, false
if price == 0 {
continue // missing index price for currencyPair so let's skip this one.
}

priceAccumulator += volume * price
volSum += state.Volume
priceAccumulator += state.Volume * price
}

if volSum == 0 {
return 0, 0, true
}
Expand Down Expand Up @@ -927,7 +920,7 @@ func (bot *ExchangeBot) updateIndices(update *IndexUpdate) error {
func (bot *ExchangeBot) dcrPriceAndVolume(code string) (float64, float64) {
var dcrPrice, volume, nSources float64
for token, xcStates := range bot.currentState.DCRExchanges {
processedDcrPrice, processedVolume, ok := bot.processState(token, code, xcStates, true)
processedDcrPrice, processedVolume, ok := bot.processState(token, code, xcStates)
if !ok {
continue
}
Expand Down
Loading