1.0.86 • Published 9 months ago

test-swap-sdk-knv-1 v1.0.86

Weekly downloads
-
License
-
Repository
-
Last release
9 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

Scenario 1: For ExactIn Swap where fromTokenAmount is entered (instead of toTokenAmount), the endpoint executes the transaction to get maximum toTokenAmount

ExactInSwap = 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 lzUSDC, then fromTokenAddress is 0x1::aptos_coin::AptosCoin
toTokenAddressYesAddress of the token being swapped to.Example: If you want to swap 10.5 APT to lzUSDC, then toTokenAddress is 0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC
fromTokenAmountYesAmount of the token being swapped from. Please set the amount without Token decimalsExample: If you want to swap 10.5 APT to lzUSDC, then fromTokenAmount is 10.5
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 four decimals 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 four decimals 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: "thala", "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.

Scenario 2: For ExactOut Swap where toTokenAmount is entered (instead of fromTokenAmount), the endpoint executes the transaction to pay minimum fromTokenAmount

ExactOutSwap = 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 lzUSDC, then fromTokenAddress is 0x1::aptos_coin::AptosCoin
toTokenAddressYesAddress of the token being swapped to.Example: If you want to swap 10.5 APT to lzUSDC, then toTokenAddress is 0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC
toTokenAmountYesAmount of the token being swapped to. Please set the amount without Token decimalsExample: If you want to swap from APT to 100 lzUSDC, 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 four decimals 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 four decimals 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: "thala", "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

Scenario 1: For ExactIn Swap where fromTokenAmount is entered (instead of toTokenAmount), the endpoint returns the maximum toTokenAmount

ExactInSwapQuote = async(GetQuotesParams);

GetQuoteParams is an object with the below fields

GetQuotesParamsRequiredDescription
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 lzUSDC, then fromTokenAddress is 0x1::aptos_coin::AptosCoin
toTokenAddressYesAddress of the token being swapped to.Example: If you want to swap 10.5 APT to lzUSDC, then toTokenAddress is 0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC
fromTokenAmountYesAmount of the token being swapped from. Please set the amount without Token decimalsExample: If you want to swap 10.5 APT to lzUSDC, then fromTokenAmount is 10.5
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 four decimals 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 four decimals 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: "thala", "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.

Scenario 2: For ExactOut Swap where toTokenAmount is entered (instead of fromTokenAmount), the endpoint returns the minimum fromTokenAmount

ExactOutSwapQuote = async(GetQuotesParams);

GetQuoteParams is an object with the below fields

GetQuotesParamsRequiredDescription
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 lzUSDC, then fromTokenAddress is 0x1::aptos_coin::AptosCoin
toTokenAddressYesAddress of the token being swapped to.Example: If you want to swap 10.5 APT to lzUSDC, then toTokenAddress is 0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC
toTokenAmountYesAmount of the token being swapped to. Please set the amount without Token decimalsExample: If you want to swap from APT to 100 lzUSDC, 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 four decimals 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 four decimals 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: "thala", "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.62

9 months ago

1.0.61

9 months ago

1.0.60

9 months ago

1.0.66

9 months ago

1.0.65

9 months ago

1.0.64

9 months ago

1.0.63

9 months ago

1.0.69

9 months ago

1.0.68

9 months ago

1.0.67

9 months ago

1.0.73

9 months ago

1.0.72

9 months ago

1.0.71

9 months ago

1.0.77

9 months ago

1.0.76

9 months ago

1.0.75

9 months ago

1.0.74

9 months ago

1.0.37

10 months ago

1.0.79

9 months ago

1.0.78

9 months ago

1.0.39

10 months ago

1.0.38

10 months ago

1.0.80

9 months ago

1.0.84

9 months ago

1.0.40

10 months ago

1.0.83

9 months ago

1.0.82

9 months ago

1.0.44

10 months ago

1.0.43

10 months ago

1.0.86

9 months ago

1.0.42

10 months ago

1.0.85

9 months ago

1.0.41

10 months ago

1.0.48

9 months ago

1.0.47

9 months ago

1.0.46

10 months ago

1.0.45

10 months ago

1.0.49

9 months ago

1.0.51

9 months ago

1.0.50

9 months ago

1.0.55

9 months ago

1.0.54

9 months ago

1.0.53

9 months ago

1.0.52

9 months ago

1.0.59

9 months ago

1.0.58

9 months ago

1.0.57

9 months ago

1.0.56

9 months ago

1.0.36

11 months ago

1.0.35

11 months ago

1.0.34

11 months ago

1.0.33

11 months ago

1.0.32

11 months ago

1.0.31

12 months ago

1.0.30

12 months ago

1.0.29

12 months ago

1.0.28

12 months ago

1.0.27

12 months ago

1.0.26

12 months ago

1.0.25

12 months ago

1.0.24

12 months ago

1.0.22

12 months ago

1.0.21

12 months ago

1.0.20

12 months ago

1.0.19

12 months ago

1.0.18

12 months ago

1.0.17

12 months ago

1.0.16

12 months ago

1.0.14

12 months ago

1.0.11

12 months ago

1.0.10

12 months ago

1.0.9

12 months ago

1.0.8

12 months ago

1.0.7

12 months ago

1.0.6

12 months ago

1.0.5

12 months ago

1.0.4

12 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

1 year ago