nautilus_kraken/common/
urls.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2025 Nautech Systems Pty Ltd. All rights reserved.
3//  https://nautechsystems.io
4//
5//  Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6//  You may not use this file except in compliance with the License.
7//  You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9//  Unless required by applicable law or agreed to in writing, software
10//  distributed under the License is distributed on an "AS IS" BASIS,
11//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//  See the License for the specific language governing permissions and
13//  limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16//! URL builders for Kraken HTTP and WebSocket endpoints.
17
18use super::{
19    consts::{
20        KRAKEN_FUTURES_HTTP_URL, KRAKEN_FUTURES_TESTNET_HTTP_URL, KRAKEN_FUTURES_TESTNET_WS_URL,
21        KRAKEN_FUTURES_WS_URL, KRAKEN_SPOT_HTTP_URL, KRAKEN_SPOT_WS_PRIVATE_URL,
22        KRAKEN_SPOT_WS_PUBLIC_URL,
23    },
24    enums::{KrakenEnvironment, KrakenProductType},
25};
26
27pub fn get_http_base_url(
28    product_type: KrakenProductType,
29    environment: KrakenEnvironment,
30) -> &'static str {
31    match (product_type, environment) {
32        (KrakenProductType::Spot, _) => KRAKEN_SPOT_HTTP_URL,
33        (KrakenProductType::Futures, KrakenEnvironment::Mainnet) => KRAKEN_FUTURES_HTTP_URL,
34        (KrakenProductType::Futures, KrakenEnvironment::Testnet) => KRAKEN_FUTURES_TESTNET_HTTP_URL,
35    }
36}
37
38pub fn get_ws_public_url(
39    product_type: KrakenProductType,
40    environment: KrakenEnvironment,
41) -> &'static str {
42    match (product_type, environment) {
43        (KrakenProductType::Spot, _) => KRAKEN_SPOT_WS_PUBLIC_URL,
44        (KrakenProductType::Futures, KrakenEnvironment::Mainnet) => KRAKEN_FUTURES_WS_URL,
45        (KrakenProductType::Futures, KrakenEnvironment::Testnet) => KRAKEN_FUTURES_TESTNET_WS_URL,
46    }
47}
48
49pub fn get_ws_private_url(
50    product_type: KrakenProductType,
51    environment: KrakenEnvironment,
52) -> &'static str {
53    match (product_type, environment) {
54        (KrakenProductType::Spot, _) => KRAKEN_SPOT_WS_PRIVATE_URL,
55        (KrakenProductType::Futures, KrakenEnvironment::Mainnet) => KRAKEN_FUTURES_WS_URL,
56        (KrakenProductType::Futures, KrakenEnvironment::Testnet) => KRAKEN_FUTURES_TESTNET_WS_URL,
57    }
58}