test-swap-sdk-knv-1 v1.0.86
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
SwapParams | Required | Description |
---|---|---|
chainId | No | ID for the chain for which the endpoint is being invoked. Note: Default chainID is 1 for Aptos Mainnet |
fromTokenAddress | Yes | Address of the token being swapped from.Example: If you want to swap 10.5 APT to lzUSDC, then fromTokenAddress is 0x1::aptos_coin::AptosCoin |
toTokenAddress | Yes | Address of the token being swapped to.Example: If you want to swap 10.5 APT to lzUSDC, then toTokenAddress is 0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC |
fromTokenAmount | Yes | Amount 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 |
toWalletAddress | Yes | Address of the wallet to which the swapped tokens will be sent |
slippagePercentage | No | Slippage 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 |
integratorFeePercentage | No | Integrator 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 |
integratorFeeAddress | No | Wallet Address where integrators want to receive their fee share.Note: Ensure it starts with 0x followed by 64 characters |
includeSources | No | List of liquidity sources to be included for route calculation.Example: "thala", "liquidswap"Note: If not specified, all available sources are included by default. |
excludeSources | No | List of liquidity sources to be excluded from the route.Example: "aux"Note: If not specified, none of the sources will be excluded by default. |
onlyDirectRoutes | No | Set 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
SwapParams | Required | Description |
---|---|---|
chainId | No | ID for the chain for which the endpoint is being invoked. Note: Default chainID is 1 for Aptos Mainnet |
fromTokenAddress | Yes | Address of the token being swapped from.Example: If you want to swap 10.5 APT to lzUSDC, then fromTokenAddress is 0x1::aptos_coin::AptosCoin |
toTokenAddress | Yes | Address of the token being swapped to.Example: If you want to swap 10.5 APT to lzUSDC, then toTokenAddress is 0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC |
toTokenAmount | Yes | Amount 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 |
toWalletAddress | Yes | Address of the wallet to which the swapped tokens will be sent |
slippagePercentage | No | Slippage 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 |
integratorFeePercentage | No | Integrator 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 |
integratorFeeAddress | No | Wallet Address where integrators want to receive their fee share.Note: Ensure it starts with 0x followed by 64 characters |
includeSources | No | List of liquidity sources to be included for route calculation.Example: "thala", "liquidswap"Note: If not specified, all available sources are included by default. |
excludeSources | No | List of liquidity sources to be excluded from the route.Example: "aux"Note: If not specified, none of the sources will be excluded by default. |
onlyDirectRoutes | No | Set 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
GetQuotesParams | Required | Description |
---|---|---|
chainId | No | ID for the chain for which the endpoint is being invoked. Note: Default chainID is 1 for Aptos Mainnet |
fromTokenAddress | Yes | Address of the token being swapped from.Example: If you want to swap 10.5 APT to lzUSDC, then fromTokenAddress is 0x1::aptos_coin::AptosCoin |
toTokenAddress | Yes | Address of the token being swapped to.Example: If you want to swap 10.5 APT to lzUSDC, then toTokenAddress is 0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC |
fromTokenAmount | Yes | Amount 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 |
slippagePercentage | No | Slippage 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 |
integratorFeePercentage | No | Integrator 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 |
integratorFeeAddress | No | Wallet Address where integrators want to receive their fee share.Note: Ensure it starts with 0x followed by 64 characters |
getTransactionData | No | Enter "rawTransaction" or "transactionPayload" to be included in the response. |
includeSources | No | List of liquidity sources to be included for route calculation.Example: "thala", "liquidswap"Note: If not specified, all available sources are included by default. |
excludeSources | No | List of liquidity sources to be excluded from the route.Example: "aux"Note: If not specified, none of the sources will be excluded by default. |
onlyDirectRoutes | No | Set 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
GetQuotesParams | Required | Description |
---|---|---|
chainId | No | ID for the chain for which the endpoint is being invoked. Note: Default chainID is 1 for Aptos Mainnet |
fromTokenAddress | Yes | Address of the token being swapped from.Example: If you want to swap 10.5 APT to lzUSDC, then fromTokenAddress is 0x1::aptos_coin::AptosCoin |
toTokenAddress | Yes | Address of the token being swapped to.Example: If you want to swap 10.5 APT to lzUSDC, then toTokenAddress is 0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC |
toTokenAmount | Yes | Amount 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 |
slippagePercentage | No | Slippage 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 |
integratorFeePercentage | No | Integrator 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 |
integratorFeeAddress | No | Wallet Address where integrators want to receive their fee share.Note: Ensure it starts with 0x followed by 64 characters |
getTransactionData | No | Enter "rawTransaction" or "transactionPayload" to be included in the response. |
includeSources | No | List of liquidity sources to be included for route calculation.Example: "thala", "liquidswap"Note: If not specified, all available sources are included by default. |
excludeSources | No | List of liquidity sources to be excluded from the route.Example: "aux"Note: If not specified, none of the sources will be excluded by default. |
onlyDirectRoutes | No | Set 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. |
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
10 months ago
9 months ago
9 months ago
10 months ago
10 months ago
9 months ago
9 months ago
10 months ago
9 months ago
9 months ago
10 months ago
10 months ago
9 months ago
10 months ago
9 months ago
10 months ago
9 months ago
9 months ago
10 months ago
10 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
9 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
12 months ago
1 year ago