@kamino-finance/kliquidity-sdk
Version:
Typescript SDK for interacting with the Kamino Liquidity (kliquidity) protocol
49 lines (46 loc) • 2.15 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 ClaimFeeAccounts {
lbPair: PublicKey
position: PublicKey
binArrayLower: PublicKey
binArrayUpper: PublicKey
sender: PublicKey
reserveX: PublicKey
reserveY: PublicKey
userTokenX: PublicKey
userTokenY: PublicKey
tokenXMint: PublicKey
tokenYMint: PublicKey
tokenProgram: PublicKey
eventAuthority: PublicKey
program: PublicKey
}
export function claimFee(
accounts: ClaimFeeAccounts,
programId: PublicKey = PROGRAM_ID
) {
const keys: Array<AccountMeta> = [
{ pubkey: accounts.lbPair, isSigner: false, isWritable: true },
{ pubkey: accounts.position, isSigner: false, isWritable: true },
{ pubkey: accounts.binArrayLower, isSigner: false, isWritable: true },
{ pubkey: accounts.binArrayUpper, isSigner: false, isWritable: true },
{ pubkey: accounts.sender, isSigner: true, isWritable: false },
{ pubkey: accounts.reserveX, isSigner: false, isWritable: true },
{ pubkey: accounts.reserveY, isSigner: false, isWritable: true },
{ pubkey: accounts.userTokenX, isSigner: false, isWritable: true },
{ pubkey: accounts.userTokenY, isSigner: false, isWritable: true },
{ pubkey: accounts.tokenXMint, isSigner: false, isWritable: false },
{ pubkey: accounts.tokenYMint, isSigner: false, isWritable: false },
{ pubkey: accounts.tokenProgram, isSigner: false, isWritable: false },
{ pubkey: accounts.eventAuthority, isSigner: false, isWritable: false },
{ pubkey: accounts.program, isSigner: false, isWritable: false },
]
const identifier = Buffer.from([169, 32, 79, 137, 136, 232, 70, 137])
const data = identifier
const ix = new TransactionInstruction({ keys, programId, data })
return ix
}