1.0.15 • Published 1 year ago
text-swap-widget-knv-1 v1.0.15
@panoraexchange/swap-sdk
SDK to perform the most optimal swap
Installtion
Using npm
npm i @panoraexchange/swap-sdkUsing yarn
yarn add @panoraexchange/swap-sdkUsing pnpm
pnpm add @panoraexchange/swap-sdkFor complete example of SDK usage please refer to the docs
https://docs.panora.exchange/developer/swap-aggregator-api-and-sdk/aggregator-sdk
Usage
Swap Functions
1. Swap transaction Function to get maximum toToken amount
ExactInSwap = async (SwapParamas, private_key);SwapParams is an object with the below field
| SwapParamas | Required | Description |
|---|---|---|
| chainId | No | ID for the chain. Note: Since Panora is only on Aptos, chainId=1. |
| fromTokenAddress | Yes | Address of the token being swapped. |
| fromTokenAmount | Yes | Amount of the token being swapped. |
| toTokenAddress | Yes | Address of the token being swapped to. |
| toWalletAddress | Yes | Address of the wallet in which the transaction will happen |
| slippagePercentage | No | Percentage of the slippage to be considered. |
2. Swap transaction fucntion to get desire amount of outToken
ExactOutSwap = async (SwapParamas, private_key)SwapParams is an object with the below field
| SwapParamas | Required | Description |
|---|---|---|
| chainId | No | ID for the chain. Note: Since Panora is only on Aptos, chainId=1. |
| fromTokenAddress | Yes | Address of the token being swapped. |
| toTokenAmount | Yes | Amount of token user desire to get after the swap. |
| toTokenAddress | Yes | Address of the token being swapped to. |
| toWalletAddress | Yes | Address of the wallet in which the transaction will happen. |
| slippagePercentage | No | Percentage of the slippage to be considered. |
Get Quote Functions
1. Get the Quote for maximum possible toToken
ExactInSwapQuote = async (GetQuotesParamas)GetQuoteParamas is an object with the below fields
| GetQuotesParamas | Required | Description |
|---|---|---|
| chainId | No | ID for the chain. Note: Since Panora is only on Aptos, chainId=1. |
| fromTokenAddress | Yes | Address of the token being swapped. |
| fromTokenAmount | Yes | Amount of the token being swapped. |
| toTokenAddress | Yes | Address of the token being swapped to. |
| slippagePercentage | No | Percentage of the slippage to be considered. |
2. Get the Quote for desire amount of toToken with minimum fromToken amount
ExactOutSwapQuote = async (GetQuotesParamas)GetQuoteParamas is an object with the below fields
| GetQuotesParamas | Required | Description |
|---|---|---|
| chainId | No | ID for the chain. Note: Since Panora is only on Aptos, chainId=1. |
| fromTokenAddress | Yes | Address of the token being swapped. |
| toTokenAmount | Yes | Amount of token user desire to get after the swap. |
| toTokenAddress | Yes | Address of the token being swapped to. |
| slippagePercentage | No | Percentage of the slippage to be considered. |