@kamino-finance/farms-sdk
Version:
42 lines (39 loc) • 1.45 kB
text/typescript
/* 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 RefreshUserStateAccounts {
userState: Address
farmState: Address
scopePrices: Option<Address>
}
export function refreshUserState(
accounts: RefreshUserStateAccounts,
remainingAccounts: Array<IAccountMeta | IAccountSignerMeta> = [],
programAddress: Address = PROGRAM_ID
) {
const keys: Array<IAccountMeta | IAccountSignerMeta> = [
{ address: accounts.userState, role: 1 },
{ address: accounts.farmState, role: 1 },
isSome(accounts.scopePrices)
? { address: accounts.scopePrices.value, role: 0 }
: { address: programAddress, role: 0 },
...remainingAccounts,
]
const identifier = Buffer.from([1, 135, 12, 62, 243, 140, 77, 108])
const data = identifier
const ix: IInstruction = { accounts: keys, programAddress, data }
return ix
}