npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@manahippo/hippo-sdk

v0.1.913

Published

Hippo SDK for Aptos

Downloads

943

Readme

hippo-sdk

hippo-sdk provides the following TypeScript interface:

  • Hippo Dex aggregator

Aggregator Usage

These snippets demonstrate how you can use the TradeAggregatorV2 class to

  1. query coin info
  2. query quotes for a particular pair
  3. perform swap
// compute a list of quotes (ordered by output), for fromSymbol -> toSymbol
const listQuotes = async (fromSymbol: string, toSymbol: string, inputUiAmt: string) => {
  const { client } = getAptosClient();
  const agg = await TradeAggregatorV2.create(client);
  const xCoinInfos = agg.coinListClient.getCoinInfoBySymbol(fromSymbol);
  const yCoinInfos = agg.coinListClient.getCoinInfoBySymbol(toSymbol);
  const inputAmt = parseFloat(inputUiAmt);
  const quotes = await agg.getQuotes(inputAmt, xCoinInfos[0], yCoinInfos[0], {
    split: true,
    considerGasWhenSorting: true,
    allowHighGas: true
  });
  for (const quote of quotes) {
    console.log('###########');
    quote.route.debugPrint();
    console.log(`Quote input: ${quote.quote.inputUiAmt}`);
    console.log(`Quote output: ${quote.quote.outputUiAmt}`);
  }
};

// send a transaction to swap "inputUiAmt" of "fromSymbol" to "toSymbol"
const swap = async (fromSymbol: string, toSymbol: string, inputUiAmt: string) => {
  const { client } = getAptosClient();
  const agg = await TradeAggregatorV2.create(client);
  const xCoinInfos = agg.coinListClient.getCoinInfoBySymbol(fromSymbol);
  const yCoinInfos = agg.coinListClient.getCoinInfoBySymbol(toSymbol);
  const inputAmt = parseFloat(inputUiAmt);
  const quotes = await agg.getQuotes(inputAmt, xCoinInfos[0], yCoinInfos[0], {
    split: true,
    considerGasWhenSorting: true,
    allowHighGas: true
  });
  if (quotes.length === 0) {
    console.log('No route available');
    return;
  }
  const payload = quotes[0].route.makeSwapPayload(inputAmt, 0);
  await sendPayloadTx(client, account, payload as TxnBuilderTypes.TransactionPayloadEntryFunction);
};

You can find more sample code that uses TradeAggregator in src/tools/index.ts.

Aggregator CLI

List commands

$ yarn cli agg2
Usage: hippo-cli agg2 [options] [command]

aggregator v2

Options:
  -h, --help

Commands:
  list-trading-pools
  list-quotes <fromSymbol> <toSymbol> <inputUiAmt>
  list-quotes-split <fromSymbol> <toSymbol> <inputUiAmt>
  list-quotes-direct <fromSymbol> <toSymbol> <inputUiAmt>
  list-quotes-api <fromSymbol> <toSymbol> <inputUiAmt>
  list-quotes-split-api <fromSymbol> <toSymbol> <inputUiAmt>
  list-quotes-with-change <fromSymbol> <toSymbol> <outputUiAmt>
  swap <fromSymbol> <toSymbol> <inputUiAmt> [minOutUiAmt] [routeIdx] [maxGas]
  simulate-swap <fromSymbol> <toSymbol> <inputUiAmt> [minOutUiAmt] [routeIdx] [maxGas]
  swap-with-fees <fromSymbol> <toSymbol> <inputUiAmt> <feeTo> <feeBips> [minOutUiAmt] [routeIdx] [maxGas]
  simulate-swap-with-fees <fromSymbol> <toSymbol> <inputUiAmt> <feeTo> <feeBips> [minOutUiAmt] [routeIdx] [maxGas]
  swap-fixed-out <fromSymbol> <toSymbol> <outputUiAmt> [routeIdx] [maxGas]
  simulate-swap-fixed-out <fromSymbol> <toSymbol> <outputUiAmt> [routeIdx] [maxGas]
  simulate-swap-with-change <fromSymbol> <toSymbol> <outputUiAmt> [maxGas]
  swap-with-change <fromSymbol> <toSymbol> <outputUiAmt> [maxGas]
  split-swap <fromSymbol> <toSymbol> <inputUiAmt> [minOutUiAmt] [routeIdx] [maxGas]
  simulate-split-swap <fromSymbol> <toSymbol> <inputUiAmt> [minOutUiAmt] [routeIdx] [maxGas]
  help [command]          

Get quotes from multiple routes

$ yarn cli -c .aptos/config.yaml agg2 list-quotes zUSDC APT 100