@kamino-finance/klend-sdk 5.14.4 → 5.15.0
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.map +1 -1
- package/dist/classes/farm_utils.js +1 -0
- package/dist/classes/farm_utils.js.map +1 -1
- package/dist/classes/manager.d.ts.map +1 -1
- package/dist/classes/manager.js +3 -1
- package/dist/classes/manager.js.map +1 -1
- package/dist/classes/market.d.ts.map +1 -1
- package/dist/classes/market.js.map +1 -1
- package/dist/classes/reserve.d.ts +1 -1
- package/dist/classes/reserve.d.ts.map +1 -1
- package/dist/classes/reserve.js +11 -8
- package/dist/classes/reserve.js.map +1 -1
- package/dist/classes/vault.d.ts +1 -1
- package/dist/classes/vault.d.ts.map +1 -1
- package/dist/classes/vault.js +89 -15
- package/dist/classes/vault.js.map +1 -1
- package/dist/client_kamino_manager.d.ts.map +1 -1
- package/dist/client_kamino_manager.js +20 -10
- package/dist/client_kamino_manager.js.map +1 -1
- package/dist/idl.json +193 -16
- package/dist/idl_codegen/accounts/GlobalConfig.d.ts +40 -0
- package/dist/idl_codegen/accounts/GlobalConfig.d.ts.map +1 -0
- package/dist/idl_codegen/accounts/GlobalConfig.js +116 -0
- package/dist/idl_codegen/accounts/GlobalConfig.js.map +1 -0
- package/dist/idl_codegen/accounts/LendingMarket.d.ts +24 -3
- package/dist/idl_codegen/accounts/LendingMarket.d.ts.map +1 -1
- package/dist/idl_codegen/accounts/LendingMarket.js +25 -7
- package/dist/idl_codegen/accounts/LendingMarket.js.map +1 -1
- package/dist/idl_codegen/accounts/index.d.ts +2 -0
- package/dist/idl_codegen/accounts/index.d.ts.map +1 -1
- package/dist/idl_codegen/accounts/index.js +3 -1
- package/dist/idl_codegen/accounts/index.js.map +1 -1
- package/dist/idl_codegen/errors/custom.d.ts +35 -11
- package/dist/idl_codegen/errors/custom.d.ts.map +1 -1
- package/dist/idl_codegen/errors/custom.js +64 -22
- package/dist/idl_codegen/errors/custom.js.map +1 -1
- package/dist/idl_codegen/instructions/idlMissingTypes.d.ts +2 -1
- package/dist/idl_codegen/instructions/idlMissingTypes.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/idlMissingTypes.js +2 -1
- package/dist/idl_codegen/instructions/idlMissingTypes.js.map +1 -1
- package/dist/idl_codegen/instructions/index.d.ts +6 -0
- package/dist/idl_codegen/instructions/index.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/index.js +7 -1
- package/dist/idl_codegen/instructions/index.js.map +1 -1
- package/dist/idl_codegen/instructions/initGlobalConfig.d.ts +10 -0
- package/dist/idl_codegen/instructions/initGlobalConfig.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/initGlobalConfig.js +19 -0
- package/dist/idl_codegen/instructions/initGlobalConfig.js.map +1 -0
- package/dist/idl_codegen/instructions/updateGlobalConfig.d.ts +13 -0
- package/dist/idl_codegen/instructions/updateGlobalConfig.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/updateGlobalConfig.js +61 -0
- package/dist/idl_codegen/instructions/updateGlobalConfig.js.map +1 -0
- package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.d.ts +7 -0
- package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.d.ts.map +1 -0
- package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.js +16 -0
- package/dist/idl_codegen/instructions/updateGlobalConfigAdmin.js.map +1 -0
- package/dist/idl_codegen/instructions/updateReserveConfig.d.ts +5 -4
- package/dist/idl_codegen/instructions/updateReserveConfig.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/updateReserveConfig.js +7 -5
- package/dist/idl_codegen/instructions/updateReserveConfig.js.map +1 -1
- package/dist/idl_codegen/instructions/withdrawProtocolFee.d.ts +2 -2
- package/dist/idl_codegen/instructions/withdrawProtocolFee.d.ts.map +1 -1
- package/dist/idl_codegen/instructions/withdrawProtocolFee.js +2 -6
- package/dist/idl_codegen/instructions/withdrawProtocolFee.js.map +1 -1
- package/dist/idl_codegen/types/UpdateGlobalConfigMode.d.ts +32 -0
- package/dist/idl_codegen/types/UpdateGlobalConfigMode.d.ts.map +1 -0
- package/dist/idl_codegen/types/UpdateGlobalConfigMode.js +108 -0
- package/dist/idl_codegen/types/UpdateGlobalConfigMode.js.map +1 -0
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts +33 -7
- package/dist/idl_codegen/types/UpdateLendingMarketMode.d.ts.map +1 -1
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js +60 -12
- package/dist/idl_codegen/types/UpdateLendingMarketMode.js.map +1 -1
- package/dist/idl_codegen/types/index.d.ts +6 -2
- package/dist/idl_codegen/types/index.d.ts.map +1 -1
- package/dist/idl_codegen/types/index.js +3 -1
- package/dist/idl_codegen/types/index.js.map +1 -1
- package/dist/utils/api.d.ts +7 -1
- package/dist/utils/api.d.ts.map +1 -1
- package/dist/utils/api.js +3 -2
- package/dist/utils/api.js.map +1 -1
- package/dist/utils/constants.d.ts +1 -1
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +3 -3
- package/dist/utils/constants.js.map +1 -1
- package/dist/utils/instruction.d.ts.map +1 -1
- package/dist/utils/instruction.js.map +1 -1
- package/dist/utils/lookupTable.d.ts.map +1 -1
- package/dist/utils/lookupTable.js +1 -6
- package/dist/utils/lookupTable.js.map +1 -1
- package/dist/utils/managerTypes.js +1 -1
- package/dist/utils/managerTypes.js.map +1 -1
- package/dist/utils/seeds.d.ts +16 -0
- package/dist/utils/seeds.d.ts.map +1 -1
- package/dist/utils/seeds.js +23 -1
- package/dist/utils/seeds.js.map +1 -1
- package/package.json +1 -1
- package/src/classes/farm_utils.ts +1 -0
- package/src/classes/manager.ts +3 -1
- package/src/classes/market.ts +2 -6
- package/src/classes/reserve.ts +12 -8
- package/src/classes/vault.ts +118 -14
- package/src/classes/vault_types.ts +1 -1
- package/src/client_kamino_manager.ts +35 -13
- package/src/idl.json +193 -16
- package/src/idl_codegen/accounts/GlobalConfig.ts +125 -0
- package/src/idl_codegen/accounts/LendingMarket.ts +41 -9
- package/src/idl_codegen/accounts/index.ts +2 -0
- package/src/idl_codegen/errors/custom.ts +65 -20
- package/src/idl_codegen/instructions/idlMissingTypes.ts +4 -2
- package/src/idl_codegen/instructions/index.ts +9 -0
- package/src/idl_codegen/instructions/initGlobalConfig.ts +30 -0
- package/src/idl_codegen/instructions/updateGlobalConfig.ts +47 -0
- package/src/idl_codegen/instructions/updateGlobalConfigAdmin.ts +24 -0
- package/src/idl_codegen/instructions/updateReserveConfig.ts +10 -8
- package/src/idl_codegen/instructions/withdrawProtocolFee.ts +4 -8
- package/src/idl_codegen/types/UpdateGlobalConfigMode.ts +90 -0
- package/src/idl_codegen/types/UpdateLendingMarketMode.ts +73 -13
- package/src/idl_codegen/types/index.ts +16 -2
- package/src/utils/api.ts +9 -3
- package/src/utils/constants.ts +3 -3
- package/src/utils/instruction.ts +2 -2
- package/src/utils/lookupTable.ts +1 -7
- package/src/utils/managerTypes.ts +1 -1
- package/src/utils/seeds.ts +25 -0
package/src/utils/api.ts
CHANGED
|
@@ -5,6 +5,12 @@ import { CDN_ENDPOINT, getApiEndpoint } from '../utils';
|
|
|
5
5
|
import { IBackOffOptions, backOff } from 'exponential-backoff';
|
|
6
6
|
import { PROGRAM_ID } from '../lib';
|
|
7
7
|
|
|
8
|
+
export type ApiRequestOptions = {
|
|
9
|
+
programId?: PublicKey;
|
|
10
|
+
source?: 'API' | 'CDN';
|
|
11
|
+
apiBaseUrl?: string;
|
|
12
|
+
};
|
|
13
|
+
|
|
8
14
|
export type ApiFilterOptions = {
|
|
9
15
|
isCurated?: boolean;
|
|
10
16
|
};
|
|
@@ -15,11 +21,11 @@ export type ApiFilterOptions = {
|
|
|
15
21
|
*
|
|
16
22
|
* @param programId - The program id to retrieve config for
|
|
17
23
|
* @param source - CDN is a json file hosted in the cloud, API is a webserver
|
|
24
|
+
* @param apiBaseUrl - Optional base URL for the API, if not provided, defaults to the standard API endpoint, not used for CDN
|
|
18
25
|
* @param filterOptions - Config options to filter markets by
|
|
19
26
|
*/
|
|
20
27
|
export async function getMarketsFromApi(
|
|
21
|
-
programId:
|
|
22
|
-
source: 'API' | 'CDN' = 'CDN',
|
|
28
|
+
{ programId = PROGRAM_ID, source = 'CDN', apiBaseUrl }: ApiRequestOptions = {},
|
|
23
29
|
filterOptions: ApiFilterOptions = {}
|
|
24
30
|
): Promise<ConfigType> {
|
|
25
31
|
let unfilteredConfigs: ConfigType = {} as ConfigType;
|
|
@@ -30,7 +36,7 @@ export async function getMarketsFromApi(
|
|
|
30
36
|
}
|
|
31
37
|
|
|
32
38
|
if (!unfilteredConfigs || isEmptyObject(unfilteredConfigs)) {
|
|
33
|
-
const API_ENDPOINT = getApiEndpoint(programId);
|
|
39
|
+
const API_ENDPOINT = getApiEndpoint(programId, apiBaseUrl);
|
|
34
40
|
unfilteredConfigs = (await backOff(() => axios.get(API_ENDPOINT), KAMINO_API_RETRY)).data as ConfigType;
|
|
35
41
|
}
|
|
36
42
|
|
package/src/utils/constants.ts
CHANGED
|
@@ -19,11 +19,11 @@ export function isENV(value: any): value is ENV {
|
|
|
19
19
|
return value === 'mainnet-beta' || value === 'devnet' || value === 'localnet';
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export function getApiEndpoint(programId: PublicKey) {
|
|
22
|
+
export function getApiEndpoint(programId: PublicKey, apiBaseUrl: string = 'https://api.kamino.finance') {
|
|
23
23
|
if (programId.equals(PROGRAM_ID)) {
|
|
24
|
-
return
|
|
24
|
+
return `${apiBaseUrl}/v2/kamino-market`;
|
|
25
25
|
} else {
|
|
26
|
-
return
|
|
26
|
+
return `${apiBaseUrl}/v2/kamino-market/?programId=${programId.toString()}`;
|
|
27
27
|
}
|
|
28
28
|
}
|
|
29
29
|
|
package/src/utils/instruction.ts
CHANGED
|
@@ -226,7 +226,7 @@ export const buildVersionedTransactionSync = (
|
|
|
226
226
|
payer: PublicKey,
|
|
227
227
|
instructions: TransactionInstruction[],
|
|
228
228
|
blockhash: Blockhash,
|
|
229
|
-
lookupTables: AddressLookupTableAccount[] = []
|
|
229
|
+
lookupTables: AddressLookupTableAccount[] = []
|
|
230
230
|
): VersionedTransaction => {
|
|
231
231
|
const messageV0 = new TransactionMessage({
|
|
232
232
|
payerKey: payer,
|
|
@@ -235,7 +235,7 @@ export const buildVersionedTransactionSync = (
|
|
|
235
235
|
}).compileToV0Message(lookupTables.filter(notEmpty));
|
|
236
236
|
|
|
237
237
|
return new VersionedTransaction(messageV0);
|
|
238
|
-
}
|
|
238
|
+
};
|
|
239
239
|
|
|
240
240
|
export const getLookupTableAccount = async (connection: Connection, address: PublicKey) => {
|
|
241
241
|
return connection.getAddressLookupTable(address).then((res) => res.value);
|
package/src/utils/lookupTable.ts
CHANGED
|
@@ -15,13 +15,7 @@ export async function createLookupTableIx(
|
|
|
15
15
|
connection: Connection,
|
|
16
16
|
wallet: PublicKey
|
|
17
17
|
): Promise<[TransactionInstruction, PublicKey]> {
|
|
18
|
-
|
|
19
|
-
authority: wallet,
|
|
20
|
-
payer: wallet,
|
|
21
|
-
recentSlot: await connection.getSlot('confirmed'),
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
return [createLookupTableIxs, lookupTableAddress];
|
|
18
|
+
return initLookupTableIx(wallet, await connection.getSlot('confirmed'));
|
|
25
19
|
}
|
|
26
20
|
|
|
27
21
|
export function extendLookupTableChunkIx(
|
|
@@ -262,7 +262,7 @@ export const DefaultConfigParams: AssetReserveConfigParams = {
|
|
|
262
262
|
borrowFeeSf: ZERO_FRACTION,
|
|
263
263
|
flashLoanFeeSf: ZERO_FRACTION,
|
|
264
264
|
protocolTakeRate: 0,
|
|
265
|
-
elevationGroups:
|
|
265
|
+
elevationGroups: new Array(20).fill(0),
|
|
266
266
|
priceFeed: null,
|
|
267
267
|
borrowLimit: new Decimal(1000.0),
|
|
268
268
|
depositLimit: new Decimal(1000.0),
|
package/src/utils/seeds.ts
CHANGED
|
@@ -39,6 +39,10 @@ export const BASE_SEED_REFERRER_STATE = 'ref_state';
|
|
|
39
39
|
* Short url seed
|
|
40
40
|
*/
|
|
41
41
|
export const BASE_SEED_SHORT_URL = 'short_url';
|
|
42
|
+
/**
|
|
43
|
+
* Short url seed
|
|
44
|
+
*/
|
|
45
|
+
export const BASE_SEED_GLOBAL_CONFIG_STATE = 'global_config';
|
|
42
46
|
/**
|
|
43
47
|
* Farm user state seed
|
|
44
48
|
*/
|
|
@@ -193,6 +197,27 @@ export function shortUrlPda(shortUrl: string, programId: PublicKey = PROGRAM_ID)
|
|
|
193
197
|
return PublicKey.findProgramAddressSync([Buffer.from(BASE_SEED_SHORT_URL), Buffer.from(shortUrl)], programId);
|
|
194
198
|
}
|
|
195
199
|
|
|
200
|
+
/**
|
|
201
|
+
* Returns the PDA and bump for the global config state.
|
|
202
|
+
* @param programId
|
|
203
|
+
* @returns [pda, bump]
|
|
204
|
+
*/
|
|
205
|
+
export function globalConfigPda(programId: PublicKey = PROGRAM_ID) {
|
|
206
|
+
return PublicKey.findProgramAddressSync([Buffer.from(BASE_SEED_GLOBAL_CONFIG_STATE)], programId);
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
/**
|
|
210
|
+
* Returns the PDA and bump for the program data.
|
|
211
|
+
* @param programId
|
|
212
|
+
* @returns [pda, bump]
|
|
213
|
+
*/
|
|
214
|
+
export function programDataPda(programId: PublicKey = PROGRAM_ID) {
|
|
215
|
+
return PublicKey.findProgramAddressSync(
|
|
216
|
+
[programId.toBuffer()],
|
|
217
|
+
new PublicKey('BPFLoaderUpgradeab1e11111111111111111111111')
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
196
221
|
/**
|
|
197
222
|
* Returns the PDA for the obligation farm state
|
|
198
223
|
* @param farm
|