@kamino-finance/klend-sdk 5.10.0 → 5.10.2
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.
- package/dist/classes/farm_utils.d.ts +22 -0
- package/dist/classes/farm_utils.d.ts.map +1 -0
- package/dist/classes/farm_utils.js +93 -0
- package/dist/classes/farm_utils.js.map +1 -0
- package/dist/classes/lut_utils.d.ts +29 -0
- package/dist/classes/lut_utils.d.ts.map +1 -0
- package/dist/classes/lut_utils.js +62 -0
- package/dist/classes/lut_utils.js.map +1 -0
- package/dist/classes/manager.d.ts +51 -28
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +53 -27
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/types.d.ts +15 -0
- package/dist/classes/types.d.ts.map +1 -1
- package/dist/classes/utils.d.ts +6 -0
- package/dist/classes/utils.d.ts.map +1 -1
- package/dist/classes/utils.js +10 -0
- package/dist/classes/utils.js.map +1 -1
- package/dist/classes/vault.d.ts +84 -56
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +229 -134
- package/dist/classes/vault.js.map +1 -1
- package/dist/client_kamino_manager.d.ts.map +1 -1
- package/dist/client_kamino_manager.js +10 -26
- package/dist/client_kamino_manager.js.map +1 -1
- package/dist/utils/ata.d.ts.map +1 -1
- package/dist/utils/ata.js +1 -0
- package/dist/utils/ata.js.map +1 -1
- package/package.json +6 -6
- package/src/classes/farm_utils.ts +155 -0
- package/src/classes/lut_utils.ts +63 -0
- package/src/classes/manager.ts +75 -31
- package/src/classes/types.ts +18 -0
- package/src/classes/utils.ts +10 -0
- package/src/classes/vault.ts +315 -158
- package/src/client_kamino_manager.ts +19 -33
- package/src/utils/ata.ts +1 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { FarmState, UserState } from '@kamino-finance/farms-sdk';
|
|
2
|
+
import { Connection, Keypair, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
3
|
+
import Decimal from 'decimal.js/decimal';
|
|
4
|
+
export declare const FARMS_GLOBAL_CONFIG_MAINNET: PublicKey;
|
|
5
|
+
export declare function getFarmStakeIxs(connection: Connection, user: PublicKey, lamportsToStake: Decimal, farmAddress: PublicKey, fetchedFarmState?: FarmState): Promise<TransactionInstruction[]>;
|
|
6
|
+
export declare function getFarmUserStatePDA(connection: Connection, user: PublicKey, farm: PublicKey): Promise<PublicKey>;
|
|
7
|
+
export declare function getFarmUnstakeIx(connection: Connection, user: PublicKey, lamportsToUnstake: Decimal, farmAddress: PublicKey, fetchedFarmState?: FarmState): Promise<TransactionInstruction>;
|
|
8
|
+
export declare function getFarmWithdrawUnstakedDepositIx(connection: Connection, user: PublicKey, farm: PublicKey, stakeTokenMint: PublicKey): Promise<TransactionInstruction>;
|
|
9
|
+
export declare function getFarmUnstakeAndWithdrawIxs(connection: Connection, user: PublicKey, lamportsToUnstake: Decimal, farmAddress: PublicKey, fetchedFarmState?: FarmState): Promise<UnstakeAndWithdrawFromFarmIxs>;
|
|
10
|
+
export declare function getSetupFarmIxsWithFarm(connection: Connection, farmAdmin: Keypair, farmTokenMint: PublicKey): Promise<SetupFarmIxsWithFarm>;
|
|
11
|
+
export declare function getUserSharesInFarm(connection: Connection, user: PublicKey, farm: PublicKey, farmTokenDecimals: number): Promise<Decimal>;
|
|
12
|
+
export declare function setVaultIdForFarmIx(connection: Connection, farmAdmin: PublicKey, farm: PublicKey, vault: PublicKey): Promise<TransactionInstruction>;
|
|
13
|
+
export declare function getSharesInFarmUserPosition(userState: UserState, tokenDecimals: number): Decimal;
|
|
14
|
+
export type SetupFarmIxsWithFarm = {
|
|
15
|
+
farm: Keypair;
|
|
16
|
+
setupFarmIxs: TransactionInstruction[];
|
|
17
|
+
};
|
|
18
|
+
export type UnstakeAndWithdrawFromFarmIxs = {
|
|
19
|
+
unstakeIx: TransactionInstruction;
|
|
20
|
+
withdrawIx: TransactionInstruction;
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=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AAED,wBAAsB,uBAAuB,CAC3C,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,OAAO,EAClB,aAAa,EAAE,SAAS,GACvB,OAAO,CAAC,oBAAoB,CAAC,CAK/B;AAED,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,UAAU,EACtB,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,SAAS,EACf,iBAAiB,EAAE,MAAM,GACxB,OAAO,CAAC,OAAO,CAAC,CAGlB;AAED,wBAAsB,mBAAmB,CACvC,UAAU,EAAE,UAAU,EACtB,SAAS,EAAE,SAAS,EACpB,IAAI,EAAE,SAAS,EACf,KAAK,EAAE,SAAS,GACf,OAAO,CAAC,sBAAsB,CAAC,CAGjC;AAED,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAEhG;AAED,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,OAAO,CAAC;IACd,YAAY,EAAE,sBAAsB,EAAE,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,6BAA6B,GAAG;IAC1C,SAAS,EAAE,sBAAsB,CAAC;IAClC,UAAU,EAAE,sBAAsB,CAAC;CACpC,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.FARMS_GLOBAL_CONFIG_MAINNET = void 0;
|
|
7
|
+
exports.getFarmStakeIxs = getFarmStakeIxs;
|
|
8
|
+
exports.getFarmUserStatePDA = getFarmUserStatePDA;
|
|
9
|
+
exports.getFarmUnstakeIx = getFarmUnstakeIx;
|
|
10
|
+
exports.getFarmWithdrawUnstakedDepositIx = getFarmWithdrawUnstakedDepositIx;
|
|
11
|
+
exports.getFarmUnstakeAndWithdrawIxs = getFarmUnstakeAndWithdrawIxs;
|
|
12
|
+
exports.getSetupFarmIxsWithFarm = getSetupFarmIxsWithFarm;
|
|
13
|
+
exports.getUserSharesInFarm = getUserSharesInFarm;
|
|
14
|
+
exports.setVaultIdForFarmIx = setVaultIdForFarmIx;
|
|
15
|
+
exports.getSharesInFarmUserPosition = getSharesInFarmUserPosition;
|
|
16
|
+
const farms_sdk_1 = require("@kamino-finance/farms-sdk");
|
|
17
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
18
|
+
const decimal_1 = __importDefault(require("decimal.js/decimal"));
|
|
19
|
+
exports.FARMS_GLOBAL_CONFIG_MAINNET = new web3_js_1.PublicKey('6UodrBjL2ZreDy7QdR4YV1oxqMBjVYSEyrFpctqqwGwL');
|
|
20
|
+
async function getFarmStakeIxs(connection, user, lamportsToStake, farmAddress, fetchedFarmState) {
|
|
21
|
+
const farmState = fetchedFarmState ? fetchedFarmState : await farms_sdk_1.FarmState.fetch(connection, farmAddress);
|
|
22
|
+
if (!farmState) {
|
|
23
|
+
throw new Error(`Farm state not found for ${farmAddress}`);
|
|
24
|
+
}
|
|
25
|
+
const farmClient = new farms_sdk_1.Farms(connection);
|
|
26
|
+
const scopePricesArg = farmState.scopePrices.equals(web3_js_1.PublicKey.default)
|
|
27
|
+
? farmClient.getProgramID()
|
|
28
|
+
: farmState.scopePrices;
|
|
29
|
+
const stakeIxs = [];
|
|
30
|
+
const userState = (0, farms_sdk_1.getUserStatePDA)(farmClient.getProgramID(), farmAddress, user);
|
|
31
|
+
const userStateExists = await connection.getAccountInfo(userState);
|
|
32
|
+
if (!userStateExists) {
|
|
33
|
+
const createUserIx = farmClient.createNewUserIx(user, farmAddress);
|
|
34
|
+
stakeIxs.push(createUserIx);
|
|
35
|
+
}
|
|
36
|
+
const stakeIx = farmClient.stakeIx(user, farmAddress, lamportsToStake, farmState.token.mint, scopePricesArg);
|
|
37
|
+
stakeIxs.push(stakeIx);
|
|
38
|
+
return stakeIxs;
|
|
39
|
+
}
|
|
40
|
+
async function getFarmUserStatePDA(connection, user, farm) {
|
|
41
|
+
const farmClient = new farms_sdk_1.Farms(connection);
|
|
42
|
+
return (0, farms_sdk_1.getUserStatePDA)(farmClient.getProgramID(), farm, user);
|
|
43
|
+
}
|
|
44
|
+
async function getFarmUnstakeIx(connection, user, lamportsToUnstake, farmAddress, fetchedFarmState) {
|
|
45
|
+
const farmState = fetchedFarmState ? fetchedFarmState : await farms_sdk_1.FarmState.fetch(connection, farmAddress);
|
|
46
|
+
if (!farmState) {
|
|
47
|
+
throw new Error(`Farm state not found for ${farmAddress}`);
|
|
48
|
+
}
|
|
49
|
+
const farmClient = new farms_sdk_1.Farms(connection);
|
|
50
|
+
const scopePricesArg = farmState.scopePrices.equals(web3_js_1.PublicKey.default)
|
|
51
|
+
? farmClient.getProgramID()
|
|
52
|
+
: farmState.scopePrices;
|
|
53
|
+
const userState = (0, farms_sdk_1.getUserStatePDA)(farmClient.getProgramID(), farmAddress, user);
|
|
54
|
+
if (!userState) {
|
|
55
|
+
throw new Error(`User state not found for ${user}`);
|
|
56
|
+
}
|
|
57
|
+
const x = new decimal_1.default(lamportsToUnstake.toString()).mul(farms_sdk_1.WAD);
|
|
58
|
+
console.log('lamportsToUnstake', lamportsToUnstake.toString());
|
|
59
|
+
return farmClient.unstakeIx(user, farmAddress, x.toString(), scopePricesArg);
|
|
60
|
+
}
|
|
61
|
+
// withdrawing from a farm is a 2 step operation: first we unstake the tokens from the farm, then we withdraw them
|
|
62
|
+
async function getFarmWithdrawUnstakedDepositIx(connection, user, farm, stakeTokenMint) {
|
|
63
|
+
const farmClient = new farms_sdk_1.Farms(connection);
|
|
64
|
+
const userState = (0, farms_sdk_1.getUserStatePDA)(farmClient.getProgramID(), farm, user);
|
|
65
|
+
return farmClient.withdrawUnstakedDepositIx(user, userState, farm, stakeTokenMint);
|
|
66
|
+
}
|
|
67
|
+
async function getFarmUnstakeAndWithdrawIxs(connection, user, lamportsToUnstake, farmAddress, fetchedFarmState) {
|
|
68
|
+
const farmState = fetchedFarmState ? fetchedFarmState : await farms_sdk_1.FarmState.fetch(connection, farmAddress);
|
|
69
|
+
if (!farmState) {
|
|
70
|
+
throw new Error(`Farm state not found for ${farmAddress}`);
|
|
71
|
+
}
|
|
72
|
+
const unstakeIx = await getFarmUnstakeIx(connection, user, lamportsToUnstake, farmAddress, farmState);
|
|
73
|
+
const withdrawIx = await getFarmWithdrawUnstakedDepositIx(connection, user, farmAddress, farmState.token.mint);
|
|
74
|
+
return { unstakeIx, withdrawIx };
|
|
75
|
+
}
|
|
76
|
+
async function getSetupFarmIxsWithFarm(connection, farmAdmin, farmTokenMint) {
|
|
77
|
+
const farmClient = new farms_sdk_1.Farms(connection);
|
|
78
|
+
const farm = new web3_js_1.Keypair();
|
|
79
|
+
const ixs = await farmClient.createFarmIx(farmAdmin.publicKey, farm, exports.FARMS_GLOBAL_CONFIG_MAINNET, farmTokenMint);
|
|
80
|
+
return { farm, setupFarmIxs: ixs };
|
|
81
|
+
}
|
|
82
|
+
async function getUserSharesInFarm(connection, user, farm, farmTokenDecimals) {
|
|
83
|
+
const farmClient = new farms_sdk_1.Farms(connection);
|
|
84
|
+
return farmClient.getUserTokensInUndelegatedFarm(user, farm, farmTokenDecimals);
|
|
85
|
+
}
|
|
86
|
+
async function setVaultIdForFarmIx(connection, farmAdmin, farm, vault) {
|
|
87
|
+
const farmClient = new farms_sdk_1.Farms(connection);
|
|
88
|
+
return farmClient.updateFarmConfigIx(farmAdmin, farm, web3_js_1.PublicKey.default, new farms_sdk_1.FarmConfigOption.UpdateVaultId(), vault);
|
|
89
|
+
}
|
|
90
|
+
function getSharesInFarmUserPosition(userState, tokenDecimals) {
|
|
91
|
+
return (0, farms_sdk_1.lamportsToCollDecimal)(new decimal_1.default((0, farms_sdk_1.scaleDownWads)(userState.activeStakeScaled)), tokenDecimals);
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=farm_utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
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
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { Connection, PublicKey, TransactionInstruction } from '@solana/web3.js';
|
|
2
|
+
/**
|
|
3
|
+
* This method retuns an instruction that creates a lookup table, alongside the pubkey of the lookup table
|
|
4
|
+
* @param payer - the owner of the lookup table
|
|
5
|
+
* @param slot - the current slot
|
|
6
|
+
* @returns - the instruction to create the lookup table and its address
|
|
7
|
+
*/
|
|
8
|
+
export declare function initLookupTableIx(payer: PublicKey, slot: number): [TransactionInstruction, PublicKey];
|
|
9
|
+
/**
|
|
10
|
+
* This method retuns an instruction that deactivates a lookup table, which is needed to close it
|
|
11
|
+
* @param payer - the owner of the lookup table
|
|
12
|
+
* @param lookupTable - the lookup table to deactivate
|
|
13
|
+
* @returns - the instruction to deactivate the lookup table
|
|
14
|
+
*/
|
|
15
|
+
export declare function deactivateLookupTableIx(payer: PublicKey, lookupTable: PublicKey): TransactionInstruction;
|
|
16
|
+
/**
|
|
17
|
+
* This method returns an instruction that closes a lookup table. That lookup table needs to be disabled at least 500 blocks before closing it.
|
|
18
|
+
* @param payer - the owner of the lookup table
|
|
19
|
+
* @param lookupTable - the lookup table to close
|
|
20
|
+
* @returns - the instruction to close the lookup table
|
|
21
|
+
*/
|
|
22
|
+
export declare function closeLookupTableIx(payer: PublicKey, lookupTable: PublicKey): TransactionInstruction;
|
|
23
|
+
/**
|
|
24
|
+
* Returns the accounts in a lookup table
|
|
25
|
+
* @param lookupTable - lookup table to get the accounts from
|
|
26
|
+
* @returns - an array of accounts in the lookup table
|
|
27
|
+
*/
|
|
28
|
+
export declare function getAccountsInLUT(connection: Connection, lookupTable: PublicKey): Promise<PublicKey[]>;
|
|
29
|
+
//# sourceMappingURL=lut_utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lut_utils.d.ts","sourceRoot":"","sources":["../../src/classes/lut_utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAA6B,UAAU,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAE3G;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,sBAAsB,EAAE,SAAS,CAAC,CAQrG;AAED;;;;;GAKG;AACH,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,GAAG,sBAAsB,CAOxG;AAED;;;;;GAKG;AAEH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,GAAG,sBAAsB,CAQnG;AAED;;;;GAIG;AACH,wBAAsB,gBAAgB,CAAC,UAAU,EAAE,UAAU,EAAE,WAAW,EAAE,SAAS,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC,CAO3G"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initLookupTableIx = initLookupTableIx;
|
|
4
|
+
exports.deactivateLookupTableIx = deactivateLookupTableIx;
|
|
5
|
+
exports.closeLookupTableIx = closeLookupTableIx;
|
|
6
|
+
exports.getAccountsInLUT = getAccountsInLUT;
|
|
7
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
8
|
+
/**
|
|
9
|
+
* This method retuns an instruction that creates a lookup table, alongside the pubkey of the lookup table
|
|
10
|
+
* @param payer - the owner of the lookup table
|
|
11
|
+
* @param slot - the current slot
|
|
12
|
+
* @returns - the instruction to create the lookup table and its address
|
|
13
|
+
*/
|
|
14
|
+
function initLookupTableIx(payer, slot) {
|
|
15
|
+
const [ixn, address] = web3_js_1.AddressLookupTableProgram.createLookupTable({
|
|
16
|
+
authority: payer,
|
|
17
|
+
payer,
|
|
18
|
+
recentSlot: slot,
|
|
19
|
+
});
|
|
20
|
+
return [ixn, address];
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* This method retuns an instruction that deactivates a lookup table, which is needed to close it
|
|
24
|
+
* @param payer - the owner of the lookup table
|
|
25
|
+
* @param lookupTable - the lookup table to deactivate
|
|
26
|
+
* @returns - the instruction to deactivate the lookup table
|
|
27
|
+
*/
|
|
28
|
+
function deactivateLookupTableIx(payer, lookupTable) {
|
|
29
|
+
const ixn = web3_js_1.AddressLookupTableProgram.deactivateLookupTable({
|
|
30
|
+
authority: payer,
|
|
31
|
+
lookupTable: lookupTable,
|
|
32
|
+
});
|
|
33
|
+
return ixn;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* This method returns an instruction that closes a lookup table. That lookup table needs to be disabled at least 500 blocks before closing it.
|
|
37
|
+
* @param payer - the owner of the lookup table
|
|
38
|
+
* @param lookupTable - the lookup table to close
|
|
39
|
+
* @returns - the instruction to close the lookup table
|
|
40
|
+
*/
|
|
41
|
+
/// this require the LUT to be deactivated at least 500 blocks before
|
|
42
|
+
function closeLookupTableIx(payer, lookupTable) {
|
|
43
|
+
const ixn = web3_js_1.AddressLookupTableProgram.closeLookupTable({
|
|
44
|
+
authority: payer,
|
|
45
|
+
recipient: payer,
|
|
46
|
+
lookupTable: lookupTable,
|
|
47
|
+
});
|
|
48
|
+
return ixn;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Returns the accounts in a lookup table
|
|
52
|
+
* @param lookupTable - lookup table to get the accounts from
|
|
53
|
+
* @returns - an array of accounts in the lookup table
|
|
54
|
+
*/
|
|
55
|
+
async function getAccountsInLUT(connection, lookupTable) {
|
|
56
|
+
const lutState = await connection.getAddressLookupTable(lookupTable);
|
|
57
|
+
if (!lutState || !lutState.value) {
|
|
58
|
+
throw new Error(`Lookup table ${lookupTable} not found`);
|
|
59
|
+
}
|
|
60
|
+
return lutState.value.state.addresses;
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=lut_utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lut_utils.js","sourceRoot":"","sources":["../../src/classes/lut_utils.ts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ig } from '../idl_codegen/types';
|
|
|
5
5
|
import Decimal from 'decimal.js';
|
|
6
6
|
import { VaultState } from '../idl_codegen_kamino_vault/accounts';
|
|
7
7
|
import { VaultConfigFieldKind } from '../idl_codegen_kamino_vault/types';
|
|
8
|
-
import { AcceptVaultOwnershipIxs, InitVaultIxs, SyncVaultLUTIxs, UpdateReserveAllocationIxs, UpdateVaultConfigIxs } from './types';
|
|
8
|
+
import { AcceptVaultOwnershipIxs, DepositIxs, InitVaultIxs, SyncVaultLUTIxs, UpdateReserveAllocationIxs, UpdateVaultConfigIxs, UserSharesForVault, WithdrawIxs } from './types';
|
|
9
|
+
import { FarmState } from '@kamino-finance/farms-sdk/dist';
|
|
9
10
|
/**
|
|
10
11
|
* KaminoManager is a class that provides a high-level interface to interact with the Kamino Lend and Kamino Vault programs, in order to create and manage a market, as well as vaults
|
|
11
12
|
*/
|
|
@@ -43,7 +44,6 @@ export declare class KaminoManager {
|
|
|
43
44
|
/**
|
|
44
45
|
* This method will create a vault with a given config. The config can be changed later on, but it is recommended to set it up correctly from the start
|
|
45
46
|
* @param vaultConfig - the config object used to create a vault
|
|
46
|
-
* @returns vault - keypair, should be used to sign the transaction which creates the vault account
|
|
47
47
|
* @returns vault: the keypair of the vault, used to sign the initialization transaction; initVaultIxs: a struct with ixs to initialize the vault and its lookup table + populateLUTIxs, a list to populate the lookup table which has to be executed in a separate transaction
|
|
48
48
|
*/
|
|
49
49
|
createVaultIxs(vaultConfig: KaminoVaultConfig): Promise<{
|
|
@@ -54,7 +54,7 @@ export declare class KaminoManager {
|
|
|
54
54
|
* This method updates the vault reserve allocation cofnig for an exiting vault reserve, or adds a new reserve to the vault if it does not exist.
|
|
55
55
|
* @param vault - vault to be updated
|
|
56
56
|
* @param reserveAllocationConfig - new reserve allocation config
|
|
57
|
-
* @returns - a struct of instructions
|
|
57
|
+
* @returns - a struct with an instruction to update the reserve allocation and an optional list of instructions to update the lookup table for the allocation changes
|
|
58
58
|
*/
|
|
59
59
|
updateVaultReserveAllocationIxs(vault: KaminoVault, reserveAllocationConfig: ReserveAllocationConfig): Promise<UpdateReserveAllocationIxs>;
|
|
60
60
|
/**
|
|
@@ -86,13 +86,22 @@ export declare class KaminoManager {
|
|
|
86
86
|
/**
|
|
87
87
|
* This function creates instructions to deposit into a vault. It will also create ATA creation instructions for the vault shares that the user receives in return
|
|
88
88
|
* @param user - user to deposit
|
|
89
|
-
* @param vault - vault to deposit into
|
|
89
|
+
* @param vault - vault to deposit into (if the state is not provided, it will be fetched)
|
|
90
90
|
* @param tokenAmount - token amount to be deposited, in decimals (will be converted in lamports)
|
|
91
|
-
* @param
|
|
92
|
-
* @param
|
|
93
|
-
* @returns - an
|
|
91
|
+
* @param [vaultReservesMap] - optional parameter; a hashmap from each reserve pubkey to the reserve state. Optional. If provided the function will be significantly faster as it will not have to fetch the reserves
|
|
92
|
+
* @param [farmState] - the state of the vault farm, if the vault has a farm. Optional. If not provided, it will be fetched
|
|
93
|
+
* @returns - an instance of DepositIxs which contains the instructions to deposit in vault and the instructions to stake the shares in the farm if the vault has a farm
|
|
94
94
|
*/
|
|
95
|
-
depositToVaultIxs(user: PublicKey, vault: KaminoVault, tokenAmount: Decimal, vaultReservesMap?: PubkeyHashMap<PublicKey, KaminoReserve>): Promise<
|
|
95
|
+
depositToVaultIxs(user: PublicKey, vault: KaminoVault, tokenAmount: Decimal, vaultReservesMap?: PubkeyHashMap<PublicKey, KaminoReserve>): Promise<DepositIxs>;
|
|
96
|
+
/**
|
|
97
|
+
* This function creates instructions to stake the shares in the vault farm if the vault has a farm
|
|
98
|
+
* @param user - user to stake
|
|
99
|
+
* @param vault - vault to deposit into its farm (if the state is not provided, it will be fetched)
|
|
100
|
+
* @param [sharesAmount] - token amount to be deposited, in decimals (will be converted in lamports). Optional. If not provided, the user's share balance will be used
|
|
101
|
+
* @param [farmState] - the state of the vault farm, if the vault has a farm. Optional. If not provided, it will be fetched
|
|
102
|
+
* @returns - a list of instructions for the user to stake shares into the vault's farm, including the creation of prerequisite accounts if needed
|
|
103
|
+
*/
|
|
104
|
+
stakeSharesIxs(user: PublicKey, vault: KaminoVault, sharesAmount?: Decimal, farmState?: FarmState): Promise<TransactionInstruction[]>;
|
|
96
105
|
/**
|
|
97
106
|
* Update a field of the vault. If the field is a pubkey it will return an extra instruction to add that account into the lookup table
|
|
98
107
|
* @param vault the vault to update
|
|
@@ -101,17 +110,23 @@ export declare class KaminoManager {
|
|
|
101
110
|
* @returns a struct that contains the instruction to update the field and an optional list of instructions to update the lookup table
|
|
102
111
|
*/
|
|
103
112
|
updateVaultConfigIxs(vault: KaminoVault, mode: VaultConfigFieldKind, value: string): Promise<UpdateVaultConfigIxs>;
|
|
113
|
+
/** Sets the farm where the shares can be staked. This is store in vault state and a vault can only have one farm, so the new farm will ovveride the old farm
|
|
114
|
+
* @param vault - vault to set the farm for
|
|
115
|
+
* @param farm - the farm where the vault shares can be staked
|
|
116
|
+
* @param [errorOnOverride] - if true, the function will throw an error if the vault already has a farm. If false, it will override the farm
|
|
117
|
+
*/
|
|
118
|
+
setVaultFarm(vault: KaminoVault, farm: PublicKey, errorOnOverride?: boolean): Promise<UpdateVaultConfigIxs>;
|
|
104
119
|
/**
|
|
105
|
-
* This function creates the instruction for the `pendingAdmin` of the vault to accept to become the owner of the vault (step 2/2 of the ownership transfer)
|
|
120
|
+
* This function creates the instruction for the `pendingAdmin` of the vault to accept to become the owner of the vault (step 2/2 of the ownership transfer)
|
|
106
121
|
* @param vault - vault to change the ownership for
|
|
107
|
-
* @returns - an instruction to
|
|
122
|
+
* @returns - an instruction to accept the ownership of the vault and a list of instructions to update the lookup table
|
|
108
123
|
*/
|
|
109
124
|
acceptVaultOwnershipIxs(vault: KaminoVault): Promise<AcceptVaultOwnershipIxs>;
|
|
110
125
|
/**
|
|
111
126
|
* This function creates the instruction for the admin to give up a part of the pending fees (which will be accounted as part of the vault)
|
|
112
127
|
* @param vault - vault to give up pending fees for
|
|
113
128
|
* @param maxAmountToGiveUp - the maximum amount of fees to give up, in tokens
|
|
114
|
-
* @returns - an instruction to
|
|
129
|
+
* @returns - an instruction to give up the specified pending fees
|
|
115
130
|
*/
|
|
116
131
|
giveUpPendingFeesIx(vault: KaminoVault, maxAmountToGiveUp: Decimal): Promise<TransactionInstruction>;
|
|
117
132
|
/**
|
|
@@ -120,31 +135,35 @@ export declare class KaminoManager {
|
|
|
120
135
|
* @param vault - vault to withdraw from
|
|
121
136
|
* @param shareAmount - share amount to withdraw, in order to withdraw everything, any value > user share amount
|
|
122
137
|
* @param slot - current slot, used to estimate the interest earned in the different reserves with allocation from the vault
|
|
123
|
-
* @
|
|
138
|
+
* @param [vaultReservesMap] - optional parameter; a hashmap from each reserve pubkey to the reserve state. If provided the function will be significantly faster as it will not have to fetch the reserves
|
|
139
|
+
* @returns an array of instructions to create missing ATAs if needed and the withdraw instructions
|
|
124
140
|
*/
|
|
125
|
-
withdrawFromVaultIxs(user: PublicKey, vault: KaminoVault, shareAmount: Decimal, slot: number): Promise<
|
|
141
|
+
withdrawFromVaultIxs(user: PublicKey, vault: KaminoVault, shareAmount: Decimal, slot: number): Promise<WithdrawIxs>;
|
|
126
142
|
/**
|
|
127
143
|
* This method withdraws all the pending fees from the vault to the owner's token ATA
|
|
128
144
|
* @param vault - vault for which the admin withdraws the pending fees
|
|
129
145
|
* @param slot - current slot, used to estimate the interest earned in the different reserves with allocation from the vault
|
|
130
|
-
* @
|
|
146
|
+
* @param [vaultReservesMap] - a hashmap from each reserve pubkey to the reserve state. Optional. If provided the function will be significantly faster as it will not have to fetch the reserves
|
|
147
|
+
* @returns - list of instructions to withdraw all pending fees, including the ATA creation instructions if needed
|
|
131
148
|
*/
|
|
132
149
|
withdrawPendingFeesIxs(vault: KaminoVault, slot: number): Promise<TransactionInstruction[]>;
|
|
133
150
|
/**
|
|
134
|
-
* This method
|
|
135
|
-
* @param payer -
|
|
136
|
-
* @param
|
|
137
|
-
* @param keys -
|
|
138
|
-
* @
|
|
151
|
+
* This method inserts the missing keys from the provided keys into an existent lookup table
|
|
152
|
+
* @param payer - payer wallet pubkey
|
|
153
|
+
* @param lookupTable - lookup table to insert the keys into
|
|
154
|
+
* @param keys - keys to insert into the lookup table
|
|
155
|
+
* @param [accountsInLUT] - the existent accounts in the lookup table. Optional. If provided, the function will not fetch the accounts in the lookup table
|
|
156
|
+
* @returns - an array of instructions to insert the missing keys into the lookup table
|
|
139
157
|
*/
|
|
140
|
-
|
|
158
|
+
insertIntoLUTIxs(payer: PublicKey, lut: PublicKey, keys: PublicKey[]): Promise<TransactionInstruction[]>;
|
|
141
159
|
/**
|
|
142
160
|
* Sync a vault for lookup table; create and set the LUT for the vault if needed and fill it with all the needed accounts
|
|
143
161
|
* @param vault the vault to sync and set the LUT for if needed
|
|
144
162
|
* @param vaultReserves optional; the state of the reserves in the vault allocation
|
|
163
|
+
* @param [vaultReservesMap] - optional parameter; a hashmap from each reserve pubkey to the reserve state. Optional. If provided the function will be significantly faster as it will not have to fetch the reserves
|
|
145
164
|
* @returns a struct that contains a list of ix to create the LUT and assign it to the vault if needed + a list of ixs to insert all the accounts in the LUT
|
|
146
165
|
*/
|
|
147
|
-
|
|
166
|
+
syncVaultLUTIxs(vault: KaminoVault, vaultReserves?: PubkeyHashMap<PublicKey, KaminoReserve>): Promise<SyncVaultLUTIxs>;
|
|
148
167
|
/**
|
|
149
168
|
* This method calculates the token per share value. This will always change based on interest earned from the vault, but calculating it requires a bunch of rpc requests. Caching this for a short duration would be optimal
|
|
150
169
|
* @param vault - vault to calculate tokensPerShare for
|
|
@@ -164,16 +183,16 @@ export declare class KaminoManager {
|
|
|
164
183
|
* This method returns the user shares balance for a given vault
|
|
165
184
|
* @param user - user to calculate the shares balance for
|
|
166
185
|
* @param vault - vault to calculate shares balance for
|
|
167
|
-
* @returns - user share balance in decimal (not lamports)
|
|
186
|
+
* @returns - a struct of user share balance (staked in vault farm if the vault has a farm and unstaked) in decimal (not lamports)
|
|
168
187
|
*/
|
|
169
|
-
getUserSharesBalanceSingleVault(user: PublicKey, vault: KaminoVault): Promise<
|
|
188
|
+
getUserSharesBalanceSingleVault(user: PublicKey, vault: KaminoVault): Promise<UserSharesForVault>;
|
|
170
189
|
/**
|
|
171
190
|
* This method returns the user shares balance for all existing vaults
|
|
172
191
|
* @param user - user to calculate the shares balance for
|
|
173
192
|
* @param vaultsOverride - the kamino vaults if already fetched, in order to reduce rpc calls
|
|
174
193
|
* @returns - hash map with keyh as vault address and value as user share balance in decimal (not lamports)
|
|
175
194
|
*/
|
|
176
|
-
getUserSharesBalanceAllVaults(user: PublicKey, vaultsOverride?: KaminoVault[]): Promise<PubkeyHashMap<PublicKey,
|
|
195
|
+
getUserSharesBalanceAllVaults(user: PublicKey, vaultsOverride?: KaminoVault[]): Promise<PubkeyHashMap<PublicKey, UserSharesForVault>>;
|
|
177
196
|
/**
|
|
178
197
|
* This method returns the management and performance fee percentages
|
|
179
198
|
* @param vaultState - vault to retrieve the fees percentages from
|
|
@@ -286,16 +305,18 @@ export declare class KaminoManager {
|
|
|
286
305
|
* Simulate the current holdings of the vault and the earned interest
|
|
287
306
|
* @param vaultState the kamino vault state to get simulated holdings and earnings for
|
|
288
307
|
* @param vaultReserves optional; the state of the reserves in the vault allocation
|
|
308
|
+
* @param [currentSlot] - the current slot. Optional. If not provided it will fetch the current slot
|
|
289
309
|
* @returns a struct of simulated vault holdings and earned interest
|
|
290
310
|
*/
|
|
291
|
-
calculateSimulatedHoldingsWithInterest(vaultState: VaultState, vaultReserves?: PubkeyHashMap<PublicKey, KaminoReserve
|
|
311
|
+
calculateSimulatedHoldingsWithInterest(vaultState: VaultState, vaultReserves?: PubkeyHashMap<PublicKey, KaminoReserve>, currentSlot?: number): Promise<SimulatedVaultHoldingsWithEarnedInterest>;
|
|
292
312
|
/**
|
|
293
313
|
* Simulate the current holdings and compute the fees that would be charged
|
|
294
314
|
* @param vaultState the kamino vault state to get simulated fees for
|
|
295
315
|
* @param simulatedCurrentHoldingsWithInterest optional; the simulated holdings and interest earned by the vault
|
|
316
|
+
* @param [currentTimestamp] the current timestamp. Optional. If not provided it will fetch the current unix timestamp
|
|
296
317
|
* @returns a struct of simulated management and interest fees
|
|
297
318
|
*/
|
|
298
|
-
calculateSimulatedFees(vaultState: VaultState, simulatedCurrentHoldingsWithInterest?: SimulatedVaultHoldingsWithEarnedInterest): Promise<VaultFees>;
|
|
319
|
+
calculateSimulatedFees(vaultState: VaultState, simulatedCurrentHoldingsWithInterest?: SimulatedVaultHoldingsWithEarnedInterest, currentTimestamp?: number): Promise<VaultFees>;
|
|
299
320
|
/**
|
|
300
321
|
* This will load the onchain state for all the reserves that the vault has allocations for
|
|
301
322
|
* @param vaultState - the vault state to load reserves for
|
|
@@ -329,11 +350,13 @@ export declare class KaminoManager {
|
|
|
329
350
|
investAllReserves(payer: PublicKey, kaminoVault: KaminoVault): Promise<TransactionInstruction[]>;
|
|
330
351
|
/**
|
|
331
352
|
* This will trigger invest by balancing, based on weights, the reserve allocation of the vault. It can either withdraw or deposit into the given reserve to balance it
|
|
332
|
-
* @param
|
|
353
|
+
* @param payer wallet pubkey
|
|
354
|
+
* @param vault - vault to invest from
|
|
333
355
|
* @param reserve - reserve to invest into or disinvest from
|
|
356
|
+
* @param [vaultReservesMap] - optional parameter; a hashmap from each reserve pubkey to the reserve state. If provided the function will be significantly faster as it will not have to fetch the reserves
|
|
334
357
|
* @returns - an array of invest instructions for each invest action required for the vault reserves
|
|
335
358
|
*/
|
|
336
|
-
investSingleReserve(payer: PublicKey, kaminoVault: KaminoVault, reserveWithAddress: ReserveWithAddress): Promise<TransactionInstruction[]>;
|
|
359
|
+
investSingleReserve(payer: PublicKey, kaminoVault: KaminoVault, reserveWithAddress: ReserveWithAddress, vaultReservesMap?: PubkeyHashMap<PublicKey, KaminoReserve>): Promise<TransactionInstruction[]>;
|
|
337
360
|
/**
|
|
338
361
|
* This will return the a map between reserve pubkey and the pct of the vault invested amount in each reserve
|
|
339
362
|
* @param vaultState - the kamino vault to get reserves distribution for
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/classes/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,UAAU,EAEV,OAAO,EACP,iBAAiB,EACjB,SAAS,EAGT,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EAEjB,cAAc,EACd,uBAAuB,EACvB,eAAe,EACf,wCAAwC,EACxC,SAAS,EACT,YAAY,EACZ,WAAW,EACX,aAAa,EACb,yBAAyB,EACzB,aAAa,EACb,oCAAoC,EACrC,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,sBAAsB,EACtB,wBAAwB,EAGxB,GAAG,EAKH,YAAY,EACZ,aAAa,EACb,aAAa,EAEb,iBAAiB,EAGjB,aAAa,EACb,OAAO,EACP,kBAAkB,EAElB,iBAAiB,EAOlB,MAAM,QAAQ,CAAC;AAIhB,OAAO,EAAkB,aAAa,EAA2B,MAAM,sBAAsB,CAAC;AAC9F,OAAO,OAAO,MAAM,YAAY,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAE,MAAM,sCAAsC,CAAC;AAKlE,OAAO,EAAE,oBAAoB,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EACL,uBAAuB,EACvB,YAAY,EACZ,eAAe,EACf,0BAA0B,EAC1B,oBAAoB,
|
|
1
|
+
{"version":3,"file":"manager.d.ts","sourceRoot":"","sources":["../../src/classes/manager.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,UAAU,EAEV,OAAO,EACP,iBAAiB,EACjB,SAAS,EAGT,sBAAsB,EACvB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,iBAAiB,EAEjB,cAAc,EACd,uBAAuB,EACvB,eAAe,EACf,wCAAwC,EACxC,SAAS,EACT,YAAY,EACZ,WAAW,EACX,aAAa,EACb,yBAAyB,EACzB,aAAa,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