From 42603a974d0c15b1274ab0171eef5698ade2f780 Mon Sep 17 00:00:00 2001 From: jmacxx <47253594+jmacxx@users.noreply.github.com> Date: Mon, 19 Feb 2024 11:48:32 -0600 Subject: [PATCH] Add KuCoin exchange. --- gradle/libs.versions.toml | 3 +- .../bisq/price/spot/providers/KuCoin.java | 46 +++++++++++++++++++ .../bisq/price/spot/providers/KuCoinTest.java | 33 +++++++++++++ 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 src/main/java/bisq/price/spot/providers/KuCoin.java create mode 100644 src/test/java/bisq/price/spot/providers/KuCoinTest.java diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index def01f5..dc47cd0 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -29,6 +29,7 @@ known-xchange-coinone = { module = 'org.knowm.xchange:xchange-coinone', version. known-xchange-independentreserve = { module = 'org.knowm.xchange:xchange-independentreserve', version.ref = 'knowm-xchange-lib' } known-xchange-kraken = { module = 'org.knowm.xchange:xchange-kraken', version.ref = 'knowm-xchange-lib' } known-xchange-luno = { module = 'org.knowm.xchange:xchange-luno', version.ref = 'knowm-xchange-lib' } +known-xchange-kucoin = { module = 'org.knowm.xchange:xchange-kucoin', version.ref = 'knowm-xchange-lib' } known-xchange-mercadobitcoin = { module = 'org.knowm.xchange:xchange-mercadobitcoin', version.ref = 'knowm-xchange-lib' } known-xchange-paribu = { module = 'org.knowm.xchange:xchange-paribu', version.ref = 'knowm-xchange-lib' } logback-core = { module = 'ch.qos.logback:logback-core', version.ref = 'logback-lib' } @@ -45,7 +46,7 @@ knowm-xchange-libs = [ 'knowm-xchange-binance', 'known-xchange-bitfinex', 'known-xchange-bitflyer', 'known-xchange-bitstamp', 'known-xchange-btcmarkets', 'known-xchange-coinbasepro', 'known-xchange-coinone', - 'known-xchange-independentreserve', + 'known-xchange-independentreserve','known-xchange-kucoin', 'known-xchange-kraken', 'known-xchange-luno', 'known-xchange-mercadobitcoin', 'known-xchange-paribu' ] diff --git a/src/main/java/bisq/price/spot/providers/KuCoin.java b/src/main/java/bisq/price/spot/providers/KuCoin.java new file mode 100644 index 0000000..59c14b0 --- /dev/null +++ b/src/main/java/bisq/price/spot/providers/KuCoin.java @@ -0,0 +1,46 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.price.spot.providers; + +import bisq.price.spot.ExchangeRate; +import bisq.price.spot.ExchangeRateProvider; + +import org.knowm.xchange.kucoin.KucoinExchange; + +import org.springframework.core.env.Environment; +import org.springframework.stereotype.Component; + +import java.time.Duration; + +import java.util.Set; + +@Component +class KuCoin extends ExchangeRateProvider { + + public KuCoin(Environment env) { + super(env, "KUCOIN", "kucoin", Duration.ofMinutes(1)); + } + + @Override + public Set doGet() { + // Supported fiat: EUR, BRL, GBP + // Supported alts: - DASH, DCR, DOGE, ERG, ETC, ETH, LTC, UNO, XMR, ZEC + // Supported alts: - DAI, TUSD, USDC, USDT + return doGet(KucoinExchange.class); + } +} diff --git a/src/test/java/bisq/price/spot/providers/KuCoinTest.java b/src/test/java/bisq/price/spot/providers/KuCoinTest.java new file mode 100644 index 0000000..326b619 --- /dev/null +++ b/src/test/java/bisq/price/spot/providers/KuCoinTest.java @@ -0,0 +1,33 @@ +/* + * This file is part of Bisq. + * + * Bisq is free software: you can redistribute it and/or modify it + * under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or (at + * your option) any later version. + * + * Bisq is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public + * License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with Bisq. If not, see . + */ + +package bisq.price.spot.providers; + +import bisq.price.AbstractExchangeRateProviderTest; +import lombok.extern.slf4j.Slf4j; +import org.junit.jupiter.api.Test; +import org.springframework.core.env.StandardEnvironment; + +@Slf4j +public class KuCoinTest extends AbstractExchangeRateProviderTest { + + @Test + public void doGet_successfulCall() { + doGet_successfulCall(new KuCoin(new StandardEnvironment())); + } + +}