Using the Aggregator SDK

hippo-sdk:

  • Detailed integration sample code on github

  • npm: @manahippo/hippo-sdk

Quoting

// compute a list of quotes (ordered by output), for fromSymbol -> toSymbol
const aggListQuotes = async (fromSymbol: string, toSymbol: string, inputUiAmt: string) => {
  const { client } = readConfig(program);
  const agg = await TradeAggregator.create(client);
  const xCoinInfo = agg.registryClient.getCoinInfoBySymbol(fromSymbol);
  const yCoinInfo = agg.registryClient.getCoinInfoBySymbol(toSymbol);
  const inputAmt = parseFloat(inputUiAmt);
  const quotes = await agg.getQuotesUptoV3(inputAmt, xCoinInfo, yCoinInfo);
  for (const quote of quotes) {
    console.log('###########');
    quote.route.debugPrint();
    console.log(`Quote input: ${quote.quote.inputUiAmt}`);
    console.log(`Quote output: ${quote.quote.outputUiAmt}`);
  }
};

Swapping

Last updated