Struct midgard_rs::Midgard
source · pub struct Midgard { /* private fields */ }Implementations§
source§impl Midgard
impl Midgard
sourcepub async fn get_actions(&mut self, params: GetActionList) -> Result<ActionList>
pub async fn get_actions(&mut self, params: GetActionList) -> Result<ActionList>
List actions along with their related transactions. An action is generated by one or more inbound transactions with the intended action set in the transaction memo. The action may result in one or more outbound transactions. Results are paginated by sets of 50. Filters may be applied to query actions.
§Example
use midgard_rs::GetActionList;
use midgard_rs::Midgard;
let mut midgard = Midgard::new();
let params = GetActionList::new(vec!["BTC.BTC".to_string()], 10);
let actions = midgard.get_actions(params).await.unwrap();
assert!(!actions.get_actions().get_actions().is_empty());To get paginated responses, you can pass the next_page_token from the previous response to the next request.
use midgard_rs::GetActionList;
use midgard_rs::Midgard;
let mut midgard = Midgard::new();
let mut params = GetActionList::new(vec!["BTC.BTC".to_string()], 10);
let actions = midgard.get_actions(params.clone()).await.unwrap();
assert!(!actions.get_actions().get_actions().is_empty());
let next_page_token = actions.get_meta().get_next_page_token();
if let Some(next_page_token) = next_page_token {
params.set_next_page_token(next_page_token);
let next_actions = midgard.get_actions(params).await.unwrap();
assert!(!next_actions.get_actions().get_actions().is_empty());
}§Errors
todo
source§impl Midgard
impl Midgard
sourcepub async fn get_balance(
&mut self,
address: &str,
timestamp: Option<i64>,
height: Option<u64>
) -> Result<Balance>
pub async fn get_balance( &mut self, address: &str, timestamp: Option<i64>, height: Option<u64> ) -> Result<Balance>
Returns all coin amounts of the given address at the specified timestamp or height, or at the latest process block if neither is provided. Only one of timestamp or height can be specified, not both, if both are specified the request will fail.
§Example
use midgard_rs::Midgard;
let mut midgard = Midgard::new();
let address = "thor102y0m3uptg0vvudeyh00r2fnz70wq7d8y7mu2g";
let balance = midgard.get_balance(address, None, None).await.unwrap();
assert!(*balance.get_height() > 0);§Errors
todo
source§impl Midgard
impl Midgard
sourcepub async fn get_borrowers_details(
&mut self,
address: &str
) -> Result<BorrowersDetails>
pub async fn get_borrowers_details( &mut self, address: &str ) -> Result<BorrowersDetails>
Returns an array of statistics for all the open loans associated with a given borrower address.
§Example
use midgard_rs::Midgard;
use rand::prelude::*;
// Create a new instance of Midgard
let mut midgard = Midgard::new();
// Get two random addresses from the list of borrowers
let borrowers = midgard.get_borrowers_list(None).await.unwrap();
let address_1 = borrowers.get_borrowers().choose(&mut rand::thread_rng()).unwrap().clone();
let address_2 = borrowers.get_borrowers().choose(&mut rand::thread_rng()).unwrap().clone();
let address = vec![address_1, address_2].join(",");
// Get the borrowers details
let borrowers_details = midgard.get_borrowers_details(&address).await.unwrap();
assert!(!borrowers_details.get_pools().is_empty());§Errors
todo
sourcepub async fn get_borrowers_list(
&mut self,
asset: Option<String>
) -> Result<BorrowersList>
pub async fn get_borrowers_list( &mut self, asset: Option<String> ) -> Result<BorrowersList>
Returns an array containing the addresses for all borrowers. Addresses are only shown once.
§Example
use midgard_rs::Midgard;
// Create a new instance of Midgard
let mut midgard = Midgard::new();
// Set the asset
let asset = Some("BTC.BTC".to_string());
// Get the borrowers list
let borrowers_list = midgard.get_borrowers_list(asset).await.unwrap();
assert!(!borrowers_list.get_borrowers().is_empty());§Errors
todo
source§impl Midgard
impl Midgard
sourcepub async fn get_churn_list(&mut self) -> Result<ChurnsList>
pub async fn get_churn_list(&mut self) -> Result<ChurnsList>
source§impl Midgard
impl Midgard
sourcepub async fn get_global_stats(&mut self) -> Result<GlobalStats>
pub async fn get_global_stats(&mut self) -> Result<GlobalStats>
Returns an object containing global stats for all pools and all transactions.
§Example
use midgard_rs::Midgard;
// Create a new instance of Midgard
let mut midgard = Midgard::new();
// Get the global stats
let global_stats = midgard.get_global_stats().await.unwrap();
assert!(*global_stats.get_add_liquidity_count() > 0);§Errors
todo
source§impl Midgard
impl Midgard
sourcepub async fn get_health_info(&mut self) -> Result<HealthInfo>
pub async fn get_health_info(&mut self) -> Result<HealthInfo>
Returns an object containing the health response of the API. Meaning of heights:
- lastThorNode - Latest block as reported by
ThorNode. - lastFetched - Latest block fetched from
ThorNode. - lastCommitted - Latest block committed to the DB but not fully processed yet.
- lastAggregated - Latest block fully processed and aggregated.
- genesisInfo - The genesis height Midgard bootstrapped with.
§Example
use midgard_rs::Midgard;
use serde_json::json;
// Create a new instance of Midgard
let mut midgard = Midgard::new();
// Get the health info
let health_info = midgard.get_health_info().await.unwrap();
println!("health_info: {}", json!(health_info));
assert!(health_info.get_last_thor_node().is_some());
assert!(health_info.get_last_fetched().is_some());
assert!(health_info.get_last_committed().is_some());
assert!(health_info.get_last_aggregated().is_some());§Errors
todo
source§impl Midgard
impl Midgard
sourcepub async fn get_depth_and_price_history(
&mut self,
pool: &str,
interval: Option<Interval>,
count: Option<usize>,
to: Option<u64>,
from: Option<u64>
) -> Result<DepthHistory>
pub async fn get_depth_and_price_history( &mut self, pool: &str, interval: Option<Interval>, count: Option<usize>, to: Option<u64>, from: Option<u64> ) -> Result<DepthHistory>
Returns the asset and rune depths and price. The values report the state at the end of each interval. History endpoint has two modes:
- With Interval parameter it returns a series of time buckets. From and To dates will be rounded to the Interval boundaries.
- Without Interval parameter a single From..To search is performed with exact timestamps.
- Interval: possible values: 5min, hour, day, week, month, quarter, year.
- count: [1..400]. Defines number of intervals. Don’t provide if Interval is missing.
- from/to: optional int, unix second.
Possible usages with interval.
- last 10 days: ?interval=day&count=10
- last 10 days before to: ?interval=day&count=10&to=1608825600
- next 10 days after from: ?interval=day&count=10&from=1606780800
- Days between from and to. From defaults to start of chain, to defaults to now. Only the first 400 intervals are returned: interval=day&from=1606780800&to=1608825600
Pagination is possible with from&count and then using the returned meta.endTime as the From parameter of the next query.
Possible configurations without interval:
- exact search for one time frame: ?from=1606780899&to=1608825600
- one time frame until now: ?from=1606780899
- from chain start until now: no query parameters
§Example
use midgard_rs::Midgard;
use midgard_rs::Interval;
// Create a new instance of Midgard
let mut midgard = Midgard::new();
// Get depth & price history
let depth_history = midgard.get_depth_and_price_history("BTC.BTC", Some(Interval::Day), Some(10), None, None).await.unwrap();
assert!(!depth_history.get_intervals().is_empty());To get paginated responses, you can pass the end_time from the previous response to the next request.
use midgard_rs::Midgard;
use midgard_rs::Interval;
// Create a new instance of Midgard
let mut midgard = Midgard::new();
// Get depth & price history
let depth_history = midgard.get_depth_and_price_history("BTC.BTC", Some(Interval::Day), Some(10), None, None).await.unwrap();
assert!(!depth_history.get_intervals().is_empty());
// Get the end time
let end_time = depth_history.get_meta().get_end_time().timestamp() as u64;
let depth_history = midgard.get_depth_and_price_history("BTC.BTC", Some(Interval::Day), Some(10), None, Some(end_time)).await.unwrap();
assert!(!depth_history.get_intervals().is_empty());§Errors
todo
sourcepub async fn get_earnings_history(
&mut self,
interval: Option<Interval>,
count: Option<usize>,
to: Option<u64>,
from: Option<u64>
) -> Result<EarningsHistory>
pub async fn get_earnings_history( &mut self, interval: Option<Interval>, count: Option<usize>, to: Option<u64>, from: Option<u64> ) -> Result<EarningsHistory>
Returns earnings data for the specified interval.
History endpoint has two modes:
- With Interval parameter it returns a series of time buckets. From and To dates will be rounded to the Interval boundaries.
- Without Interval parameter a single From..To search is performed with exact timestamps.
- Interval: possible values: 5min, hour, day, week, month, quarter, year.
- count: [1..400]. Defines number of intervals. Don’t provide if Interval is missing.
- from/to: optional int, unix second.
Possible usages with interval.
- last 10 days: ?interval=day&count=10
- last 10 days before to: ?interval=day&count=10&to=1608825600
- next 10 days after from: ?interval=day&count=10&from=1606780800
- Days between from and to. From defaults to start of chain, to defaults to now. Only the first 400 intervals are returned: interval=day&from=1606780800&to=1608825600
Pagination is possible with from&count and then using the returned meta.endTime as the From parameter of the next query.
Possible configurations without interval:
- exact search for one time frame: ?from=1606780899&to=1608825600
- one time frame until now: ?from=1606780899
- from chain start until now: no query parameters
§Example
use midgard_rs::Midgard;
use midgard_rs::Interval;
// Create a new instance of Midgard
let mut midgard = Midgard::new();
let depth_history = midgard.get_depth_and_price_history("BTC.BTC", Some(Interval::Day), Some(10), None, None).await.unwrap();
assert!(!depth_history.get_intervals().is_empty());To get paginated responses, you can pass the end_time from the previous response to the next request.
use midgard_rs::Midgard;
use midgard_rs::Interval;
// Create a new instance of Midgard
let mut midgard = Midgard::new();
// Get depth & price history
let depth_history = midgard.get_depth_and_price_history("BTC.BTC", Some(Interval::Day), Some(10), None, None).await.unwrap();
assert!(!depth_history.get_intervals().is_empty());
// Get the end time
let end_time = depth_history.get_meta().get_end_time().timestamp() as u64;
let depth_history = midgard.get_depth_and_price_history("BTC.BTC", Some(Interval::Day), Some(10), None, Some(end_time)).await.unwrap();
assert!(!depth_history.get_intervals().is_empty());§Errors
todo
sourcepub async fn get_liquidity_change_history(
&mut self,
pool: &str,
interval: Option<Interval>,
count: Option<usize>,
to: Option<u64>,
from: Option<u64>
) -> Result<LiquidityChangeHistory>
pub async fn get_liquidity_change_history( &mut self, pool: &str, interval: Option<Interval>, count: Option<usize>, to: Option<u64>, from: Option<u64> ) -> Result<LiquidityChangeHistory>
Returns withdrawals and deposits for given time interval. If pool is not specified returns for all pools
History endpoint has two modes:
- With Interval parameter it returns a series of time buckets. From and To dates will be rounded to the Interval boundaries.
- Without Interval parameter a single From..To search is performed with exact timestamps.
- Interval: possible values: 5min, hour, day, week, month, quarter, year.
- count: [1..400]. Defines number of intervals. Don’t provide if Interval is missing.
- from/to: optional int, unix second.
Possible usages with interval.
- last 10 days: ?interval=day&count=10
- last 10 days before to: ?interval=day&count=10&to=1608825600
- next 10 days after from: ?interval=day&count=10&from=1606780800
- Days between from and to. From defaults to start of chain, to defaults to now. Only the first 400 intervals are returned: interval=day&from=1606780800&to=1608825600
Pagination is possible with from&count and then using the returned meta.endTime as the From parameter of the next query.
Possible configurations without interval:
- exact search for one time frame: ?from=1606780899&to=1608825600
- one time frame until now: ?from=1606780899
- from chain start until now: no query parameters
§Example
use midgard_rs::Midgard;
use midgard_rs::Interval;
// Create a new instance of Midgard
let mut midgard = Midgard::new();
// Get liquidity change history
let liquidity_change_history = midgard.get_liquidity_change_history("BTC.BTC", Some(Interval::Day), Some(10), None, None).await.unwrap();
assert!(!liquidity_change_history.get_intervals().is_empty());To get paginated responses, you can pass the end_time from the previous response to the next request.
use midgard_rs::Midgard;
use midgard_rs::Interval;
// Create a new instance of Midgard
let mut midgard = Midgard::new();
// Get liquidity change history
let liquidity_change_history = midgard.get_liquidity_change_history("BTC.BTC", Some(Interval::Day), Some(10), None, None).await.unwrap();
assert!(!liquidity_change_history.get_intervals().is_empty());
// Get the end time
let end_time = liquidity_change_history.get_meta().get_end_time().timestamp() as u64;
let liquidity_change_history = midgard.get_liquidity_change_history("BTC.BTC", Some(Interval::Day), Some(10), None, Some(end_time)).await.unwrap();
assert!(!liquidity_change_history.get_intervals().is_empty());§Errors
todo
sourcepub async fn get_savers_units_and_depth_history(
&mut self,
pool: &str,
interval: Option<Interval>,
count: Option<usize>,
to: Option<u64>,
from: Option<u64>
) -> Result<SaversHistory>
pub async fn get_savers_units_and_depth_history( &mut self, pool: &str, interval: Option<Interval>, count: Option<usize>, to: Option<u64>, from: Option<u64> ) -> Result<SaversHistory>
Returns savers depths and units. The values report the state at the end of each interval.
History endpoint has two modes:
- With Interval parameter it returns a series of time buckets. From and To dates will be rounded to the Interval boundaries.
- Without Interval parameter a single From..To search is performed with exact timestamps.
- Interval: possible values: 5min, hour, day, week, month, quarter, year.
- count: [1..400]. Defines number of intervals. Don’t provide if Interval is missing.
- from/to: optional int, unix second.
Possible usages with interval.
- last 10 days: ?interval=day&count=10
- last 10 days before to: ?interval=day&count=10&to=1608825600
- next 10 days after from: ?interval=day&count=10&from=1606780800
- Days between from and to. From defaults to start of chain, to defaults to now. Only the first 400 intervals are returned: interval=day&from=1606780800&to=1608825600
Pagination is possible with from&count and then using the returned meta.endTime as the From parameter of the next query.
Possible configurations without interval:
- exact search for one time frame: ?from=1606780899&to=1608825600
- one time frame until now: ?from=1606780899
- from chain start until now: no query parameters
§Example
use midgard_rs::Midgard;
use midgard_rs::Interval;
// Create a new instance of Midgard
let mut midgard = Midgard::new();
// Get savers units and depth history
let savers_history = midgard.get_savers_units_and_depth_history("BTC.BTC", Some(Interval::Day), Some(10), None, None).await.unwrap();
assert!(!savers_history.get_intervals().is_empty());To get paginated responses, you can pass the end_time from the previous response to the next request.
use midgard_rs::Midgard;
use midgard_rs::Interval;
// Create a new instance of Midgard
let mut midgard = Midgard::new();
// Get savers units and depth history
let savers_history = midgard.get_savers_units_and_depth_history("BTC.BTC", Some(Interval::Day), Some(10), None, None).await.unwrap();
assert!(!savers_history.get_intervals().is_empty());
// Get the end time
let end_time = savers_history.get_meta().get_end_time().timestamp() as u64;
let savers_history = midgard.get_savers_units_and_depth_history("BTC.BTC", Some(Interval::Day), Some(10), None, Some(end_time)).await.unwrap();
assert!(!savers_history.get_intervals().is_empty());§Errors
todo
sourcepub async fn get_swaps_history(
&mut self,
pool: Option<&str>,
interval: Option<Interval>,
count: Option<usize>,
to: Option<u64>,
from: Option<u64>
) -> Result<SwapHistory>
pub async fn get_swaps_history( &mut self, pool: Option<&str>, interval: Option<Interval>, count: Option<usize>, to: Option<u64>, from: Option<u64> ) -> Result<SwapHistory>
Returns swap count, volume, fees, slip in specified interval. If pool is not specified returns for all pools
History endpoint has two modes:
- With Interval parameter it returns a series of time buckets. From and To dates will be rounded to the Interval boundaries.
- Without Interval parameter a single From..To search is performed with exact timestamps.
- Interval: possible values: 5min, hour, day, week, month, quarter, year.
- count: [1..400]. Defines number of intervals. Don’t provide if Interval is missing.
- from/to: optional int, unix second.
Possible usages with interval.
- last 10 days: ?interval=day&count=10
- last 10 days before to: ?interval=day&count=10&to=1608825600
- next 10 days after from: ?interval=day&count=10&from=1606780800
- Days between from and to. From defaults to start of chain, to defaults to now. Only the first 400 intervals are returned: interval=day&from=1606780800&to=1608825600
Pagination is possible with from&count and then using the returned meta.endTime as the From parameter of the next query.
Possible configurations without interval:
- exact search for one time frame: ?from=1606780899&to=1608825600
- one time frame until now: ?from=1606780899
- from chain start until now: no query parameters
§Example
use midgard_rs::Midgard;
use midgard_rs::Interval;
// Create a new instance of Midgard
let mut midgard = Midgard::new();
// Get swaps history
let swaps_history = midgard.get_swaps_history(None, Some(Interval::Day), Some(10), None, None).await.unwrap();
assert!(!swaps_history.get_intervals().is_empty());To get paginated responses, you can pass the end_time from the previous response to the next request.
use midgard_rs::Midgard;
use midgard_rs::Interval;
// Create a new instance of Midgard
let mut midgard = Midgard::new();
// Get swaps history
let swaps_history = midgard.get_swaps_history(None, Some(Interval::Day), Some(10), None, None).await.unwrap();
assert!(!swaps_history.get_intervals().is_empty());
// Get the end time
let end_time = swaps_history.get_meta().get_end_time().timestamp() as u64;
let swaps_history = midgard.get_swaps_history(None, Some(Interval::Day), Some(10), None, Some(end_time)).await.unwrap();
assert!(!swaps_history.get_intervals().is_empty());§Errors
todo
sourcepub async fn get_total_value_locked_history(
&mut self,
interval: Option<Interval>,
count: Option<usize>,
to: Option<u64>,
from: Option<u64>
) -> Result<TVLHistory>
pub async fn get_total_value_locked_history( &mut self, interval: Option<Interval>, count: Option<usize>, to: Option<u64>, from: Option<u64> ) -> Result<TVLHistory>
Returns total pool depths, total bonds, and total value locked in specified interval.
Total Value Locked = Total Bonds + 2 * Total Pool Depths
History endpoint has two modes:
- With Interval parameter it returns a series of time buckets. From and To dates will be rounded to the Interval boundaries.
- Without Interval parameter a single From..To search is performed with exact timestamps.
- Interval: possible values: 5min, hour, day, week, month, quarter, year.
- count: [1..400]. Defines number of intervals. Don’t provide if Interval is missing.
- from/to: optional int, unix second.
Possible usages with interval.
- last 10 days: ?interval=day&count=10
- last 10 days before to: ?interval=day&count=10&to=1608825600
- next 10 days after from: ?interval=day&count=10&from=1606780800
- Days between from and to. From defaults to start of chain, to defaults to now. Only the first 400 intervals are returned: interval=day&from=1606780800&to=1608825600
Pagination is possible with from&count and then using the returned meta.endTime as the From parameter of the next query.
Possible configurations without interval:
- exact search for one time frame: ?from=1606780899&to=1608825600
- one time frame until now: ?from=1606780899
- from chain start until now: no query parameters
§Example
use midgard_rs::Midgard;
use midgard_rs::Interval;
// Create a new instance of Midgard
let mut midgard = Midgard::new();
// Get total value locked history
let tvl_history = midgard.get_total_value_locked_history(Some(Interval::Day), Some(10), None, None).await.unwrap();
assert!(!tvl_history.get_intervals().is_empty());To get paginated responses, you can pass the end_time from the previous response to the next request.
use midgard_rs::Midgard;
use midgard_rs::Interval;
// Create a new instance of Midgard
let mut midgard = Midgard::new();
// Get total value locked history
let tvl_history = midgard.get_total_value_locked_history(Some(Interval::Day), Some(10), None, None).await.unwrap();
assert!(!tvl_history.get_intervals().is_empty());
// Get the end time
let end_time = tvl_history.get_meta().get_end_time().timestamp() as u64;
let tvl_history = midgard.get_total_value_locked_history(Some(Interval::Day), Some(10), None, Some(end_time)).await.unwrap();
assert!(!tvl_history.get_intervals().is_empty());§Errors
todo
source§impl Midgard
impl Midgard
sourcepub async fn get_member_details(
&mut self,
address: &[String],
show_savers: bool
) -> Result<MemberDetails>
pub async fn get_member_details( &mut self, address: &[String], show_savers: bool ) -> Result<MemberDetails>
Returns an array of statistics for all the liquidity providers associated with a given member address.
§path Parameters
address
- required
- string
- Example: bnb1jxfh2g85q3v0tdq56fnevx6xcxtcnhtsmcu64m,bc1qcxssye4j6730h7ehgega3gyykkuwgdgmmpu62n
- Address to match liquidity providers. Either a rune or an asset address may be given. Query can also be multiple addresses should be seperated by comma (‘,’)
§query Parameters
showSavers
- boolean
- Default: false
- Example: showSavers=true
- A flag to show saver vault membership details, the default is false.
§Example
use midgard_rs::Midgard;
use midgard_rs::MemberDetails;
use rand::prelude::*;
let mut midgard = Midgard::new();
// get random pool members list
let pool_list = midgard.get_pool_list(None, None).await.unwrap();
let random_usize = thread_rng().gen_range(0..pool_list.get_assets().len());
let pool = pool_list.get_assets()[random_usize].clone();
let member_list = midgard.get_member_list(Some(pool)).await.unwrap();
// get random member addresses
let random_usize = thread_rng().gen_range(0..member_list.get_members().len());
let random_usize_2 = thread_rng().gen_range(0..member_list.get_members().len());
let address = vec![member_list.get_members()[random_usize].clone(), member_list.get_members()[random_usize_2].clone()];
// get member details
let show_savers = false;
let member_details = midgard.get_member_details(&address, show_savers).await.unwrap();
assert!(!member_details.get_pools().is_empty());§Errors
todo
sourcepub async fn get_member_list(
&mut self,
pool: Option<String>
) -> Result<MemberList>
pub async fn get_member_list( &mut self, pool: Option<String> ) -> Result<MemberList>
Returns an array containing the addresses for all pool members. Addresses are only shown once. If there’s both a RUNE address and an asset address for a member, only the RUNE address will be shown.
§query Parameters
pool
- string
- Example: pool=BNB.BNB
§Example
use midgard_rs::Midgard;
use midgard_rs::MemberList;
use rand::prelude::*;
let mut midgard = Midgard::new();
// get random pool
let pool_list = midgard.get_pool_list(None, None).await.unwrap();
let random_usize = thread_rng().gen_range(0..pool_list.get_assets().len());
let pool = pool_list.get_assets()[random_usize].clone();
// get member list
let member_list = midgard.get_member_list(Some(pool)).await.unwrap();
assert!(!member_list.get_members().is_empty());§Errors
todo
source§impl Midgard
impl Midgard
sourcepub async fn get_network_data(&mut self) -> Result<NetworkData>
pub async fn get_network_data(&mut self) -> Result<NetworkData>
source§impl Midgard
impl Midgard
sourcepub async fn get_pool_list(
&mut self,
status: Option<PoolStatus>,
period: Option<TimePeriod>
) -> Result<PoolList>
pub async fn get_pool_list( &mut self, status: Option<PoolStatus>, period: Option<TimePeriod> ) -> Result<PoolList>
Returns an array containing details for a set of pools.
§Example
use midgard_rs::Midgard;
use midgard_rs::PoolStatus;
use midgard_rs::TimePeriod;
let mut midgard = Midgard::new();
let pool_list = midgard.get_pool_list(None, None).await.unwrap();
assert!(!pool_list.get_pools().is_empty());§Errors
todo
sourcepub async fn get_details_of_pool(
&mut self,
pool: &str,
period: Option<TimePeriod>
) -> Result<Pool>
pub async fn get_details_of_pool( &mut self, pool: &str, period: Option<TimePeriod> ) -> Result<Pool>
Returns details of the pool: depths, price, 24h volume, APY.
§Example
use midgard_rs::Midgard;
use midgard_rs::TimePeriod;
use rand::prelude::*;
let mut midgard = Midgard::new();
// Get a random pool
let pool_list = midgard.get_pool_list(None, None).await.unwrap();
let random_usize = thread_rng().gen_range(0..pool_list.get_pools().len());
let pool = pool_list.get_pools()[random_usize].clone();
let pool = pool.get_asset().to_string();
// Get details of the pool
let details = midgard.get_details_of_pool(&pool, None).await.unwrap();
assert!(!details.get_annual_percentage_rate().is_zero());§Errors
todo
sourcepub async fn get_known_pool_list(&mut self) -> Result<KnownPoolList>
pub async fn get_known_pool_list(&mut self) -> Result<KnownPoolList>
Returns an object with known pools and their statuses.
§Example
use midgard_rs::Midgard;
use midgard_rs::PoolStatus;
let mut midgard = Midgard::new();
let known_pool_list = midgard.get_known_pool_list().await.unwrap();
assert!(!known_pool_list.into_iter().collect::<Vec<(String, PoolStatus)>>().is_empty());§Errors
todo
sourcepub async fn get_statistics_of_pool(
&mut self,
pool: &str,
period: Option<TimePeriod>
) -> Result<PoolStatistics>
pub async fn get_statistics_of_pool( &mut self, pool: &str, period: Option<TimePeriod> ) -> Result<PoolStatistics>
Statistics about the pool. The description of the fields have pointers about the corresponding v2/history location. Visit the history endpoint for drilldowns.
§Example
use midgard_rs::Midgard;
use midgard_rs::TimePeriod;
use rand::prelude::*;
let mut midgard = Midgard::new();
// Get a random pool
let pool_list = midgard.get_pool_list(None, None).await.unwrap();
let random_usize = thread_rng().gen_range(0..pool_list.get_pools().len());
let pool = pool_list.get_pools()[random_usize].clone();
let pool = pool.get_asset().to_string();
// Get statistics of the pool
let pool_statistics = midgard.get_statistics_of_pool(&pool, None).await.unwrap();
assert!(!pool_statistics.get_asset().is_empty());§Errors
todo
source§impl Midgard
impl Midgard
sourcepub async fn get_savers_details(
&mut self,
address: &[String]
) -> Result<SaversDetails>
pub async fn get_savers_details( &mut self, address: &[String] ) -> Result<SaversDetails>
Returns an array of statistics for all the savers associated with a given member address. Query can also be multiple addresses should be seperated by comma (‘,’).
§Example
use midgard_rs::Midgard;
use midgard_rs::SaversDetails;
let mut midgard = Midgard::new();
let address = vec![
"bnb1jxfh2g85q3v0tdq56fnevx6xcxtcnhtsmcu64m".to_string(),
"bc1qcxssye4j6730h7ehgega3gyykkuwgdgmmpu62n".to_string(),
];
let savers_details = midgard.get_savers_details(&address).await.unwrap();
assert!(!savers_details.get_pools().is_empty());§Errors
todo
source§impl Midgard
impl Midgard
sourcepub async fn get_thorname_details(
&mut self,
name: &str
) -> Result<ThornameDetails>
pub async fn get_thorname_details( &mut self, name: &str ) -> Result<ThornameDetails>
Returns an array of chains and their addresses associated with the given THORName.
§Example
use midgard_rs::Midgard;
let mut midgard = Midgard::new();
let name = "thorchain";
let thorname_details = midgard.get_thorname_details(&name).await.unwrap();
assert!(!thorname_details.get_owner().is_empty());§Errors
todo
sourcepub async fn get_thorname_owner(
&mut self,
address: &str
) -> Result<ThornameOwner>
pub async fn get_thorname_owner( &mut self, address: &str ) -> Result<ThornameOwner>
Returns an array of THORNames owned by the address. The address is not necessarily an associated address for those thornames.
§Example
use midgard_rs::Midgard;
let mut midgard = Midgard::new();
let address = "thor18w0hsdru75ug0x4uvamgjn6ghlu43mr4dcypq9";
let thorname_owner = midgard.get_thorname_owner(&address).await.unwrap();
assert!(!thorname_owner.get_thorname_owner().is_empty());§Errors
todo
sourcepub async fn get_thorname_reverse_lookup(
&mut self,
address: &str
) -> Result<ThornameReverseLookup>
pub async fn get_thorname_reverse_lookup( &mut self, address: &str ) -> Result<ThornameReverseLookup>
Returns an array of THORNames associated with the given address
§Example
use midgard_rs::Midgard;
let mut midgard = Midgard::new();
let address = "thor18w0hsdru75ug0x4uvamgjn6ghlu43mr4dcypq9";
let thorname_owner = midgard.get_thorname_owner(&address).await.unwrap();
assert!(!thorname_owner.get_thorname_owner().is_empty());§Errors
todo