kana-ag-sdk
v1.2.2
Published
## Description * SDK to interact with all aggregator platform available on kanalabs
Downloads
4
Readme
Kanalabs aggregator sdk
Description
- SDK to interact with all aggregator platform available on kanalabs
SDK Usage
npm i kana-ag-sdk
import { getRoutesForSwap, getSwapIx} from 'kana-ag-sdk'
import {Transaction,sendAndConfirmTransaction} from '@solana/web3.js'
let connection = "your rpc"
async function swap(){
let routes = await getRoutesForSwap("Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB", //fromToken
"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v", //toToken
10 //amount
) //further options will be added soon
let optimalRoute = routes.routesInfos[0]?.marketInfos //this will be the optimal route
let ix = await getSwapIx(optimalRoute, ownerKey.publicKey.toString())
const transaction = Transaction.from(Buffer.from(ix.serializedTransaction, 'base64'))
let signature = await sendAndConfirmTransaction(connection, transaction, [ownerKeypair])
console.log(signature)
}
swap()