@marinade.finance/kamino-sdk
Version:
40 lines (37 loc) • 1.79 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 '@project-serum/borsh'; // eslint-disable-line @typescript-eslint/no-unused-vars
import * as types from '../types'; // eslint-disable-line @typescript-eslint/no-unused-vars
import { WHIRLPOOL_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) {
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: WHIRLPOOL_PROGRAM_ID, data });
return ix;
}