1.0.8 • Published 11 months ago

@panoraexchange/swap-sdk v1.0.8

Weekly downloads
-
License
-
Repository
-
Last release
11 months ago

PANORA SDK

SDK to perform the most optimal swap

Installtion

Using npm

npm i @panoraexchange/swap-sdk

Using yarn

yarn add @panoraexchange/swap-sdk

Using pnpm

pnpm add @panoraexchange/swap-sdk

For complete example of SDK usage please refer to: https://docs.panora.exchange

Attribution

Kindly include proper attribution when using the SDK in projects or presentations. Mention “Powered by Panora” whenever applicable.

Usage

Initialize Panora SDK

import Panora, { PanoraConfig } from "@panoraexchange/swap-sdk"

const config: PanoraConfig = {
  apiKey: "YOUR API KEY",
  rpcUrl: "CUSTOM RPC URL"
}

const panora = new Panora(config)

Execute Swap Transactions

Swap = async(SwapParams, private_key);

SwapParams is an object with the below field

SwapParamsRequiredDescription
chainIdNoID for the chain for which the endpoint is being invoked. Note: Default chainID is 1 for Aptos Mainnet
fromTokenAddressYesAddress of the token being swapped from.Example: If you want to swap 10.5 APT to USDT, then fromTokenAddress is 0x1::aptos_coin::AptosCoin
toTokenAddressYesAddress of the token being swapped to.Example: If you want to swap 10.5 APT to USDT, then toTokenAddress is 0x357b0b74bc833e95a115ad22604854d6b0fca151cecd94111770e5d6ffc9dc2b
fromTokenAmountNoAmount of the token being swapped from. Please set the amount without Token decimalsExample: If you want to swap 10.5 APT to USDT, then fromTokenAmount is 10.5
toTokenAmountNoAmount of the token being swapped to. Please set the amount without Token decimalsExample: If you want to swap from APT to 100 USDT, then toTokenAmount is 100
toWalletAddressYesAddress of the wallet to which the swapped tokens will be sent
slippagePercentageNoSlippage tolerance as 'auto' (which lets Panora choose the optimal slippage for the transaction, up to a maximum of 5%) or a percentage value.Example: For 3% slippage tolerance, set the value as 3. This can be set as 0.1, 0.5, 1.0 or any custom slippage percentage between 0 and 100Note: If nothing is entered, slippage tolerance will be set to auto by default. If a numeric value is entered, anything after one decimal will be truncated
integratorFeePercentageNoIntegrator fee as a percentage value.Example: For 2% integrator fee, set the value as 2. This can be set as 0.1, 0.5, 1.0 or any custom integrator fee between 0 and 2.Note: If nothing is entered, integrator fee will be set to 0 by default. Anything after one decimal will be truncated
integratorFeeAddressNoWallet Address where integrators want to receive their fee share.Note: Ensure it starts with 0x followed by 64 characters
includeSourcesNoList of liquidity sources to be included for route calculation.Example: "ThalaSwapV2", "Liquidswap"Note: If not specified, all available sources are included by default.
excludeSourcesNoList of liquidity sources to be excluded from the route.Example: "Aux"Note: If not specified, none of the sources will be excluded by default.
onlyDirectRoutesNoSet to true to restrict to direct routes without intermediate hops or splits.Example: For direct swaps without hops or splits, set to true.Default is false.

Get Quote Details for the swap transaction

SwapQuote = async(SwapQuoteParams);

SwapQuoteParams is an object with the below fields

SwapQuoteParamsRequiredDescription
chainIdNoID for the chain for which the endpoint is being invoked. Note: Default chainID is 1 for Aptos Mainnet
fromTokenAddressYesAddress of the token being swapped from.Example: If you want to swap 10.5 APT to USDT, then fromTokenAddress is 0x1::aptos_coin::AptosCoin
toTokenAddressYesAddress of the token being swapped to.Example: If you want to swap 10.5 APT to USDT, then toTokenAddress is 0x357b0b74bc833e95a115ad22604854d6b0fca151cecd94111770e5d6ffc9dc2b
fromTokenAmountYesAmount of the token being swapped from. Please set the amount without Token decimalsExample: If you want to swap 10.5 APT to USDT, then fromTokenAmount is 10.5
toTokenAmountYesAmount of the token being swapped to. Please set the amount without Token decimalsExample: If you want to swap from APT to 100 USDT, then toTokenAmount is 100
slippagePercentageNoSlippage tolerance as 'auto' (which lets Panora choose the optimal slippage for the transaction, up to a maximum of 5%) or a percentage value.Example: For 3% slippage tolerance, set the value as 3. This can be set as 0.1, 0.5, 1.0 or any custom slippage percentage between 0 and 100Note: If nothing is entered, slippage tolerance will be set to auto by default. If a numeric value is entered, anything after one decimal will be truncated
integratorFeePercentageNoIntegrator fee as a percentage value.Example: For 2% integrator fee, set the value as 2. This can be set as 0.1, 0.5, 1.0 or any custom integrator fee between 0 and 2.Note: If nothing is entered, integrator fee will be set to 0 by default. Anything after one decimal will be truncated
integratorFeeAddressNoWallet Address where integrators want to receive their fee share.Note: Ensure it starts with 0x followed by 64 characters
getTransactionDataNoEnter "rawTransaction" or "transactionPayload" to be included in the response.
includeSourcesNoList of liquidity sources to be included for route calculation.Example: "ThalaSwapV2", "Liquidswap"Note: If not specified, all available sources are included by default.
excludeSourcesNoList of liquidity sources to be excluded from the route.Example: "Aux"Note: If not specified, none of the sources will be excluded by default.
onlyDirectRoutesNoSet to true to restrict to direct routes without intermediate hops or splits.Example: For direct swaps without hops or splits, set to true.Default is false.
1.0.8

11 months ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.0

1 year ago