UNPKG

@kamino-finance/kliquidity-sdk

Version:

Typescript SDK for interacting with the Kamino Liquidity (kliquidity) protocol

56 lines (51 loc) 1.71 kB
/* eslint-disable @typescript-eslint/no-unused-vars */ import { Address, isSome, IAccountMeta, IAccountSignerMeta, IInstruction, Option, TransactionSigner, } from "@solana/kit" /* eslint-enable @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 { borshAddress } from "../utils" // 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 SetRewardAuthorityArgs { rewardIndex: number } export interface SetRewardAuthorityAccounts { whirlpool: Address rewardAuthority: TransactionSigner newRewardAuthority: Address } export const layout = borsh.struct([borsh.u8("rewardIndex")]) export function setRewardAuthority( args: SetRewardAuthorityArgs, accounts: SetRewardAuthorityAccounts, programAddress: Address = PROGRAM_ID ) { const keys: Array<IAccountMeta | IAccountSignerMeta> = [ { address: accounts.whirlpool, role: 1 }, { address: accounts.rewardAuthority.address, role: 2, signer: accounts.rewardAuthority, }, { address: accounts.newRewardAuthority, role: 0 }, ] const identifier = Buffer.from([34, 39, 183, 252, 83, 28, 85, 127]) const buffer = Buffer.alloc(1000) const len = layout.encode( { rewardIndex: args.rewardIndex, }, buffer ) const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len) const ix: IInstruction = { accounts: keys, programAddress, data } return ix }