UNPKG

@kamino-finance/kliquidity-sdk

Version:

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

59 lines (54 loc) 1.79 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 UpdateRewardFunderArgs { rewardIndex: BN newFunder: Address } export interface UpdateRewardFunderAccounts { lbPair: Address admin: TransactionSigner eventAuthority: Address program: Address } export const layout = borsh.struct([ borsh.u64("rewardIndex"), borshAddress("newFunder"), ]) export function updateRewardFunder( args: UpdateRewardFunderArgs, accounts: UpdateRewardFunderAccounts, programAddress: Address = PROGRAM_ID ) { const keys: Array<IAccountMeta | IAccountSignerMeta> = [ { address: accounts.lbPair, role: 1 }, { address: accounts.admin.address, role: 2, signer: accounts.admin }, { address: accounts.eventAuthority, role: 0 }, { address: accounts.program, role: 0 }, ] const identifier = Buffer.from([211, 28, 48, 32, 215, 160, 35, 23]) const buffer = Buffer.alloc(1000) const len = layout.encode( { rewardIndex: args.rewardIndex, newFunder: args.newFunder, }, buffer ) const data = Buffer.concat([identifier, buffer]).slice(0, 8 + len) const ix: IInstruction = { accounts: keys, programAddress, data } return ix }