@kamino-finance/klend-sdk 3.2.9 → 3.2.10
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/shared.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/classes/shared.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"shared.js","sourceRoot":"","sources":["../../src/classes/shared.ts"],"names":[],"mappings":";;;AAoBA,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,kCAAiB,CAAA;IACjB,sCAAqB,CAAA;IACrB,kCAAiB,CAAA;AACnB,CAAC,EAJW,aAAa,6BAAb,aAAa,QAIxB","sourcesContent":["import { PublicKey } from '@solana/web3.js';\nimport Decimal from 'decimal.js';\n\nexport type ConfigType = Array<MarketConfigType>;\n\nexport type MarketConfigType = {\n name: string;\n isPrimary: boolean;\n description: string;\n lendingMarket: string;\n lookupTable: string;\n};\n\nexport type ReserveConfigResponse = {\n liquidityToken: {\n symbol: string;\n mint: string;\n };\n};\n\nexport enum ReserveStatus {\n Active = 'Active',\n Obsolete = 'Obsolete',\n Hidden = 'Hidden',\n}\n\nexport type ReserveDataType = {\n status: ReserveStatus;\n mintAddress: PublicKey;\n borrowCurve: [number, number][];\n loanToValuePct: number;\n maxLiquidationBonus: number;\n minLiquidationBonus: number;\n liquidationThreshold: number;\n reserveDepositLimit: Decimal;\n reserveBorrowLimit: Decimal;\n depositLimitCrossedSlot: number;\n borrowLimitCrossedSlot: number;\n symbol: string;\n decimals: number;\n protocolTakeRate: number;\n accumulatedProtocolFees: Decimal;\n mintTotalSupply: Decimal;\n borrowFactor: number;\n};\n"]}
|
package/dist/utils/api.d.ts
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { PublicKey } from '@solana/web3.js';
|
|
2
2
|
import { ConfigType } from '../classes';
|
|
3
3
|
import { IBackOffOptions } from 'exponential-backoff';
|
|
4
|
+
/**
|
|
5
|
+
* Fetch config from the API
|
|
6
|
+
* A good place to start to find active klend markets without expensive RPC calls
|
|
7
|
+
*
|
|
8
|
+
* @param programId - The program id to retrieve config for
|
|
9
|
+
* @param source - CDN is a json file hosted in the cloud, API is a webserver
|
|
10
|
+
*/
|
|
4
11
|
export declare function getMarketsFromApi(programId?: PublicKey, source?: 'API' | 'CDN'): Promise<ConfigType>;
|
|
5
12
|
export declare const KAMINO_CDN_RETRY: Partial<IBackOffOptions>;
|
|
6
13
|
export declare const KAMINO_API_RETRY: Partial<IBackOffOptions>;
|
package/dist/utils/api.js
CHANGED
|
@@ -19,14 +19,21 @@ const classes_1 = require("../classes");
|
|
|
19
19
|
const utils_1 = require("../utils");
|
|
20
20
|
const exponential_backoff_1 = require("exponential-backoff");
|
|
21
21
|
const lib_1 = require("../lib");
|
|
22
|
+
/**
|
|
23
|
+
* Fetch config from the API
|
|
24
|
+
* A good place to start to find active klend markets without expensive RPC calls
|
|
25
|
+
*
|
|
26
|
+
* @param programId - The program id to retrieve config for
|
|
27
|
+
* @param source - CDN is a json file hosted in the cloud, API is a webserver
|
|
28
|
+
*/
|
|
22
29
|
function getMarketsFromApi() {
|
|
23
30
|
return __awaiter(this, arguments, void 0, function* (programId = lib_1.PROGRAM_ID, source = 'CDN') {
|
|
24
31
|
let configs = {};
|
|
25
32
|
if (source === 'CDN') {
|
|
26
33
|
configs = (yield (0, exponential_backoff_1.backOff)(() => axios_1.default.get(utils_1.CDN_ENDPOINT), exports.KAMINO_CDN_RETRY)).data[programId.toString()];
|
|
27
34
|
}
|
|
28
|
-
const API_ENDPOINT = (0, utils_1.getApiEndpoint)(programId);
|
|
29
35
|
if (!configs || (0, classes_1.isEmptyObject)(configs)) {
|
|
36
|
+
const API_ENDPOINT = (0, utils_1.getApiEndpoint)(programId);
|
|
30
37
|
configs = (yield (0, exponential_backoff_1.backOff)(() => axios_1.default.get(API_ENDPOINT), exports.KAMINO_API_RETRY)).data;
|
|
31
38
|
}
|
|
32
39
|
return configs;
|
package/dist/utils/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/utils/api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/utils/api.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAcA,8CAgBC;AA7BD,kDAA0B;AAC1B,wCAAuD;AACvD,oCAAwD;AACxD,6DAA+D;AAC/D,gCAAoC;AAEpC;;;;;;GAMG;AACH,SAAsB,iBAAiB;yDACrC,YAAuB,gBAAU,EACjC,SAAwB,KAAK;QAE7B,IAAI,OAAO,GAAe,EAAgB,CAAC;QAE3C,IAAI,MAAM,KAAK,KAAK,EAAE,CAAC;YACrB,OAAO,GAAG,CAAC,MAAM,IAAA,6BAAO,EAAC,GAAG,EAAE,CAAC,eAAK,CAAC,GAAG,CAAC,oBAAY,CAAC,EAAE,wBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAe,CAAC;QACtH,CAAC;QAED,IAAI,CAAC,OAAO,IAAI,IAAA,uBAAa,EAAC,OAAO,CAAC,EAAE,CAAC;YACvC,MAAM,YAAY,GAAG,IAAA,sBAAc,EAAC,SAAS,CAAC,CAAC;YAC/C,OAAO,GAAG,CAAC,MAAM,IAAA,6BAAO,EAAC,GAAG,EAAE,CAAC,eAAK,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE,wBAAgB,CAAC,CAAC,CAAC,IAAkB,CAAC;QAChG,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CAAA;AAEY,QAAA,gBAAgB,GAA6B;IACxD,QAAQ,EAAE,IAAI;IACd,aAAa,EAAE,CAAC;IAChB,aAAa,EAAE,EAAE;IACjB,KAAK,EAAE,CAAC,CAAM,EAAE,aAAqB,EAAE,EAAE;QACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAChB,OAAO,CAAC,IAAI,CAAC;YACX,aAAa;YACb,OAAO,EAAE,8DAA8D;SACxE,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAC;AAEW,QAAA,gBAAgB,GAA6B;IACxD,QAAQ,EAAE,IAAI;IACd,aAAa,EAAE,CAAC;IAChB,aAAa,EAAE,EAAE;IACjB,KAAK,EAAE,CAAC,CAAM,EAAE,aAAqB,EAAE,EAAE;QACvC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAChB,OAAO,CAAC,IAAI,CAAC;YACX,aAAa;YACb,OAAO,EAAE,sEAAsE;SAChF,CAAC,CAAC;QACH,OAAO,IAAI,CAAC;IACd,CAAC;CACF,CAAC","sourcesContent":["import { PublicKey } from '@solana/web3.js';\nimport axios from 'axios';\nimport { ConfigType, isEmptyObject } from '../classes';\nimport { CDN_ENDPOINT, getApiEndpoint } from '../utils';\nimport { IBackOffOptions, backOff } from 'exponential-backoff';\nimport { PROGRAM_ID } from '../lib';\n\n/**\n * Fetch config from the API\n * A good place to start to find active klend markets without expensive RPC calls\n *\n * @param programId - The program id to retrieve config for\n * @param source - CDN is a json file hosted in the cloud, API is a webserver\n */\nexport async function getMarketsFromApi(\n programId: PublicKey = PROGRAM_ID,\n source: 'API' | 'CDN' = 'CDN'\n): Promise<ConfigType> {\n let configs: ConfigType = {} as ConfigType;\n\n if (source === 'CDN') {\n configs = (await backOff(() => axios.get(CDN_ENDPOINT), KAMINO_CDN_RETRY)).data[programId.toString()] as ConfigType;\n }\n\n if (!configs || isEmptyObject(configs)) {\n const API_ENDPOINT = getApiEndpoint(programId);\n configs = (await backOff(() => axios.get(API_ENDPOINT), KAMINO_API_RETRY)).data as ConfigType;\n }\n\n return configs;\n}\n\nexport const KAMINO_CDN_RETRY: Partial<IBackOffOptions> = {\n maxDelay: 1000,\n numOfAttempts: 3,\n startingDelay: 10,\n retry: (e: any, attemptNumber: number) => {\n console.warn(e);\n console.warn({\n attemptNumber,\n message: 'kamino CDN call failed, retrying with exponential backoff...',\n });\n return true;\n },\n};\n\nexport const KAMINO_API_RETRY: Partial<IBackOffOptions> = {\n maxDelay: 1000,\n numOfAttempts: 3,\n startingDelay: 10,\n retry: (e: any, attemptNumber: number) => {\n console.warn(e);\n console.warn({\n attemptNumber,\n message: 'api.kamino.finance call failed, retrying with exponential backoff...',\n });\n return true;\n },\n};\n"]}
|