@kamino-finance/klend-sdk 5.13.5 → 5.13.7

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.
@@ -290,13 +290,20 @@ async function main() {
290
290
  const _createVaultSig = await processTxn(
291
291
  env.client,
292
292
  env.payer,
293
- [...instructions.initVaultIxs, instructions.createLUTIx, instructions.initSharesMetadataIx],
293
+ [...instructions.createAtaIfNeededIxs, ...instructions.initVaultIxs, instructions.createLUTIx],
294
294
  mode,
295
295
  2500,
296
296
  [vaultKp]
297
297
  );
298
298
  await sleep(2000);
299
- const _populateLUTSig = await processTxn(env.client, env.payer, instructions.populateLUTIxs, mode, 2500, []);
299
+ const _populateLUTSig = await processTxn(
300
+ env.client,
301
+ env.payer,
302
+ [...instructions.populateLUTIxs, ...instructions.cleanupIxs],
303
+ mode,
304
+ 2500,
305
+ []
306
+ );
300
307
 
301
308
  const _setSharesMetadataSig = await processTxn(
302
309
  env.client,
@@ -679,6 +686,42 @@ async function main() {
679
686
  mode === 'execute' && console.log('Pending fees withdrawn:', withdrawPendingFeesSig);
680
687
  });
681
688
 
689
+ commands
690
+ .command('remove-vault-allocation')
691
+ .requiredOption('--vault <string>', 'Vault address')
692
+ .requiredOption('--reserve <string>', 'Reserve address')
693
+ .requiredOption(
694
+ `--mode <string>`,
695
+ 'simulate - to print txn simulation, inspect - to get txn simulation in explorer, execute - execute txn, multisig - to get bs58 txn for multisig usage'
696
+ )
697
+ .option(`--staging`, 'If true, will use the staging programs')
698
+ .option(`--multisig <string>`, 'If using multisig mode this is required, otherwise will be ignored')
699
+ .action(async ({ vault, reserve, mode, staging, multisig }) => {
700
+ const env = initializeClient(mode === 'multisig', staging);
701
+ const reserveAddress = new PublicKey(reserve);
702
+ const vaultAddress = new PublicKey(vault);
703
+
704
+ if (mode === 'multisig' && !multisig) {
705
+ throw new Error('If using multisig mode, multisig is required');
706
+ }
707
+
708
+ const kaminoManager = new KaminoManager(
709
+ env.connection,
710
+ DEFAULT_RECENT_SLOT_DURATION_MS,
711
+ env.kLendProgramId,
712
+ env.kVaultProgramId
713
+ );
714
+
715
+ const kaminoVault = new KaminoVault(vaultAddress, undefined, env.kVaultProgramId);
716
+ const instruction = await kaminoManager.removeReserveFromAllocationIx(kaminoVault, reserveAddress);
717
+
718
+ if (instruction) {
719
+ const updateVaultAllocationSig = await processTxn(env.client, env.payer, [instruction], mode, 2500, []);
720
+
721
+ mode === 'execute' && console.log('Vault allocation updated:', updateVaultAllocationSig);
722
+ }
723
+ });
724
+
682
725
  commands
683
726
  .command('stake')
684
727
  .requiredOption('--vault <string>', 'Vault address')
@@ -43,7 +43,7 @@ export function resolveMetadataFromToken(token: string, extra: string): { name:
43
43
  console.log('token', token);
44
44
  console.log('extra', extra);
45
45
  const name = `kVault ${token} ${extra}`;
46
- const symbol = `kV${token.toUpperCase()}`;
46
+ const symbol = `kV-${token.toUpperCase()}`;
47
47
  return { name, symbol };
48
48
  }
49
49
 
@@ -0,0 +1,33 @@
1
+ import { PublicKey } from '@solana/web3.js';
2
+
3
+ const SQUADS_API_BASE_URL = 'https://4fnetmviidiqkjzenwxe66vgoa0soerr.lambda-url.us-east-1.on.aws/';
4
+
5
+ export async function walletIsSquadsMultisig(wallet: PublicKey) {
6
+ const response = await fetch(`${SQUADS_API_BASE_URL}/is-multisig?wallet=${wallet.toBase58()}`);
7
+ const data = await response.json();
8
+ const squadsResponse = data as SquadsMultisigResponse;
9
+ return squadsResponse.isSquad;
10
+ }
11
+
12
+ // todo: find a way to get the admins number and threshold
13
+ export async function getSquadsMultisigAdminsAndThreshold(_wallet: PublicKey): Promise<{
14
+ adminsNumber: number;
15
+ threshold: number;
16
+ }> {
17
+ return {
18
+ adminsNumber: 1,
19
+ threshold: 1,
20
+ };
21
+ }
22
+
23
+ // {"isSquad":true,"version":"v3"}
24
+ export type SquadsMultisigResponse = {
25
+ isSquad: boolean;
26
+ version: string;
27
+ };
28
+
29
+ export interface WalletType {
30
+ walletType: 'simpleWallet' | 'squadsMultisig';
31
+ walletAdminsNumber: number;
32
+ walletThreshold: number;
33
+ }