Skip to content

Get Liquidity Provider info

Tan Xiu Haw edited this page Sep 21, 2023 · 5 revisions

Get Liquidity Provider info for a given provider key NOT WORKING

  • Following parameters required:
    • Key - provider key to get info from
  • Return - liquidity provider class
    • liquidity provider data
      • Mosaic ID
      • Provider key
      • Owner
      • Additionally minted
      • Slashing account
      • Slashing period
      • Window size
      • Height created
      • Alpha, Beta
      • Recent turnover
      • Array of turnover history
#include <xpxchaincpp/sdk.h>
#include <iostream>

using namespace xpx_chain_sdk;

int main() 
{
  xpx_chain_sdk::Config config = xpx_chain_sdk::GetConfig();
  config.nodeAddress = "127.0.0.1";
  config.port = "3000";
  
  std::string key = "";

  auto client = xpx_chain_sdk::getClient(config);
  auto liquidityProvider = client->liquidityProvider()->getLiquidityProviderByKey(key).data;

  std::cout << liquidityProvider.mosaicId << std::endl;
  std::cout << liquidityProvider.providerKey << std::endl;
  std::cout << liquidityProvider.owner << std::endl;
  std::cout << liquidityProvider.additionallyMinted << std::endl;
  std::cout << liquidityProvider.slashingAccount << std::endl;
  std::cout << liquidityProvider.slashingPeriod << std::endl;
  std::cout << liquidityProvider.windowSize << std::endl;
  std::cout << liquidityProvider.creationHeight << std::endl;
  std::cout << liquidityProvider.alpha << std::endl;
  std::cout << liquidityProvider.beta << std::endl;
  std::cout << liquidityProvider.recentTurnover.rate.currencyAmount << std::endl;
  std::cout << liquidityProvider.recentTurnover.rate.mosaicAmount << std::endl;
  std::cout << liquidityProvider.recentTurnover.turnover << std::endl;

  auto turnoverHistory = liquidityProvider.turnoverHistory;
  for (auto& turnoverData : turnoverHistory) {
    std::cout << turnoverData.turnover << std::endl;
  }
  return 0;
}

Get Liquidity Provider pagination info NOT WORKING

  • Return - liquidity provider page class
    • multiple liquidity providers
      • Array of liquidity provider class
    • pagination
      • Total entries
      • Page number
      • Page size
      • Total pages
#include <xpxchaincpp/sdk.h>
#include <iostream>

using namespace xpx_chain_sdk;

int main() 
{
  xpx_chain_sdk::Config config = xpx_chain_sdk::GetConfig();
  config.nodeAddress = "127.0.0.1";
  config.port = "3000";
  
  std::string key = "";

  auto client = xpx_chain_sdk::getClient(config);
  auto liquidityProviderPage = client->liquidityProvider()->getLiquidityProviders();
  auto liquidityProviders = liquidityProviderPage.data.liquidityProviders;

  for (auto& liquidityProvider : liquidityProviders) {
    std::cout << liquidityProvider.data.mosaicId << std::endl;
  }

  std::cout << liquidityProviderPage.pagination.totalEntries << std::endl;
  std::cout << liquidityProviderPage.pagination.pageNumber << std::endl;
  std::cout << liquidityProviderPage.pagination.pageSize << std::endl;
  std::cout << liquidityProviderPage.pagination.totalPages << std::endl;
  return 0;
}