4.0.2 • Published 8 months ago

@hop.ag/sdk v4.0.2

Weekly downloads
-
License
ISC
Repository
-
Last release
8 months ago

Hop SDK

Use this library to interact with Hop Aggregator's swap.

npm install @hop.ag/sdk

Initialize

import { HopApi, HopApiOptions } from "@hop.ag/sdk";
import { getFullnodeUrl } from "@mysten/sui/client";

const rpc_url = getFullNodeUrl("mainnet");
const hop_api_options: HopApiOptions = {
  api_key: "",
  
  // 1bps = 0.01%. 10_000bps = 100%.
  fee_bps: 0,
  fee_wallet: "YOUR_SUI_ADDRESS_HERE",
  
  // option to charge fees in sui when possible
  // instead of only the output token
  charge_fees_in_sui: true,
};

const sdk = new HopApi(rpc_url, hop_api_options);

To use the Hop Aggregator API, please create an api key here first.

Get a Swap Quote

Call this first to display the expected amount out.

const quote = await sdk.fetchQuote({
  token_in: "",
  token_out: "",
  amount_in: 0,
});

Get a Swap Transaction

Call this when a user clicks trade and wants to execute a transaction.

const tx = await sdk.fetchTx({
  trade: quote.trade,
  sui_address: "VALID_SUI_ADDRESS_HERE",

  gas_budget: 0.03e9, // optional default is 0.03 SUI
  max_slippage_bps: 100, // optional default is 1%

  return_output_coin_argument: false, // toggle to use the output coin in a ptb
});

Get a list of Verified Tokens

We maintain a list of verified SUI ecosystem tokens and their metadata. This endpoint returns a curated list - with ordering - for your application.

const tokens = await sdk.fetchTokens();

Automatic Updates

As soon as new liquidity sources become available, your SDK will automatically aggregate them, without anything required on your end.

Attribution

Please link to and/or mention Powered by Hop if you are using this SDK.

4.0.2

8 months ago

4.0.1

8 months ago

4.0.0

8 months ago

3.3.6

8 months ago

3.3.1

8 months ago

3.3.0

9 months ago

3.3.5

8 months ago

3.3.4

8 months ago

3.3.3

8 months ago

3.3.2

8 months ago

2.2.0

1 year ago

2.1.6

1 year ago

2.1.5

1 year ago

3.2.7

10 months ago

3.1.8

11 months ago

3.0.9

12 months ago

3.2.2

10 months ago

3.1.3

12 months ago

3.0.4

1 year ago

3.2.1

10 months ago

3.1.2

12 months ago

3.0.3

1 year ago

3.2.0

10 months ago

3.1.1

12 months ago

3.0.2

1 year ago

3.1.0

12 months ago

3.0.1

1 year ago

3.2.6

10 months ago

3.1.7

11 months ago

3.0.8

12 months ago

3.2.5

10 months ago

3.1.6

12 months ago

3.0.7

1 year ago

3.2.4

10 months ago

3.1.5

12 months ago

3.0.6

1 year ago

3.2.3

10 months ago

3.1.4

12 months ago

3.0.0

1 year ago

2.1.4

1 year ago

2.1.3

1 year ago

2.1.2

1 year ago

2.1.1

1 year ago

2.0.3

1 year ago

2.0.2

1 year ago

2.0.1

1 year ago

2.0.0

1 year ago

1.1.1

1 year ago

1.1.0

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago