@kamino-finance/klend-sdk 5.14.3 → 5.14.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -287,6 +287,18 @@ export function orThrow(message: string): never {
287
287
  throw new Error(message);
288
288
  }
289
289
 
290
+ export function blobEquals(left: Uint8Array, right: Uint8Array): boolean {
291
+ if (left.length !== right.length) {
292
+ return false;
293
+ }
294
+ for (let i = 0; i < left.length; ++i) {
295
+ if (left[i] !== right[i]) {
296
+ return false;
297
+ }
298
+ }
299
+ return true;
300
+ }
301
+
290
302
  /**
291
303
  * Returns an integer {@link Decimal} nearest to the given one.
292
304
  *
@@ -11,7 +11,13 @@ import {
11
11
  SYSVAR_RENT_PUBKEY,
12
12
  TransactionInstruction,
13
13
  } from '@solana/web3.js';
14
- import { getAssociatedTokenAddressSync, NATIVE_MINT, TOKEN_PROGRAM_ID, unpackAccount } from '@solana/spl-token';
14
+ import {
15
+ createCloseAccountInstruction,
16
+ getAssociatedTokenAddressSync,
17
+ NATIVE_MINT,
18
+ TOKEN_PROGRAM_ID,
19
+ unpackAccount,
20
+ } from '@solana/spl-token';
15
21
  import {
16
22
  getAssociatedTokenAddress,
17
23
  getTransferWsolIxs,
@@ -1064,6 +1070,7 @@ export class KaminoVaultClient {
1064
1070
  const withdrawIxs: WithdrawIxs = {
1065
1071
  unstakeFromFarmIfNeededIxs: [],
1066
1072
  withdrawIxs: [],
1073
+ postWithdrawIxs: [],
1067
1074
  };
1068
1075
 
1069
1076
  const shareLamportsToWithdraw = collToLamportsDecimal(shareAmount, vaultState.sharesMintDecimals.toNumber());
@@ -1099,6 +1106,13 @@ export class KaminoVaultClient {
1099
1106
  withdrawIxs.withdrawIxs = withdrawFromVaultIxs;
1100
1107
  }
1101
1108
 
1109
+ // if the vault is for SOL return the ix to unwrap the SOL
1110
+ if (vaultState.tokenMint.equals(NATIVE_MINT)) {
1111
+ const userWsolAta = getAssociatedTokenAddress(NATIVE_MINT, user);
1112
+ const unwrapIx = createCloseAccountInstruction(userWsolAta, user, user, [], TOKEN_PROGRAM_ID);
1113
+ withdrawIxs.postWithdrawIxs.push(unwrapIx);
1114
+ }
1115
+
1102
1116
  return withdrawIxs;
1103
1117
  }
1104
1118
 
@@ -48,6 +48,7 @@ export type DepositIxs = {
48
48
  export type WithdrawIxs = {
49
49
  unstakeFromFarmIfNeededIxs: TransactionInstruction[];
50
50
  withdrawIxs: TransactionInstruction[];
51
+ postWithdrawIxs: TransactionInstruction[]; // wSOL ATA close ix
51
52
  };
52
53
 
53
54
  /** The shares an user has in a vault (staked and unstaked), in tokens */
@@ -895,7 +895,7 @@ async function main() {
895
895
  const withdrawSig = await processTxn(
896
896
  env.client,
897
897
  env.payer,
898
- [...withdrawIxs.unstakeFromFarmIfNeededIxs, ...withdrawIxs.withdrawIxs],
898
+ [...withdrawIxs.unstakeFromFarmIfNeededIxs, ...withdrawIxs.withdrawIxs, ...withdrawIxs.postWithdrawIxs],
899
899
  mode,
900
900
  2500,
901
901
  [],
@@ -1156,6 +1156,10 @@ async function main() {
1156
1156
  printHoldings(holdings);
1157
1157
  console.log(`Tokens per share for vault ${vaultAddress.toBase58()}: ${tokensPerShare}`);
1158
1158
  console.log('vaultOverview', vaultOverview);
1159
+
1160
+ for (const [reserveAddress, reserveOverview] of vaultOverview.reservesOverview) {
1161
+ console.log(`reserve ${reserveAddress.toBase58()} supplyAPY ${reserveOverview.supplyAPY}`);
1162
+ }
1159
1163
  });
1160
1164
 
1161
1165
  commands.command('get-oracle-mappings').action(async () => {