From 94085aed0004e8c092cb3e89d97095549ac61668 Mon Sep 17 00:00:00 2001 From: Starsquid <108214377+starsquidnodes@users.noreply.github.com> Date: Sat, 14 Sep 2024 11:54:54 +0200 Subject: [PATCH] Add rewrites from MATIC to POL --- oracle/provider/binance.go | 20 +++++++++++++++++++- oracle/provider/bitfinex.go | 5 +++-- oracle/provider/bitget.go | 3 ++- oracle/provider/bybit.go | 20 +++++++++++++++++++- oracle/provider/gate.go | 3 ++- oracle/provider/huobi.go | 3 ++- oracle/provider/kraken.go | 9 +++++---- oracle/provider/kucoin.go | 3 ++- oracle/provider/lbank.go | 16 +++++++++++++++- oracle/provider/mexc.go | 3 ++- oracle/provider/okx.go | 16 +++++++++++++++- oracle/provider/phemex.go | 16 +++++++++++++++- 12 files changed, 101 insertions(+), 16 deletions(-) diff --git a/oracle/provider/binance.go b/oracle/provider/binance.go index 3ba5d5c..65ffc8a 100644 --- a/oracle/provider/binance.go +++ b/oracle/provider/binance.go @@ -79,7 +79,7 @@ func NewBinanceProvider( } availablePairs, _ := provider.GetAvailablePairs() - provider.setPairs(pairs, availablePairs, nil) + provider.setPairs(pairs, availablePairs, currencyPairToBinanceSymbol) go startPolling(provider, provider.endpoints.PollInterval, logger) return provider, nil @@ -140,3 +140,21 @@ func (p *BinanceProvider) GetAvailablePairs() (map[string]struct{}, error) { return symbols, nil } + +func currencyPairToBinanceSymbol(pair types.CurrencyPair) string { + mapping := map[string]string{ + "MATIC": "POL", + } + + base, found := mapping[pair.Base] + if !found { + base = pair.Base + } + + quote, found := mapping[pair.Quote] + if !found { + quote = pair.Quote + } + + return base + quote +} diff --git a/oracle/provider/bitfinex.go b/oracle/provider/bitfinex.go index 159228f..ba424f8 100644 --- a/oracle/provider/bitfinex.go +++ b/oracle/provider/bitfinex.go @@ -134,8 +134,9 @@ func (p *BitfinexProvider) GetAvailablePairs() (map[string]struct{}, error) { func currencyPairToBitfinexSymbol(pair types.CurrencyPair) string { mapping := map[string]string{ - "LUNC": "LUNA", - "LUNA": "LUNA2", + "LUNC": "LUNA", + "LUNA": "LUNA2", + "MATIC": "POL", } base, found := mapping[pair.Base] diff --git a/oracle/provider/bitget.go b/oracle/provider/bitget.go index 1c3444d..da82f56 100644 --- a/oracle/provider/bitget.go +++ b/oracle/provider/bitget.go @@ -129,7 +129,8 @@ func (p *BitgetProvider) GetAvailablePairs() (map[string]struct{}, error) { func currencyPairToBitgetSymbol(pair types.CurrencyPair) string { mapping := map[string]string{ - "AXL": "WAXL", + "AXL": "WAXL", + "MATIC": "POL", } base, found := mapping[pair.Base] diff --git a/oracle/provider/bybit.go b/oracle/provider/bybit.go index eda1f5c..344b918 100644 --- a/oracle/provider/bybit.go +++ b/oracle/provider/bybit.go @@ -60,7 +60,7 @@ func NewBybitProvider( ) availablePairs, _ := provider.GetAvailablePairs() - provider.setPairs(pairs, availablePairs, nil) + provider.setPairs(pairs, availablePairs, currencyPairToBybitSymbol) go startPolling(provider, provider.endpoints.PollInterval, logger) return provider, nil @@ -121,3 +121,21 @@ func (p *BybitProvider) GetAvailablePairs() (map[string]struct{}, error) { return symbols, nil } + +func currencyPairToBybitSymbol(pair types.CurrencyPair) string { + mapping := map[string]string{ + "MATIC": "POL", + } + + base, found := mapping[pair.Base] + if !found { + base = pair.Base + } + + quote, found := mapping[pair.Quote] + if !found { + quote = pair.Quote + } + + return base + quote +} diff --git a/oracle/provider/gate.go b/oracle/provider/gate.go index 8328dd7..750c634 100644 --- a/oracle/provider/gate.go +++ b/oracle/provider/gate.go @@ -114,7 +114,8 @@ func (p *GateProvider) GetAvailablePairs() (map[string]struct{}, error) { func currencyPairToGateSymbol(pair types.CurrencyPair) string { mapping := map[string]string{ - "AXL": "WAXL", + "AXL": "WAXL", + "MATIC": "POL", } base, found := mapping[pair.Base] diff --git a/oracle/provider/huobi.go b/oracle/provider/huobi.go index c9ba8f7..5ec8c4a 100644 --- a/oracle/provider/huobi.go +++ b/oracle/provider/huobi.go @@ -120,7 +120,8 @@ func (p *HuobiProvider) GetAvailablePairs() (map[string]struct{}, error) { func currencyPairToHuobiSymbol(pair types.CurrencyPair) string { mapping := map[string]string{ - "AXL": "WAXL", + "AXL": "WAXL", + "MATIC": "POL", } base, found := mapping[pair.Base] diff --git a/oracle/provider/kraken.go b/oracle/provider/kraken.go index f72da0a..7e07d4f 100644 --- a/oracle/provider/kraken.go +++ b/oracle/provider/kraken.go @@ -176,10 +176,11 @@ func currencyPairToKrakenSymbol(pair types.CurrencyPair) string { "USDJPY": "ZUSDZJPY", } mapping := map[string]string{ - "AXL": "WAXL", - "BTC": "XBT", - "LUNC": "LUNA", - "LUNA": "LUNA2", + "AXL": "WAXL", + "BTC": "XBT", + "LUNC": "LUNA", + "LUNA": "LUNA2", + "MATIC": "POL", } base, found := mapping[pair.Base] diff --git a/oracle/provider/kucoin.go b/oracle/provider/kucoin.go index ef2396b..af1782a 100644 --- a/oracle/provider/kucoin.go +++ b/oracle/provider/kucoin.go @@ -124,7 +124,8 @@ func (p *KucoinProvider) GetAvailablePairs() (map[string]struct{}, error) { func currencyPairToKucoinSymbol(pair types.CurrencyPair) string { mapping := map[string]string{ - "AXL": "WAXL", + "AXL": "WAXL", + "MATIC": "POL", } base, found := mapping[pair.Base] diff --git a/oracle/provider/lbank.go b/oracle/provider/lbank.go index 9feda34..c651f19 100644 --- a/oracle/provider/lbank.go +++ b/oracle/provider/lbank.go @@ -123,5 +123,19 @@ func (p *LbankProvider) GetAvailablePairs() (map[string]struct{}, error) { } func currencyPairToLbankSymbol(pair types.CurrencyPair) string { - return strings.ToLower(pair.Join("_")) + mapping := map[string]string{ + "MATIC": "POL", + } + + base, found := mapping[pair.Base] + if !found { + base = pair.Base + } + + quote, found := mapping[pair.Quote] + if !found { + quote = pair.Quote + } + + return strings.ToLower(base + "_" + quote) } diff --git a/oracle/provider/mexc.go b/oracle/provider/mexc.go index 56aaabb..0d1d57a 100644 --- a/oracle/provider/mexc.go +++ b/oracle/provider/mexc.go @@ -114,7 +114,8 @@ func (p *MexcProvider) GetAvailablePairs() (map[string]struct{}, error) { func currencyPairToMexcSymbol(pair types.CurrencyPair) string { mapping := map[string]string{ - "AXL": "WAXL", + "AXL": "WAXL", + "MATIC": "POL", } base, found := mapping[pair.Base] diff --git a/oracle/provider/okx.go b/oracle/provider/okx.go index 5ebd0ee..8f44097 100644 --- a/oracle/provider/okx.go +++ b/oracle/provider/okx.go @@ -128,5 +128,19 @@ func (p *OkxProvider) GetAvailablePairs() (map[string]struct{}, error) { } func currencyPairToOkxSymbol(pair types.CurrencyPair) string { - return pair.Join("-") + mapping := map[string]string{ + "MATIC": "POL", + } + + base, found := mapping[pair.Base] + if !found { + base = pair.Base + } + + quote, found := mapping[pair.Quote] + if !found { + quote = pair.Quote + } + + return base + "-" + quote } diff --git a/oracle/provider/phemex.go b/oracle/provider/phemex.go index c05caad..54ec864 100644 --- a/oracle/provider/phemex.go +++ b/oracle/provider/phemex.go @@ -214,5 +214,19 @@ func (p *PhemexProvider) GetAvailablePairs() (map[string]struct{}, error) { } func currencyPairToPhemexSymbol(pair types.CurrencyPair) string { - return "s" + pair.String() + mapping := map[string]string{ + "MATIC": "POL", + } + + base, found := mapping[pair.Base] + if !found { + base = pair.Base + } + + quote, found := mapping[pair.Quote] + if !found { + quote = pair.Quote + } + + return "s" + base + quote }