pub struct Swapkit { /* private fields */ }
Implementations§
Source§impl Swapkit
impl Swapkit
Sourcepub async fn get_supported_chains(&mut self) -> Result<SupportedChains>
pub async fn get_supported_chains(&mut self) -> Result<SupportedChains>
Retrieve a list of all the chains the API supports.
§Returns JSON Equivalent
{
"ETH": "1",
"AVAX": "43114",
"THOR": "thorchain-mainnet-v1",
"BTC": "bitcoin",
"LTC": "litecoin",
"BNB": "Binance-Chain-Tigris",
"BSC": "56",
"BCH": "bitcoincash",
"GAIA": "cosmoshub-4",
"DOGE": "dogecoin"
}
§Example
use swapkit_rs::Swapkit;
use dotenv;
use swapkit_rs::Configuration;
let swapkit_config = Configuration::new(None, dotenv::var("SWAPKIT_REFERER").unwrap().as_str(), dotenv::var("SWAPKIT_X_API_KEY").unwrap().as_str());
let mut swapkit = Swapkit::new(swapkit_config);
let supported_chains = swapkit.get_supported_chains().await.unwrap();
assert_ne!(supported_chains.get_chains().len(), 0);
§Errors
todo
Sourcepub async fn get_chains_with_details(&mut self) -> Result<ChainsWithDetails>
pub async fn get_chains_with_details(&mut self) -> Result<ChainsWithDetails>
Retrieve a list of all the chains the API supports with details.
§Returns JSON Equivalent
{
"chain": "AVAX",
"chainId": 43114,
"displayName": "Avalanche",
"symbol": "AVAX",
"logo": "https://static.thorswap.net/token-list/images/avax.avax.png",
"providers": [
"THORCHAIN",
"PANGOLIN"
],
"status": "active",
"category": "evm",
"evm": true,
"mainnet": true,
"defaultDecimals": 18,
"averageBlockTime": 3000,
"confirmationsRequired": 1,
"gasRate": null,
"gasAsset": {
"chain": "AVAX",
"symbol": "AVAX",
"identifier": "AVAX.AVAX",
"decimals": 18
},
}
§Example
use swapkit_rs::Swapkit;
use dotenv;
use swapkit_rs::Configuration;
let swapkit_config = Configuration::new(None, dotenv::var("SWAPKIT_REFERER").unwrap().as_str(), dotenv::var("SWAPKIT_X_API_KEY").unwrap().as_str());
let mut swapkit = Swapkit::new(swapkit_config);
let chains_with_details = swapkit.get_chains_with_details().await.unwrap();
assert_ne!(chains_with_details.get_chains().len(), 0);
§Errors
todo
Source§impl Swapkit
impl Swapkit
Sourcepub async fn get_gas_prices(&mut self) -> Result<GasPrices>
pub async fn get_gas_prices(&mut self) -> Result<GasPrices>
Retrieve the current gas prices.
§Returns JSON Equivalent
[
{
"asset": "THOR.RUNE",
"units": "tor",
"gas": 2000000,
"chainId": "thorchain-mainnet-v1",
"gasAsset": 0.02
}
]
§Example
use swapkit_rs::Swapkit;
use dotenv;
use swapkit_rs::Configuration;
let swapkit_config = Configuration::new(None, dotenv::var("SWAPKIT_REFERER").unwrap().as_str(), dotenv::var("SWAPKIT_X_API_KEY").unwrap().as_str());
let mut swapkit = Swapkit::new(swapkit_config);
let gas_prices = swapkit.get_gas_prices().await.unwrap();
assert_ne!(gas_prices.get_gas_prices().len(), 0);
§Errors
todo
Source§impl Swapkit
impl Swapkit
Sourcepub async fn get_available_assets_for_pool(&mut self, asset: &str) -> Result<()>
pub async fn get_available_assets_for_pool(&mut self, asset: &str) -> Result<()>
§Errors
Endpoint not returning a response.
Sourcepub async fn get_available_lending_assets(
&mut self,
) -> Result<Vec<LendingAsset>>
pub async fn get_available_lending_assets( &mut self, ) -> Result<Vec<LendingAsset>>
Retrieve a list of all the lending assets the API supports.
§Returns JSON Equivalent
[
{
"asset": "BTC.BTC",
"assetDepthAssetAmount": "1103.58594672",
"runeDepthAssetAmount": "10841279.17868466",
"loanCr": "200",
"loanCollateral": "1931.73698979",
"lendingAvailable": true,
"filledPercentage": "95.31",
"derivedDepthPercentage": "9497",
"ltvPercentage": "50.00"
}
]
§Example
use swapkit_rs::Swapkit;
use dotenv;
use swapkit_rs::Configuration;
let swapkit_config = Configuration::new(None, dotenv::var("SWAPKIT_REFERER").unwrap().as_str(), dotenv::var("SWAPKIT_X_API_KEY").unwrap().as_str());
let mut swapkit = Swapkit::new(swapkit_config);
let lending_assets = swapkit.get_available_lending_assets().await.unwrap();
assert_ne!(lending_assets.len(), 0);
§Errors
todo
Sourcepub async fn get_loans(&mut self, address: &str, asset: &str) -> Result<Loan>
pub async fn get_loans(&mut self, address: &str, asset: &str) -> Result<Loan>
Retrieve a loan for a given address and asset.
§Returns JSON Equivalent
{
"asset": "BTC.BTC",
"debtCurrent": "1764.0462",
"debtIssued": "1764.0462",
"debtRepaid": "0",
"collateralCurrent": "0.06489696",
"collateralDeposited": "0.06489696",
"collateralWithdrawn": "0",
"lastOpenHeight": 14876835,
"lastRepayHeight": 0,
"ltvPercentage": "39.53",
"owner": "bc1qzafz3f0h90u7n9j862uupaf5hpeydmhvpnzwzz"
}
§Example
use swapkit_rs::Swapkit;
use dotenv;
use swapkit_rs::Configuration;
let swapkit_config = Configuration::new(None, dotenv::var("SWAPKIT_REFERER").unwrap().as_str(), dotenv::var("SWAPKIT_X_API_KEY").unwrap().as_str());
let mut swapkit = Swapkit::new(swapkit_config);
let loan = swapkit.get_loans("bc1qzafz3f0h90u7n9j862uupaf5hpeydmhvpnzwzz", "BTC.BTC").await.unwrap();
assert_eq!(loan.get_asset(), "BTC.BTC".to_string());
§Errors
todo
Source§impl Swapkit
impl Swapkit
Sourcepub async fn get_supported_providers(&mut self) -> Result<SupportedProviders>
pub async fn get_supported_providers(&mut self) -> Result<SupportedProviders>
Retrieve a list of all the providers the API supports.
§Returns JSON Equivalent
[
"Thorchain"...
]
§Example
use swapkit_rs::Swapkit;
use dotenv;
use swapkit_rs::Configuration;
let swapkit_config = Configuration::new(None, dotenv::var("SWAPKIT_REFERER").unwrap().as_str(), dotenv::var("SWAPKIT_X_API_KEY").unwrap().as_str());
let mut swapkit = Swapkit::new(swapkit_config);
let supported_providers = swapkit.get_supported_providers().await.unwrap();
assert_ne!(supported_providers.get_providers().len(), 0);
§Errors
todo
Source§impl Swapkit
impl Swapkit
Sourcepub async fn get_request_a_swap_quote(
&mut self,
parameters: RequestASwapQuoteParams,
) -> Result<Quote>
pub async fn get_request_a_swap_quote( &mut self, parameters: RequestASwapQuoteParams, ) -> Result<Quote>
Retrieve a quote for a swap.
§Returns JSON Equivalent
{
"quoteId": "477981ae-eed8-4162-885b-3af7495fb8fb",
"routes": [
QuoteRoute
],
"sellAssetAmount": "1"
}
§Example
use swapkit_rs::Swapkit;
use dotenv;
use swapkit_rs::Configuration;
let swapkit_config = Configuration::new(None, dotenv::var("SWAPKIT_REFERER").unwrap().as_str(), dotenv::var("SWAPKIT_X_API_KEY").unwrap().as_str());
let mut swapkit = Swapkit::new(swapkit_config);
let quote = swapkit.get_request_a_swap_quote(RequestASwapQuoteParams {
sell_asset: "BTC.BTC".to_string(),
buy_asset: "ETH.AAVE-0X7FC66500C84A76AD7E9C93437BFC5AC33E2DDAE9".to_string(),
sell_amount: "1".to_string(),
sender_address: "bc1q7cyrfmck2ffu2ud3rn5l5a8yv6f0chkp0zpemf".to_string(),
recipient_address: "0x2bD63111C794B29809f5F7d85aD2Ba67DB7C5CA5".to_string(),
affiliate_address: None,
affiliate_basis_points: None,
is_affiliate_fee_flat: None,
slippage: None,
}).await.unwrap();
assert_ne!(quote.get_quote().len(), 0);
§Errors
todo
Sourcepub async fn get_request_a_borrow_quote(
&mut self,
parameters: RequestABorrowQuoteParams,
) -> Result<BorrowQuote>
pub async fn get_request_a_borrow_quote( &mut self, parameters: RequestABorrowQuoteParams, ) -> Result<BorrowQuote>
Retrieve a quote for a borrow.
§Returns JSON Equivalent
{
"inboundAddress": "bc1qpqkqxgln9qwahw76nyp3v9fqyc7zy252yhv2kc",
"inboundConfirmationBlocks": 1,
"inboundConfirmationSeconds": 600,
"outboundDelayBlocks": 58,
"outboundDelaySeconds": 348,
"fees": HashMap<String, Vec<QuoteFee>>,
"expiry": 1715973758,
"warning": "Do not cache this response. Do not send funds after the expiry.",
"notes": "First output should be to inbound_address, second output should be change back to self, third output should be OP_RETURN, limited to 80 bytes. Do not send below the dust threshold. Do not use exotic spend scripts, locks or address formats (P2WSH with Bech32 address format preferred).",
"dustThreshold": "10000",
"memo": "$+:BTC.BTC:bc1q7cyrfmck2ffu2ud3rn5l5a8yv6f0chkp0zpemf:1:t:100",
"expectedAmountOut": "0.49226113",
"expectedCollaterizationRatio": "20000",
"expectedCollateralDeposited": "0.98814537",
"expectedDebtIssued": "32909.635",
"recommendedMinAmountIn": "0.00025588",
"interestRate": 0,
"streamingSwapBlocks": 4,
"streamingSwapSeconds": 24,
"totalOpenLoanSeconds": 972,
"complete": true,
"expectedOutput": "0.49226113",
"expectedOutputMaxSlippage": "0.48981206965174129353",
"expectedOutputUSD": "30886.8363905783448903382",
"expectedOutputMaxSlippageUSD": "30733.1705378889003882495021603092742",
"timeEstimates": QuoteTimeEstimates,
"swaps": Vec<Vec<QuoteSwap>>,
"route": BorrowQuoteRoute,
"amountIn": "1",
"amountOut": "0.49226113",
"amountOutMin": "0.48981206965174129353",
"targetAddress": "bc1qpqkqxgln9qwahw76nyp3v9fqyc7zy252yhv2kc",
"recipientAddress": "bc1q7cyrfmck2ffu2ud3rn5l5a8yv6f0chkp0zpemf",
"assetIn": "BTC.BTC",
"assetOut": "BTC.BTC",
"estimatedTime": 1008,
"streamingSwap": StreamingSwap,
}
§Example
use swapkit_rs::Swapkit;
use dotenv;
use swapkit_rs::Configuration;
use swapkit_rs::RequestABorrowQuoteParams;
let swapkit_config = Configuration::new(None, dotenv::var("SWAPKIT_REFERER").unwrap().as_str(), dotenv::var("SWAPKIT_X_API_KEY").unwrap().as_str());
let mut swapkit = Swapkit::new(swapkit_config);
let quote = swapkit.get_request_a_borrow_quote(RequestABorrowQuoteParams {
asset_in: "BTC.BTC".to_string(),
asset_out: "BTC.BTC".to_string(),
slippage: "0.5".to_string(),
amount: "1".to_string(),
sender_address: "bc1q7cyrfmck2ffu2ud3rn5l5a8yv6f0chkp0zpemf".to_string(),
recipient_address: "bc1q7cyrfmck2ffu2ud3rn5l5a8yv6f0chkp0zpemf".to_string(),
}).await.unwrap();
assert_eq!(quote.get_asset_in(), "BTC.BTC".to_string());
§Errors
todo
Sourcepub async fn get_request_a_repay_quote(
&mut self,
parameters: RequestARepayQuoteParams,
) -> Result<RepayQuote>
pub async fn get_request_a_repay_quote( &mut self, parameters: RequestARepayQuoteParams, ) -> Result<RepayQuote>
Retrieve a quote for a repay.
§Returns JSON Equivalent
{
"inboundAddress": "bc1qpqkqxgln9qwahw76nyp3v9fqyc7zy252yhv2kc",
"inboundConfirmationBlocks": 1,
"inboundConfirmationSeconds": 600,
"outboundDelayBlocks": 0,
"outboundDelaySeconds": 0,
"fees": Hashmap<String, Vec<QuoteFee>>
"expiry": 1715977820,
"warning": "Do not cache this response. Do not send funds after the expiry.",
"notes": "First output should be to inbound_address, second output should be change back to self, third output should be OP_RETURN, limited to 80 bytes. Do not send below the dust threshold. Do not use exotic spend scripts, locks or address formats (P2WSH with Bech32 address format preferred).",
"dustThreshold": "10000",
"recommendedMinAmountIn": "0.00031104",
"memo": "$-:BTC.BTC:bc1qzafz3f0h90u7n9j862uupaf5hpeydmhvpnzwzz:1",
"expectedAmountOut": "0.00000000",
"expectedAmountIn": "0.00013192",
"expectedCollateralWithdrawn": "0.00000000",
"expectedDebtRepaid": "8.82417067",
"streamingSwapBlocks": 2,
"streamingSwapSeconds": 12,
"totalRepaySeconds": 612,
"collateralCurrent": "0.06489696",
"repayAssetAmount": "0.00019534",
"repayAssetAmountUSD": "12.25657330",
"timeEstimates": QuoteTimeEstimates,
"streamingSwap": StreamingSwap
}
§Example
use swapkit_rs::Swapkit;
use dotenv;
use swapkit_rs::Configuration;
use swapkit_rs::RequestARepayQuoteParams;
use rust_decimal::Decimal;
let swapkit_config = Configuration::new(None, dotenv::var("SWAPKIT_REFERER").unwrap().as_str(), dotenv::var("SWAPKIT_X_API_KEY").unwrap().as_str());
let mut swapkit = Swapkit::new(swapkit_config);
let quote = swapkit.get_request_a_repay_quote(RequestARepayQuoteParams {
repay_asset: "BTC.BTC".to_string(),
collateral_asset: "BTC.BTC".to_string(),
amount_percentage: "0.5".to_string(),
sender_address: "bc1qzafz3f0h90u7n9j862uupaf5hpeydmhvpnzwzz".to_string(),
collateral_address: "bc1qzafz3f0h90u7n9j862uupaf5hpeydmhvpnzwzz".to_string(),
affiliate_basis_points: "".to_string(),
affiliate_address: "".to_string(),
}).await.unwrap();
assert_ne!(quote.get_inbound_confirmation_blocks(), Decimal::ZERO);
§Errors
todo
Source§impl Swapkit
impl Swapkit
Sourcepub async fn get_minimum_amount_to_send_with_details(
&mut self,
from: &str,
to: &str,
) -> Result<MinimumAmountToSendWithDetails>
pub async fn get_minimum_amount_to_send_with_details( &mut self, from: &str, to: &str, ) -> Result<MinimumAmountToSendWithDetails>
Retrieve the minimum swap amount with details.
§Arguments
From: The asset to send. To: The asset to receive.
§Returns JSON Equivalent
{
"result": "0.00077264",
"asset": "BTC.BTC",
"fromInboundAddress": InboundAddress,
"toInboundAddress": InboundAddress,
"toPool": Pool,
"fromPool": Pool
}
§Example
use swapkit_rs::Swapkit;
use dotenv;
use swapkit_rs::Configuration;
use rust_decimal::Decimal;
let swapkit_config = Configuration::new(None, dotenv::var("SWAPKIT_REFERER").unwrap().as_str(), dotenv::var("SWAPKIT_X_API_KEY").unwrap().as_str());
let mut swapkit = Swapkit::new(swapkit_config);
let minimum_amount_to_send_with_details = swapkit.get_minimum_amount_to_send_with_details("BTC.BTC", "ETH.ETH").await.unwrap();
assert_ne!(minimum_amount_to_send_with_details.get_result(), &Decimal::ZERO);
§Errors
todo
Sourcepub async fn get_gas_history(&mut self, chain_id: &str) -> Result<GasHistory>
pub async fn get_gas_history(&mut self, chain_id: &str) -> Result<GasHistory>
Retrieve the gas history for a given chain.
§Arguments
Chain ID: The chain ID to retrieve gas history for.
§Returns JSON Equivalent
{
"lastTimestamp": 1688396693338,
"chainId": "43114",
"unitName": "wei",
"history": [
{
"value": 25,
"timestamp": 1688394892940
}
],
"average24h": 25.01171800476548,
"average7d": 25.46623886101168
}
§Example
use swapkit_rs::Swapkit;
use dotenv;
use swapkit_rs::Configuration;
use rust_decimal::Decimal;
let swapkit_config = Configuration::new(None, dotenv::var("SWAPKIT_REFERER").unwrap().as_str(), dotenv::var("SWAPKIT_X_API_KEY").unwrap().as_str());
let mut swapkit = Swapkit::new(swapkit_config);
let gas_history = swapkit.get_gas_history("43114").await.unwrap();
assert_ne!(gas_history.get_last_timestamp(), &Decimal::ZERO);
§Errors
todo
Sourcepub async fn get_gas_rates(&mut self) -> Result<Vec<GasPrice>>
pub async fn get_gas_rates(&mut self) -> Result<Vec<GasPrice>>
Retrieve the current gas rates.
§Returns JSON Equivalent
[
{
"asset": "THOR.RUNE",
"units": "tor",
"gas": 2000000,
"chainId": "thorchain-mainnet-v1",
"gasAsset": 0.02
}
]
§Example
use swapkit_rs::Swapkit;
use dotenv;
use swapkit_rs::Configuration;
let swapkit_config = Configuration::new(None, dotenv::var("SWAPKIT_REFERER").unwrap().as_str(), dotenv::var("SWAPKIT_X_API_KEY").unwrap().as_str());
let mut swapkit = Swapkit::new(swapkit_config);
let gas_rates = swapkit.get_gas_rates().await.unwrap();
assert_ne!(gas_rates.len(), 0);
§Errors
todo
Source§impl Swapkit
impl Swapkit
Sourcepub async fn get_currencies_with_details(
&mut self,
) -> Result<CurrenciesWithDetails>
pub async fn get_currencies_with_details( &mut self, ) -> Result<CurrenciesWithDetails>
Retrieve a list of all the currencies the API supports with details.
§Returns JSON Equivalent
[
{
"name": "JOE",
"ticker": "JOE",
"address": "0x6e84a6216eA6dACC71eE8E6b0a5B7322EEbC0fDd",
"protocol": "AVAX",
"blockchain": "avalanche",
"chainId": 43114,
"apiIdentifier": "LOGO",
"decimals": 18,
"fullName": "AVAX.JOE-0X6E84A6216EA6DACC71EE8E6B0A5B7322EEBC0FDD",
"extraIdName": "",
"image": "https://raw.githubusercontent.com/traderjoe-xyz/joe-tokenlists/main/logos/0x6e84a6216eA6dACC71eE8E6b0a5B7322EEbC0fDd/logo.png",
"enabled": true,
"addressUrl": "https://snowtrace.io/address/",
"transactionUrl": "https://snowtrace.io/tx/",
"payinConfirmation": 1,
"averageBlockTime": 3000,
"notifications": {}
}
]
§Example
use swapkit_rs::Swapkit;
use dotenv;
use swapkit_rs::Configuration;
let swapkit_config = Configuration::new(None, dotenv::var("SWAPKIT_REFERER").unwrap().as_str(), dotenv::var("SWAPKIT_X_API_KEY").unwrap().as_str());
let mut swapkit = Swapkit::new(swapkit_config);
let currencies_with_details = swapkit.get_currencies_with_details().await.unwrap();
assert_ne!(currencies_with_details.get_currencies().len(), 0);
§Errors
todo
Sourcepub async fn get_token_pair_exchange_rate(
&mut self,
provider: &str,
buy_asset: &str,
sell_asset: &str,
) -> Result<ExchangeRate>
pub async fn get_token_pair_exchange_rate( &mut self, provider: &str, buy_asset: &str, sell_asset: &str, ) -> Result<ExchangeRate>
Retrieve the exchange rate between two tokens.
§Arguments
Provider: The provider to use for the exchange rate. Buy Asset: The asset to buy. Sell Asset: The asset to sell.
§Returns JSON Equivalent
{
"price": "1040560352527"
}
§Example
use swapkit_rs::Swapkit;
use dotenv;
use swapkit_rs::Configuration;
use rust_decimal::Decimal;
let swapkit_config = Configuration::new(None, dotenv::var("SWAPKIT_REFERER").unwrap().as_str(), dotenv::var("SWAPKIT_X_API_KEY").unwrap().as_str());
let mut swapkit = Swapkit::new(swapkit_config);
let exchange_rate = swapkit.get_token_pair_exchange_rate("THORCHAIN", "DOGE.DOGE", "THOR.RUNE").await.unwrap();
assert_ne!(exchange_rate.get_price(), &Decimal::ZERO);
§Errors
todo
Sourcepub async fn get_cached_prices(
&mut self,
tokens: Vec<String>,
metadata: Option<bool>,
lookup: Option<bool>,
sparkline: Option<bool>,
) -> Result<Vec<CachedPrice>>
pub async fn get_cached_prices( &mut self, tokens: Vec<String>, metadata: Option<bool>, lookup: Option<bool>, sparkline: Option<bool>, ) -> Result<Vec<CachedPrice>>
Retrieve the cached prices for a list of tokens.
§Arguments
Tokens: The list of tokens to retrieve the cached prices for. Metadata: Whether to include metadata in the response. Lookup: Whether to include lookup in the response. Sparkline: Whether to include sparkline in the response.
§Returns JSON Equivalent
[
{
"identifier": "BTC.BTC",
"provider": "thorchain",
"cg": {
"id": "bitcoin",
"name": "Bitcoin",
"market_cap": 538744544621,
"total_volume": 10969486163,
"price_change_24h_usd": -280.7722306713,
"price_change_percentage_24h_usd": -1.00657,
"sparkline_in_7d": "[28089.09709191385,27855.474964663084,27927.67807075597,27862.451794300196,27401.389272685337,27548.852018252153,27615.06488509527,27435.934692025516,27562.09703912351,27598.39792470794,27602.136947882696,27598.9993500583,27571.437611819903,27665.63327626977,27553.297682750952,27602.018171651824,27563.595143671093,27625.437113184413,27558.0389366372,27461.551847933046,27569.889017420348,27368.015011005587,27298.401139637797,27395.034111122666,27435.513880295017,27309.802923311734,27265.62463094056,27382.985451629556,27392.25698000947,27317.95783922375,27426.281146181223,27320.072509867994,27346.85930262205,27414.617414216456,27432.019190020048,27388.27831172733,27400.17389979379,27417.772319131862,27447.69073131563,27534.856488004025,27603.635460136415,27523.122837058436,27575.341017285835,27592.909263075417,27477.46254030785,27369.56539790677,27429.897057694783,27535.337250467284,27521.509194542694,27567.34444638266,27617.79707466413,27675.18226365197,27695.855655305724,27749.3591623358,27792.1112772493,27876.32045700953,27732.499011630913,27699.322189011964,27660.43776930838,27680.70811109574,27660.999881505486,27664.97998586457,27590.036109010794,27667.90317363952,27688.253128131677,27721.67093310776,27725.682886029477,27726.762917492902,27994.89730864139,28002.696815579708,27589.94070738397,27441.098459102155,27480.642145540383,27508.41169867955,27467.996840385844,27456.093199426483,27457.408171499657,27467.11281497509,27435.874615135104,27449.182553534614,27517.47659313017,27558.748584098343,27562.639686375685,27534.994803406487,27503.43709227742,27494.18273652981,27620.121334693493,27621.813080590975,27702.884509536205,27683.873490852977,27701.91202188015,27243.358912167776,27456.300949264096,27662.24505724077,28013.47513717081,27892.269316717717,27981.479515547853,27917.380788407478,27985.7686619,27985.153411120693,28141.091408717115,28015.369152584746,27958.196437350485,27935.45095504778,27929.06137059663,27919.728618535293,27928.21340921988,27933.38550086624,27916.173694762296,27918.823019136453,27905.662730230513,28019.428794289277,27955.69272098428,27952.4164201191,27951.995889644913,27975.65933688445,27954.276783733738,27962.347106863614,27954.76428701786,27965.11535213417,27963.657703192323,27902.221666935628,27876.74105849813,27933.844027691975,27959.75997497363,27974.7571037059,27977.543490700005,27991.261470727324,28018.263813642363,28031.083435007025,28088.344154516606,27941.92298575307,27950.417711989663,27910.307222168412,27922.817290402683,27918.183840966572,27920.63263879015,27838.539286459865,27831.66156449875,27834.03341170247,27945.573583737674,27938.916346723378,27907.122197042805,27925.396851235255,27890.631604658025,27876.307273823193,27902.96253787604,27924.562097939088,27976.4021826868,27919.889110632826,27948.10365174851,27841.982877887764,27984.53805572639,27956.367599384863,27940.268226458327,27945.412331761243,27871.811818805272,27921.657949143835,27843.34062675791,27752.810045457743,27556.74411716421,27542.403193736372,27502.801112830097,27477.190872892766,27489.23855019311,27486.740612263195,27453.06304817622,27354.09084225846]",
"timestamp": 1696883306189
},
"price_usd": 62744.82080390614,
"timestamp": 1710352724180
}
]
§Example
use swapkit_rs::Swapkit;
use dotenv;
use swapkit_rs::Configuration;
let swapkit_config = Configuration::new(None, dotenv::var("SWAPKIT_REFERER").unwrap().as_str(), dotenv::var("SWAPKIT_X_API_KEY").unwrap().as_str());
let mut swapkit = Swapkit::new(swapkit_config);
let cached_prices = swapkit.get_cached_prices(vec!["BTC.BTC".to_string()], None, None, None).await.unwrap();
assert_ne!(cached_prices.len(), 0);
§Errors
todo
Sourcepub async fn get_token_providers(&mut self) -> Result<Vec<Provider>>
pub async fn get_token_providers(&mut self) -> Result<Vec<Provider>>
Retrieve a list of all the token providers the API supports.
§Returns JSON Equivalent
[
{
"provider": "Woofi",
"version": {
"major": 1,
"minor": 0,
"patch" 0
},
"nbTokens": 4,
"logo": "https://static.thorswap.net/token-list/images/eth.woo-0x4691937a7508860f876c9c0a2a617e7d9e945d4b.png"
}
]
§Example
use swapkit_rs::Swapkit;
use dotenv;
use swapkit_rs::Configuration;
let swapkit_config = Configuration::new(None, dotenv::var("SWAPKIT_REFERER").unwrap().as_str(), dotenv::var("SWAPKIT_X_API_KEY").unwrap().as_str());
let mut swapkit = Swapkit::new(swapkit_config);
let token_providers = swapkit.get_token_providers().await.unwrap();
assert_ne!(token_providers.len(), 0);
§Errors
todo