@kamino-finance/kliquidity-sdk
Version:
Typescript SDK for interacting with the Kamino Liquidity (kliquidity) protocol
43 lines (40 loc) • 1.77 kB
text/typescript
import { TransactionInstruction, PublicKey, AccountMeta } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
import { PROGRAM_ID } from "../programId"
export interface CollectFeesAccounts {
whirlpool: PublicKey
positionAuthority: PublicKey
position: PublicKey
positionTokenAccount: PublicKey
tokenOwnerAccountA: PublicKey
tokenVaultA: PublicKey
tokenOwnerAccountB: PublicKey
tokenVaultB: PublicKey
tokenProgram: PublicKey
}
export function collectFees(
accounts: CollectFeesAccounts,
programId: PublicKey = PROGRAM_ID
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.whirlpool, isSigner: false, isWritable: false },
{ pubkey: accounts.positionAuthority, isSigner: true, isWritable: false },
{ pubkey: accounts.position, isSigner: false, isWritable: true },
{
pubkey: accounts.positionTokenAccount,
isSigner: false,
isWritable: false,
},
{ pubkey: accounts.tokenOwnerAccountA, isSigner: false, isWritable: true },
{ pubkey: accounts.tokenVaultA, isSigner: false, isWritable: true },
{ pubkey: accounts.tokenOwnerAccountB, isSigner: false, isWritable: true },
{ pubkey: accounts.tokenVaultB, isSigner: false, isWritable: true },
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
]
const identifier = Buffer.from([164, 152, 207, 99, 30, 186, 19, 182])
const data = identifier
const ix = new TransactionInstruction({ keys, programId, data })
return ix
}