npm install @panoraexchange/swap-sdk
yarn add @panoraexchange/swap-sdk
pnpm add @panoraexchange/swap-sdk
import Panora, { PanoraConfig } from "@panoraexchange/swap-sdk"
const config: PanoraConfig = {
apiKey: "YOUR API KEY",
rpcUrl: "CUSTOM RPC URL"
}
const client = new Panora(config)
const exactInSwap = async () => {
const response = await client.Swap(
{
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"
)
}
const exactOutSwap = async () => {
const response = await client.Swap(
{
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"
)
}
const exactInSwapBatch = async () => {
const response = await client.BatchSwap(
[
{
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: "0x1::aptos_coin::AptosCoin",
toTokenAddress:
"0xf22bede237a07e121b56d91a491eb7bcdfd1f5907926a9e58338f964a01b17fa::asset::USDC",
toTokenAmount: "1",
toWalletAddress: "YOUR WALLET ADDRESS",
slippagePercentage: "1",
integratorFeeAddress: "INTEGRATOR FEE ADDRESS",
integratorFeePercentage: "1",
},
],
"YOUR PRIVATE KEY"
)
}
const exactInSwapQuote = async () => {
const response = await client.SwapQuote({
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"
})
}
const exactOutSwapQuote = async () => {
const response = await client.SwapQuote({
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",
})
}
Kindly include proper attribution when using the API in projects or presentations. Mention βPowered by Panoraβ wherever applicable.