Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gold-fans-marry.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@macalinao/clients-kamino-lending": patch
---

Set default for farms program
5 changes: 5 additions & 0 deletions .changeset/heavy-cougars-love.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@macalinao/clients-voter-stake-registry": patch
---

Update VSR idl with bytemuck info
11 changes: 11 additions & 0 deletions .changeset/proud-eagles-wink.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
"@macalinao/clients-voter-stake-registry": patch
"@macalinao/clients-orca-whirlpools": patch
"@macalinao/clients-kamino-lending": patch
"@macalinao/clients-spl-governance": patch
"@macalinao/clients-token-metadata": patch
"@macalinao/coda-visitors": patch
"@macalinao/coda": patch
---

Add default instruction account values for many programs
10 changes: 10 additions & 0 deletions bun.lock
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,10 @@
"name": "@macalinao/coda-visitors",
"version": "0.1.2",
"dependencies": {
"@solana-program/system": "^0.8.1",
"@solana-program/token": "^0.6.0",
"@solana-program/token-2022": "^0.5.0",
"@solana/sysvars": "^3.0.3",
"codama": "catalog:",
},
"devDependencies": {
Expand Down Expand Up @@ -681,6 +685,12 @@

"@shikijs/vscode-textmate": ["@shikijs/[email protected]", "", {}, "sha512-83yeghZ2xxin3Nj8z1NMd/NCuca+gsYXswywDy5bHvwlWL8tpTQmzGeUuHd9FC3E/SBEMvzJRwWEOz5gGes9Qg=="],

"@solana-program/system": ["@solana-program/[email protected]", "", { "peerDependencies": { "@solana/kit": "^3.0" } }, "sha512-71U9Mzdpw8HQtfgfJSL5xKZbLMRnza2Llsfk7gGnmg2waqK+o8MMH4YNma8xXS1UmOBptXIiNvoZ3p7cmOVktg=="],

"@solana-program/token": ["@solana-program/[email protected]", "", { "peerDependencies": { "@solana/kit": "^3.0" } }, "sha512-omkZh4Tt9rre4wzWHNOhOEHyenXQku3xyc/UrKvShexA/Qlhza67q7uRwmwEDUs4QqoDBidSZPooOmepnA/jig=="],

"@solana-program/token-2022": ["@solana-program/[email protected]", "", { "peerDependencies": { "@solana/kit": "^3.0", "@solana/sysvars": "^3.0" } }, "sha512-CJcFU2bXeXh2da7GAsBRBbmYbmMCBb7uQye0ePsv9pKbWm7r4sqMLoNEi5B+bHRIx9urTKAbmYlGnvWxC9htNg=="],

"@solana/accounts": ["@solana/[email protected]", "", { "dependencies": { "@solana/addresses": "3.0.3", "@solana/codecs-core": "3.0.3", "@solana/codecs-strings": "3.0.3", "@solana/errors": "3.0.3", "@solana/rpc-spec": "3.0.3", "@solana/rpc-types": "3.0.3" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-KqlePrlZaHXfu8YQTCxN204ZuVm9o68CCcUr6l27MG2cuRUtEM1Ta0iR8JFkRUAEfZJC4Cu0ZDjK/v49loXjZQ=="],

"@solana/addresses": ["@solana/[email protected]", "", { "dependencies": { "@solana/assertions": "3.0.3", "@solana/codecs-core": "3.0.3", "@solana/codecs-strings": "3.0.3", "@solana/errors": "3.0.3", "@solana/nominal-types": "3.0.3" }, "peerDependencies": { "typescript": ">=5.3.3" } }, "sha512-AuMwKhJI89ANqiuJ/fawcwxNKkSeHH9CApZd2xelQQLS7X8uxAOovpcmEgiObQuiVP944s9ScGUT62Bdul9qYg=="],
Expand Down
7 changes: 7 additions & 0 deletions clients/kamino-lending/coda.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
constantPdaSeedNodeFromString,
defineConfig,
numberTypeNode,
programLinkNode,
publicKeyTypeNode,
renameVisitor,
stringTypeNode,
Expand All @@ -16,6 +17,12 @@ export default defineConfig({
docs: {
npmPackageName: "@macalinao/clients-kamino-lending",
},
instructionAccountDefaultValues: [
{
account: "farmsProgram",
defaultValue: programLinkNode("farms"),
},
],
// We can add custom visitors here later if needed
visitors: [
addPdasVisitor({
Expand Down
12 changes: 10 additions & 2 deletions clients/kamino-lending/src/generated/instructions/addRewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ export type AddRewardsInstruction<
TAccountFarmVaultsAuthority extends string | AccountMeta = string,
TAccountPayerRewardTokenAta extends string | AccountMeta = string,
TAccountScopePrices extends string | AccountMeta = string,
TAccountTokenProgram extends string | AccountMeta = string,
TAccountTokenProgram extends
| string
| AccountMeta = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
TRemainingAccounts extends readonly AccountMeta[] = [],
> = Instruction<TProgram> &
InstructionWithData<ReadonlyUint8Array> &
Expand Down Expand Up @@ -147,7 +149,7 @@ export interface AddRewardsInput<
farmVaultsAuthority: Address<TAccountFarmVaultsAuthority>;
payerRewardTokenAta: Address<TAccountPayerRewardTokenAta>;
scopePrices?: Address<TAccountScopePrices>;
tokenProgram: Address<TAccountTokenProgram>;
tokenProgram?: Address<TAccountTokenProgram>;
amount: AddRewardsInstructionDataArgs["amount"];
rewardIndex: AddRewardsInstructionDataArgs["rewardIndex"];
}
Expand Down Expand Up @@ -213,6 +215,12 @@ export function getAddRewardsInstruction<
// Original args.
const args = { ...input };

// Resolve default values.
if (!accounts.tokenProgram.value) {
accounts.tokenProgram.value =
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">;
}

const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
return Object.freeze({
accounts: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,9 @@ export type BorrowObligationLiquidityInstruction<
| AccountMeta = string,
TAccountUserDestinationLiquidity extends string | AccountMeta = string,
TAccountReferrerTokenState extends string | AccountMeta = string,
TAccountTokenProgram extends string | AccountMeta = string,
TAccountTokenProgram extends
| string
| AccountMeta = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
TAccountInstructionSysvarAccount extends
| string
| AccountMeta = "Sysvar1nstructions1111111111111111111111111",
Expand Down Expand Up @@ -174,7 +176,7 @@ export interface BorrowObligationLiquidityInput<
borrowReserveLiquidityFeeReceiver: Address<TAccountBorrowReserveLiquidityFeeReceiver>;
userDestinationLiquidity: Address<TAccountUserDestinationLiquidity>;
referrerTokenState?: Address<TAccountReferrerTokenState>;
tokenProgram: Address<TAccountTokenProgram>;
tokenProgram?: Address<TAccountTokenProgram>;
instructionSysvarAccount?: Address<TAccountInstructionSysvarAccount>;
liquidityAmount: BorrowObligationLiquidityInstructionDataArgs["liquidityAmount"];
}
Expand Down Expand Up @@ -273,6 +275,10 @@ export function getBorrowObligationLiquidityInstruction<
const args = { ...input };

// Resolve default values.
if (!accounts.tokenProgram.value) {
accounts.tokenProgram.value =
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">;
}
if (!accounts.instructionSysvarAccount.value) {
accounts.instructionSysvarAccount.value =
"Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ import {
getU64Encoder,
transformEncoder,
} from "@solana/kit";
import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js";
import {
FARMS_PROGRAM_ADDRESS,
KAMINO_LENDING_PROGRAM_ADDRESS,
} from "../programs/index.js";
import { getAccountMetaFactory } from "../shared/index.js";

export const BORROW_OBLIGATION_LIQUIDITY_V2_DISCRIMINATOR: ReadonlyUint8Array =
Expand All @@ -61,13 +64,17 @@ export type BorrowObligationLiquidityV2Instruction<
| AccountMeta = string,
TAccountUserDestinationLiquidity extends string | AccountMeta = string,
TAccountReferrerTokenState extends string | AccountMeta = string,
TAccountTokenProgram extends string | AccountMeta = string,
TAccountTokenProgram extends
| string
| AccountMeta = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
TAccountInstructionSysvarAccount extends
| string
| AccountMeta = "Sysvar1nstructions1111111111111111111111111",
TAccountObligationFarmUserState extends string | AccountMeta = string,
TAccountReserveFarmState extends string | AccountMeta = string,
TAccountFarmsProgram extends string | AccountMeta = string,
TAccountFarmsProgram extends
| string
| AccountMeta = "FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr",
TRemainingAccounts extends readonly AccountMeta[] = [],
> = Instruction<TProgram> &
InstructionWithData<ReadonlyUint8Array> &
Expand Down Expand Up @@ -189,11 +196,11 @@ export interface BorrowObligationLiquidityV2Input<
borrowReserveLiquidityFeeReceiver: Address<TAccountBorrowReserveLiquidityFeeReceiver>;
userDestinationLiquidity: Address<TAccountUserDestinationLiquidity>;
referrerTokenState?: Address<TAccountReferrerTokenState>;
tokenProgram: Address<TAccountTokenProgram>;
tokenProgram?: Address<TAccountTokenProgram>;
instructionSysvarAccount?: Address<TAccountInstructionSysvarAccount>;
obligationFarmUserState?: Address<TAccountObligationFarmUserState>;
reserveFarmState?: Address<TAccountReserveFarmState>;
farmsProgram: Address<TAccountFarmsProgram>;
farmsProgram?: Address<TAccountFarmsProgram>;
liquidityAmount: BorrowObligationLiquidityV2InstructionDataArgs["liquidityAmount"];
}

Expand Down Expand Up @@ -309,10 +316,18 @@ export function getBorrowObligationLiquidityV2Instruction<
const args = { ...input };

// Resolve default values.
if (!accounts.tokenProgram.value) {
accounts.tokenProgram.value =
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">;
}
if (!accounts.instructionSysvarAccount.value) {
accounts.instructionSysvarAccount.value =
"Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">;
}
if (!accounts.farmsProgram.value) {
accounts.farmsProgram.value = FARMS_PROGRAM_ADDRESS;
accounts.farmsProgram.isWritable = false;
}

const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
return Object.freeze({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,12 @@ export type DeleteReferrerStateAndShortUrlInstruction<
TAccountReferrer extends string | AccountMeta = string,
TAccountReferrerState extends string | AccountMeta = string,
TAccountShortUrl extends string | AccountMeta = string,
TAccountRent extends string | AccountMeta = string,
TAccountSystemProgram extends string | AccountMeta = string,
TAccountRent extends
| string
| AccountMeta = "SysvarRent111111111111111111111111111111111",
TAccountSystemProgram extends
| string
| AccountMeta = "11111111111111111111111111111111",
TRemainingAccounts extends readonly AccountMeta[] = [],
> = Instruction<TProgram> &
InstructionWithData<ReadonlyUint8Array> &
Expand Down Expand Up @@ -119,8 +123,8 @@ export interface DeleteReferrerStateAndShortUrlInput<
referrer: TransactionSigner<TAccountReferrer>;
referrerState: Address<TAccountReferrerState>;
shortUrl: Address<TAccountShortUrl>;
rent: Address<TAccountRent>;
systemProgram: Address<TAccountSystemProgram>;
rent?: Address<TAccountRent>;
systemProgram?: Address<TAccountSystemProgram>;
}

export function getDeleteReferrerStateAndShortUrlInstruction<
Expand Down Expand Up @@ -164,6 +168,16 @@ export function getDeleteReferrerStateAndShortUrlInstruction<
ResolvedAccount
>;

// Resolve default values.
if (!accounts.rent.value) {
accounts.rent.value =
"SysvarRent111111111111111111111111111111111" as Address<"SysvarRent111111111111111111111111111111111">;
}
if (!accounts.systemProgram.value) {
accounts.systemProgram.value =
"11111111111111111111111111111111" as Address<"11111111111111111111111111111111">;
}

const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
return Object.freeze({
accounts: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ import {
getU64Encoder,
transformEncoder,
} from "@solana/kit";
import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js";
import {
FARMS_PROGRAM_ADDRESS,
KAMINO_LENDING_PROGRAM_ADDRESS,
} from "../programs/index.js";
import { getAccountMetaFactory } from "../shared/index.js";

export const DEPOSIT_AND_WITHDRAW_DISCRIMINATOR: ReadonlyUint8Array =
Expand Down Expand Up @@ -129,7 +132,9 @@ export type DepositAndWithdrawInstruction<
TAccountWithdrawFarmsAccountsReserveFarmState extends
| string
| AccountMeta = string,
TAccountFarmsProgram extends string | AccountMeta = string,
TAccountFarmsProgram extends
| string
| AccountMeta = "FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr",
TRemainingAccounts extends readonly AccountMeta[] = [],
> = Instruction<TProgram> &
InstructionWithData<ReadonlyUint8Array> &
Expand Down Expand Up @@ -353,7 +358,7 @@ export interface DepositAndWithdrawInput<
depositFarmsAccountsReserveFarmState?: Address<TAccountDepositFarmsAccountsReserveFarmState>;
withdrawFarmsAccountsObligationFarmUserState?: Address<TAccountWithdrawFarmsAccountsObligationFarmUserState>;
withdrawFarmsAccountsReserveFarmState?: Address<TAccountWithdrawFarmsAccountsReserveFarmState>;
farmsProgram: Address<TAccountFarmsProgram>;
farmsProgram?: Address<TAccountFarmsProgram>;
liquidityAmount: DepositAndWithdrawInstructionDataArgs["liquidityAmount"];
withdrawCollateralAmount: DepositAndWithdrawInstructionDataArgs["withdrawCollateralAmount"];
}
Expand Down Expand Up @@ -619,6 +624,10 @@ export function getDepositAndWithdrawInstruction<
accounts.withdrawAccountsInstructionSysvarAccount.value =
"Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">;
}
if (!accounts.farmsProgram.value) {
accounts.farmsProgram.value = FARMS_PROGRAM_ADDRESS;
accounts.farmsProgram.isWritable = false;
}

const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
return Object.freeze({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ import {
getU64Encoder,
transformEncoder,
} from "@solana/kit";
import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js";
import {
FARMS_PROGRAM_ADDRESS,
KAMINO_LENDING_PROGRAM_ADDRESS,
} from "../programs/index.js";
import { getAccountMetaFactory } from "../shared/index.js";

export const DEPOSIT_OBLIGATION_COLLATERAL_V2_DISCRIMINATOR: ReadonlyUint8Array =
Expand All @@ -55,14 +58,18 @@ export type DepositObligationCollateralV2Instruction<
TAccountDepositReserve extends string | AccountMeta = string,
TAccountReserveDestinationCollateral extends string | AccountMeta = string,
TAccountUserSourceCollateral extends string | AccountMeta = string,
TAccountTokenProgram extends string | AccountMeta = string,
TAccountTokenProgram extends
| string
| AccountMeta = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
TAccountInstructionSysvarAccount extends
| string
| AccountMeta = "Sysvar1nstructions1111111111111111111111111",
TAccountLendingMarketAuthority extends string | AccountMeta = string,
TAccountObligationFarmUserState extends string | AccountMeta = string,
TAccountReserveFarmState extends string | AccountMeta = string,
TAccountFarmsProgram extends string | AccountMeta = string,
TAccountFarmsProgram extends
| string
| AccountMeta = "FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr",
TRemainingAccounts extends readonly AccountMeta[] = [],
> = Instruction<TProgram> &
InstructionWithData<ReadonlyUint8Array> &
Expand Down Expand Up @@ -168,12 +175,12 @@ export interface DepositObligationCollateralV2Input<
depositReserve: Address<TAccountDepositReserve>;
reserveDestinationCollateral: Address<TAccountReserveDestinationCollateral>;
userSourceCollateral: Address<TAccountUserSourceCollateral>;
tokenProgram: Address<TAccountTokenProgram>;
tokenProgram?: Address<TAccountTokenProgram>;
instructionSysvarAccount?: Address<TAccountInstructionSysvarAccount>;
lendingMarketAuthority: Address<TAccountLendingMarketAuthority>;
obligationFarmUserState?: Address<TAccountObligationFarmUserState>;
reserveFarmState?: Address<TAccountReserveFarmState>;
farmsProgram: Address<TAccountFarmsProgram>;
farmsProgram?: Address<TAccountFarmsProgram>;
collateralAmount: DepositObligationCollateralV2InstructionDataArgs["collateralAmount"];
}

Expand Down Expand Up @@ -268,10 +275,18 @@ export function getDepositObligationCollateralV2Instruction<
const args = { ...input };

// Resolve default values.
if (!accounts.tokenProgram.value) {
accounts.tokenProgram.value =
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA" as Address<"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA">;
}
if (!accounts.instructionSysvarAccount.value) {
accounts.instructionSysvarAccount.value =
"Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">;
}
if (!accounts.farmsProgram.value) {
accounts.farmsProgram.value = FARMS_PROGRAM_ADDRESS;
accounts.farmsProgram.isWritable = false;
}

const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
return Object.freeze({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ import {
getU64Encoder,
transformEncoder,
} from "@solana/kit";
import { KAMINO_LENDING_PROGRAM_ADDRESS } from "../programs/index.js";
import {
FARMS_PROGRAM_ADDRESS,
KAMINO_LENDING_PROGRAM_ADDRESS,
} from "../programs/index.js";
import { getAccountMetaFactory } from "../shared/index.js";

export const DEPOSIT_RESERVE_LIQUIDITY_AND_OBLIGATION_COLLATERAL_V2_DISCRIMINATOR: ReadonlyUint8Array =
Expand Down Expand Up @@ -71,7 +74,9 @@ export type DepositReserveLiquidityAndObligationCollateralV2Instruction<
| AccountMeta = "Sysvar1nstructions1111111111111111111111111",
TAccountObligationFarmUserState extends string | AccountMeta = string,
TAccountReserveFarmState extends string | AccountMeta = string,
TAccountFarmsProgram extends string | AccountMeta = string,
TAccountFarmsProgram extends
| string
| AccountMeta = "FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr",
TRemainingAccounts extends readonly AccountMeta[] = [],
> = Instruction<TProgram> &
InstructionWithData<ReadonlyUint8Array> &
Expand Down Expand Up @@ -208,7 +213,7 @@ export interface DepositReserveLiquidityAndObligationCollateralV2Input<
instructionSysvarAccount?: Address<TAccountInstructionSysvarAccount>;
obligationFarmUserState?: Address<TAccountObligationFarmUserState>;
reserveFarmState?: Address<TAccountReserveFarmState>;
farmsProgram: Address<TAccountFarmsProgram>;
farmsProgram?: Address<TAccountFarmsProgram>;
liquidityAmount: DepositReserveLiquidityAndObligationCollateralV2InstructionDataArgs["liquidityAmount"];
}

Expand Down Expand Up @@ -345,6 +350,10 @@ export function getDepositReserveLiquidityAndObligationCollateralV2Instruction<
accounts.instructionSysvarAccount.value =
"Sysvar1nstructions1111111111111111111111111" as Address<"Sysvar1nstructions1111111111111111111111111">;
}
if (!accounts.farmsProgram.value) {
accounts.farmsProgram.value = FARMS_PROGRAM_ADDRESS;
accounts.farmsProgram.isWritable = false;
}

const getAccountMeta = getAccountMetaFactory(programAddress, "programId");
return Object.freeze({
Expand Down
Loading