🖥️Aggregator SDK
A wrapper over the Panora API to provide functions to swap between any two tokens easily
Installation
Using npm
npm install @panoraexchange/swap-sdk
Using yarn
yarn add @panoraexchange/swap-sdk
Using pnpm
pnpm add @panoraexchange/swap-sdk
Usage
1. Initialize Panora SDK
import Panora, { PanoraConfig } from "@panoraexchange/swap-sdk"
const config: PanoraConfig = {
apiKey: "YOUR API KEY",
rpcUrl: "CUSTOM RPC URL"
}
const client = new Panora(config)
Public API Key:
a4^KV_EaTf4MW#ZdvgGKX#HUD^3IFEAOV_kzpIE^3BQGA8pDnrkT7JcIy#HNlLGi
Note: For large-scale apps, please raise a ticket on Discord for a dedicated key.
2. Swap Functions
i. ExactInSwap:
const exactInSwap = async () => {
const response = await client.ExactInSwap(
{
chainId: "1",
fromTokenAddress: "0x1::aptos_coin::AptosCoin",
toTokenAddress:
"0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
fromTokenAmount: "1",
toWalletAddress: "YOUR WALLET ADDRESS",
slippagePercentage: "1",
integratorFeeAddress: "INTEGRATOR FEE WALLET ADDRESS",
integratorFeePercentage: "1",
},
"YOUR PRIVATE KEY"
)
}
ii. ExactOutSwap:
const exactOutSwap = async () => {
const response = await client.ExactOutSwap(
{
chainId: "1",
fromTokenAddress: "0x1::aptos_coin::AptosCoin",
toTokenAddress:
"0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
toTokenAmount: "12",
toWalletAddress: "YOUR WALLET ADDRESS",
slippagePercentage: "1",
integratorFeeAddress: "INTEGRATOR FEE WALLET ADDRESS",
integratorFeePercentage: "1",
},
"YOUR PRIVATE KEY"
)
}
iii. ExactInSwapBatch:
const exactInSwapBatch = async () => {
const response = await client.ExactInSwapBatch(
[
{
chainId: "1",
fromTokenAddress: "0x1::aptos_coin::AptosCoin",
toTokenAddress:
"0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
fromTokenAmount: "1",
toWalletAddress: "YOUR WALLET ADDRESS",
slippagePercentage: "1",
integratorFeeAddress: "INTEGRATOR FEE WALLET ADDRESS",
integratorFeePercentage: "1",
},
{
chainId: "1",
fromTokenAddress:
"0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDT",
toTokenAddress:
"0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::WETH",
fromTokenAmount: "1",
toWalletAddress: "YOUR WALLET ADDRESS",
slippagePercentage: "1",
integratorFeeAddress: "INTEGRATOR FEE WALLET ADDRESS",
integratorFeePercentage: "1",
},
],
"YOUR PRIVATE KEY"
)
}
iv. ExactOutSwapBatch:
const exactOutSwapBatch = async () => {
const response = await client.ExactOutSwapBatch(
[
{
chainId: "1",
fromTokenAddress: "0x1::aptos_coin::AptosCoin",
toTokenAddress:
"0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
toTokenAmount: "1",
toWalletAddress: "YOUR WALLET ADDRESS",
slippagePercentage: "1",
integratorFeeAddress: "INTEGRATOR FEE ADDRESS",
integratorFeePercentage: "1",
},
{
chainId: "1",
fromTokenAddress:
"0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDT",
toTokenAddress:
"0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::WETH",
toTokenAmount: "1",
toWalletAddress: "YOUR WALLET ADDRESS",
slippagePercentage: "1",
integratorFeeAddress: "INTEGRATOR FEE WALLET ADDRESS",
integratorFeePercentage: "1",
},
],
"YOUR PRIVATE KEY"
)
}
3. Quote Functions
i. ExactInSwapQuote
const exactInSwapQuote = async () => {
const response = await client.ExactInSwapQuote({
chainId: "1",
fromTokenAddress: "0x1::aptos_coin::AptosCoin",
toTokenAddress:
"0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
fromTokenAmount: "1",
toWalletAddress: "YOUR WALLET ADDRESS",
slippagePercentage: "1",
integratorFeeAddress: "INTEGRATOR FEE WALLET ADDRESS",
integratorFeePercentage: "1",
// "rawTransaction" | "transactionPayload" depending on the use case
getTransactionData: "rawTransaction"
})
}
ii. ExactOutSwapQuote
const exactOutSwapQuote = async () => {
const response = await client.ExactOutSwapQuote({
chainId: "1",
fromTokenAddress: "0x1::aptos_coin::AptosCoin",
toTokenAddress:
"0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
toTokenAmount: "1",
toWalletAddress: "YOUR WALLET ADDRESS",
slippagePercentage: "1",
integratorFeeAddress: "INTEGRATOR FEE WALLET ADDRESS",
integratorFeePercentage: "1",
})
}
Attribution
Kindly include proper attribution when using the API in projects or presentations. Mention “Powered by Panora” wherever applicable.
Last updated