@suilend/sdk 1.0.7 → 1.0.9
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/core/api/events.d.ts +3 -0
- package/core/api/events.js +3 -0
- package/core/client.d.ts +1 -0
- package/core/client.js +10 -5
- package/core/constants.d.ts +4 -0
- package/core/constants.js +6 -1
- package/core/parsers/apiReserveAssetDataEvent.d.ts +10 -10
- package/core/parsers/apiReserveAssetDataEvent.js +23 -42
- package/core/parsers/deps.d.ts +3 -3
- package/core/parsers/obligation.d.ts +2 -0
- package/core/parsers/obligation.js +7 -4
- package/core/parsers/rateLimiter.js +2 -1
- package/core/parsers/reserve.js +3 -5
- package/core/types.d.ts +164 -0
- package/core/utils/events.d.ts +176 -0
- package/core/utils/events.js +104 -0
- package/core/utils/simulate.d.ts +56 -0
- package/core/utils/simulate.js +312 -0
- package/core/utils/utils.d.ts +61 -0
- package/core/utils/utils.js +157 -0
- package/core/utils.d.ts +4 -0
- package/core/utils.js +25 -1
- package/mainnet/_generated/suilend/index.d.ts +1 -1
- package/mainnet/_generated/suilend/index.js +1 -1
- package/mainnet/constants.d.ts +2 -0
- package/mainnet/constants.js +3 -0
- package/mainnet/utils/events.d.ts +1 -144
- package/mainnet/utils/events.js +14 -112
- package/mainnet/utils/obligation.d.ts +4 -4
- package/mainnet/utils/simulate.d.ts +30 -14
- package/mainnet/utils/simulate.js +53 -259
- package/mainnet/utils/utils.d.ts +1 -79
- package/mainnet/utils/utils.js +15 -155
- package/package.json +1 -1
package/core/api/events.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
import { DownsampledApiReserveAssetDataEvent } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Note: This SDK function is experimental and may change or require authentication in the future.
|
|
4
|
+
*/
|
|
2
5
|
export declare const fetchDownsampledApiReserveAssetDataEvents: (reserveId: string, days: number, sampleIntervalS: number) => Promise<DownsampledApiReserveAssetDataEvent[]>;
|
package/core/api/events.js
CHANGED
|
@@ -10,6 +10,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.fetchDownsampledApiReserveAssetDataEvents = void 0;
|
|
13
|
+
/**
|
|
14
|
+
* Note: This SDK function is experimental and may change or require authentication in the future.
|
|
15
|
+
*/
|
|
13
16
|
const fetchDownsampledApiReserveAssetDataEvents = (reserveId, days, sampleIntervalS) => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
17
|
const url = `https://api.suilend.fi/events/downsampled-reserve-asset-data?reserveId=${reserveId}&days=${days}&sampleIntervalS=${sampleIntervalS}`;
|
|
15
18
|
const res = yield fetch(url);
|
package/core/client.d.ts
CHANGED
|
@@ -93,6 +93,7 @@ export declare class SuilendClient {
|
|
|
93
93
|
refreshAll(txb: TransactionBlock, obligation: typeof this.Obligation, extraReserveArrayIndex?: bigint): Promise<void>;
|
|
94
94
|
refreshReservePrices(txb: TransactionBlock, priceInfoObjectId: string, reserveArrayIndex: bigint): Promise<void>;
|
|
95
95
|
deposit(sendCoin: ObjectArg, coinType: string, obligationOwnerCap: ObjectArg, txb: TransactionBlock): Promise<void>;
|
|
96
|
+
depositCoin(ownerId: string, sendCoin: ObjectArg, coinType: string, txb: TransactionBlock, obligationOwnerCapId?: string): Promise<void>;
|
|
96
97
|
depositIntoObligation(ownerId: string, coinType: string, value: string, txb: TransactionBlock, obligationOwnerCapId?: string): Promise<void>;
|
|
97
98
|
withdraw(obligationOwnerCapId: string, obligationId: string, coinType: string, value: string, txb: TransactionBlock): Promise<TransactionResult>;
|
|
98
99
|
withdrawFromObligation(ownerId: string, obligationOwnerCapId: string, obligationId: string, coinType: string, value: string, txb: TransactionBlock): Promise<void>;
|
package/core/client.js
CHANGED
|
@@ -341,12 +341,20 @@ class SuilendClient {
|
|
|
341
341
|
});
|
|
342
342
|
});
|
|
343
343
|
}
|
|
344
|
-
|
|
344
|
+
depositCoin(ownerId, sendCoin, coinType, txb, obligationOwnerCapId) {
|
|
345
345
|
return __awaiter(this, void 0, void 0, function* () {
|
|
346
346
|
let createdObligationOwnerCap;
|
|
347
347
|
if (!obligationOwnerCapId) {
|
|
348
348
|
createdObligationOwnerCap = this.createObligation(txb)[0];
|
|
349
349
|
}
|
|
350
|
+
this.deposit(sendCoin, coinType, (obligationOwnerCapId !== null && obligationOwnerCapId !== void 0 ? obligationOwnerCapId : createdObligationOwnerCap), txb);
|
|
351
|
+
if (createdObligationOwnerCap) {
|
|
352
|
+
txb.transferObjects([createdObligationOwnerCap], txb.pure(ownerId));
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
}
|
|
356
|
+
depositIntoObligation(ownerId, coinType, value, txb, obligationOwnerCapId) {
|
|
357
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
350
358
|
const isSui = (0, utils_1.normalizeStructTag)(coinType) === (0, utils_1.normalizeStructTag)(SUI_COINTYPE);
|
|
351
359
|
const coins = (yield this.client.getCoins({
|
|
352
360
|
owner: ownerId,
|
|
@@ -357,10 +365,7 @@ class SuilendClient {
|
|
|
357
365
|
txb.mergeCoins(txb.object(mergedCoin.coinObjectId), coins.map((c) => txb.object(c.coinObjectId)).slice(1));
|
|
358
366
|
}
|
|
359
367
|
const [sendCoin] = txb.splitCoins(isSui ? txb.gas : txb.object(mergedCoin.coinObjectId), [txb.pure(value)]);
|
|
360
|
-
this.
|
|
361
|
-
if (createdObligationOwnerCap) {
|
|
362
|
-
txb.transferObjects([createdObligationOwnerCap], txb.pure(ownerId));
|
|
363
|
-
}
|
|
368
|
+
this.depositCoin(ownerId, sendCoin, coinType, txb, obligationOwnerCapId);
|
|
364
369
|
});
|
|
365
370
|
}
|
|
366
371
|
withdraw(obligationOwnerCapId, obligationId, coinType, value, txb) {
|
package/core/constants.d.ts
CHANGED
package/core/constants.js
CHANGED
|
@@ -3,7 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.WAD = exports.maxU64 = void 0;
|
|
6
|
+
exports.SdkEnv = exports.WAD = exports.maxU64 = void 0;
|
|
7
7
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
8
|
exports.maxU64 = new bignumber_js_1.default(2).pow(64).minus(1);
|
|
9
9
|
exports.WAD = new bignumber_js_1.default(10).pow(18);
|
|
10
|
+
var SdkEnv;
|
|
11
|
+
(function (SdkEnv) {
|
|
12
|
+
SdkEnv["BETA"] = "beta";
|
|
13
|
+
SdkEnv["MAINNET"] = "mainnet";
|
|
14
|
+
})(SdkEnv || (exports.SdkEnv = SdkEnv = {}));
|
|
@@ -4,20 +4,19 @@ import { ParsedReserve } from "./reserve";
|
|
|
4
4
|
export type ParsedReserveAssetDataEvent = ReturnType<typeof parseReserveAssetDataEvent>;
|
|
5
5
|
export declare const parseReserveAssetDataEvent: (event: ApiReserveAssetDataEvent, reserve: ParsedReserve) => {
|
|
6
6
|
id: number;
|
|
7
|
-
|
|
7
|
+
lendingMarketId: string;
|
|
8
8
|
coinType: string;
|
|
9
9
|
reserveId: string;
|
|
10
|
+
availableAmount: BigNumber;
|
|
10
11
|
depositedAmount: BigNumber;
|
|
11
12
|
borrowedAmount: BigNumber;
|
|
12
|
-
|
|
13
|
+
availableAmountUsd: BigNumber;
|
|
13
14
|
depositedAmountUsd: BigNumber;
|
|
14
15
|
borrowedAmountUsd: BigNumber;
|
|
15
|
-
availableAmountUsd: BigNumber;
|
|
16
|
-
utilizationPercent: BigNumber;
|
|
17
16
|
borrowAprPercent: BigNumber;
|
|
18
17
|
depositAprPercent: BigNumber;
|
|
19
18
|
ctokenSupply: BigNumber;
|
|
20
|
-
cumulativeBorrowRate:
|
|
19
|
+
cumulativeBorrowRate: BigNumber;
|
|
21
20
|
price: BigNumber;
|
|
22
21
|
smoothedPrice: BigNumber;
|
|
23
22
|
minPrice: BigNumber;
|
|
@@ -27,25 +26,25 @@ export declare const parseReserveAssetDataEvent: (event: ApiReserveAssetDataEven
|
|
|
27
26
|
digest: string;
|
|
28
27
|
eventIndex: number;
|
|
29
28
|
sender: string;
|
|
29
|
+
utilizationPercent: BigNumber;
|
|
30
30
|
};
|
|
31
31
|
export type ParsedDownsampledApiReserveAssetDataEvent = ReturnType<typeof parseDownsampledApiReserveAssetDataEvent>;
|
|
32
32
|
export declare const parseDownsampledApiReserveAssetDataEvent: (event: DownsampledApiReserveAssetDataEvent, reserve: ParsedReserve) => {
|
|
33
33
|
sampleTimestampS: number;
|
|
34
34
|
id: number;
|
|
35
|
-
|
|
35
|
+
lendingMarketId: string;
|
|
36
36
|
coinType: string;
|
|
37
37
|
reserveId: string;
|
|
38
|
+
availableAmount: BigNumber;
|
|
38
39
|
depositedAmount: BigNumber;
|
|
39
40
|
borrowedAmount: BigNumber;
|
|
40
|
-
|
|
41
|
+
availableAmountUsd: BigNumber;
|
|
41
42
|
depositedAmountUsd: BigNumber;
|
|
42
43
|
borrowedAmountUsd: BigNumber;
|
|
43
|
-
availableAmountUsd: BigNumber;
|
|
44
|
-
utilizationPercent: BigNumber;
|
|
45
44
|
borrowAprPercent: BigNumber;
|
|
46
45
|
depositAprPercent: BigNumber;
|
|
47
46
|
ctokenSupply: BigNumber;
|
|
48
|
-
cumulativeBorrowRate:
|
|
47
|
+
cumulativeBorrowRate: BigNumber;
|
|
49
48
|
price: BigNumber;
|
|
50
49
|
smoothedPrice: BigNumber;
|
|
51
50
|
minPrice: BigNumber;
|
|
@@ -55,4 +54,5 @@ export declare const parseDownsampledApiReserveAssetDataEvent: (event: Downsampl
|
|
|
55
54
|
digest: string;
|
|
56
55
|
eventIndex: number;
|
|
57
56
|
sender: string;
|
|
57
|
+
utilizationPercent: BigNumber;
|
|
58
58
|
};
|
|
@@ -7,68 +7,48 @@ exports.parseDownsampledApiReserveAssetDataEvent = exports.parseReserveAssetData
|
|
|
7
7
|
const utils_1 = require("@mysten/sui.js/utils");
|
|
8
8
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
9
9
|
const constants_1 = require("../constants");
|
|
10
|
-
const calculateBorrowAprPercent = (utilizationPercent, reserve) => {
|
|
11
|
-
const config = reserve.config;
|
|
12
|
-
let i = 1;
|
|
13
|
-
while (i < config.interestRate.length) {
|
|
14
|
-
const leftUtilPercent = config.interestRate[i - 1].utilPercent;
|
|
15
|
-
const leftAprPercent = config.interestRate[i - 1].aprPercent;
|
|
16
|
-
const rightUtilPercent = config.interestRate[i].utilPercent;
|
|
17
|
-
const rightAprPercent = config.interestRate[i].aprPercent;
|
|
18
|
-
if (utilizationPercent.gte(leftUtilPercent) &&
|
|
19
|
-
utilizationPercent.lte(rightUtilPercent)) {
|
|
20
|
-
const weight = new bignumber_js_1.default(utilizationPercent.minus(leftUtilPercent)).div(rightUtilPercent.minus(leftUtilPercent));
|
|
21
|
-
return leftAprPercent.plus(weight.times(rightAprPercent.minus(leftAprPercent)));
|
|
22
|
-
}
|
|
23
|
-
i = i + 1;
|
|
24
|
-
}
|
|
25
|
-
// Should never reach here
|
|
26
|
-
return new bignumber_js_1.default(0);
|
|
27
|
-
};
|
|
28
10
|
const parseReserveAssetDataEvent = (event, reserve) => {
|
|
29
|
-
const
|
|
11
|
+
const availableAmount = new bignumber_js_1.default(event.availableAmount)
|
|
30
12
|
.div(constants_1.WAD)
|
|
31
13
|
.div(10 ** reserve.mintDecimals);
|
|
32
|
-
const
|
|
14
|
+
const depositedAmount = new bignumber_js_1.default(event.supplyAmount)
|
|
33
15
|
.div(constants_1.WAD)
|
|
34
16
|
.div(10 ** reserve.mintDecimals);
|
|
35
|
-
const
|
|
17
|
+
const borrowedAmount = new bignumber_js_1.default(event.borrowedAmount)
|
|
36
18
|
.div(constants_1.WAD)
|
|
37
19
|
.div(10 ** reserve.mintDecimals);
|
|
20
|
+
const availableAmountUsd = new bignumber_js_1.default(event.availableAmountUsdEstimate).div(constants_1.WAD);
|
|
21
|
+
const depositedAmountUsd = new bignumber_js_1.default(event.supplyAmountUsdEstimate).div(constants_1.WAD);
|
|
22
|
+
const borrowedAmountUsd = new bignumber_js_1.default(event.borrowedAmountUsdEstimate).div(constants_1.WAD);
|
|
23
|
+
const borrowAprPercent = new bignumber_js_1.default(event.borrowApr).div(constants_1.WAD).times(100);
|
|
24
|
+
const depositAprPercent = new bignumber_js_1.default(event.supplyApr).div(constants_1.WAD).times(100);
|
|
38
25
|
const ctokenSupply = new bignumber_js_1.default(event.ctokenSupply).div(10 ** reserve.mintDecimals);
|
|
39
|
-
const
|
|
40
|
-
? new bignumber_js_1.default(0)
|
|
41
|
-
: borrowedAmount.div(depositedAmount).times(100);
|
|
42
|
-
const borrowAprPercent = calculateBorrowAprPercent(utilizationPercent, reserve);
|
|
43
|
-
const depositAprPercent = utilizationPercent
|
|
44
|
-
.div(100)
|
|
45
|
-
.times(borrowAprPercent.div(100))
|
|
46
|
-
.times(new bignumber_js_1.default(100).minus(new bignumber_js_1.default(reserve.config.spreadFeeBps).div(100)));
|
|
26
|
+
const cumulativeBorrowRate = new bignumber_js_1.default(event.cumulativeBorrowRate).div(constants_1.WAD);
|
|
47
27
|
const price = new bignumber_js_1.default(event.price).div(constants_1.WAD);
|
|
48
28
|
const smoothedPrice = new bignumber_js_1.default(event.smoothedPrice).div(constants_1.WAD);
|
|
49
29
|
const minPrice = bignumber_js_1.default.min(price, smoothedPrice);
|
|
50
30
|
const maxPrice = bignumber_js_1.default.max(price, smoothedPrice);
|
|
51
|
-
|
|
52
|
-
const
|
|
53
|
-
|
|
31
|
+
// Custom
|
|
32
|
+
const utilizationPercent = depositedAmount.eq(0)
|
|
33
|
+
? new bignumber_js_1.default(0)
|
|
34
|
+
: borrowedAmount.div(depositedAmount).times(100);
|
|
54
35
|
return {
|
|
55
36
|
id: event.id,
|
|
56
|
-
|
|
37
|
+
lendingMarketId: event.lendingMarketId,
|
|
57
38
|
coinType: (0, utils_1.normalizeStructTag)(event.coinType),
|
|
58
39
|
reserveId: event.reserveId,
|
|
40
|
+
availableAmount,
|
|
59
41
|
depositedAmount,
|
|
60
42
|
borrowedAmount,
|
|
61
|
-
|
|
43
|
+
availableAmountUsd,
|
|
62
44
|
depositedAmountUsd,
|
|
63
45
|
borrowedAmountUsd,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
price: price,
|
|
71
|
-
smoothedPrice: smoothedPrice,
|
|
46
|
+
borrowAprPercent,
|
|
47
|
+
depositAprPercent,
|
|
48
|
+
ctokenSupply,
|
|
49
|
+
cumulativeBorrowRate,
|
|
50
|
+
price,
|
|
51
|
+
smoothedPrice,
|
|
72
52
|
minPrice,
|
|
73
53
|
maxPrice,
|
|
74
54
|
priceLastUpdateTimestampS: event.priceLastUpdateTimestampS,
|
|
@@ -76,6 +56,7 @@ const parseReserveAssetDataEvent = (event, reserve) => {
|
|
|
76
56
|
digest: event.digest,
|
|
77
57
|
eventIndex: event.eventIndex,
|
|
78
58
|
sender: event.sender,
|
|
59
|
+
utilizationPercent,
|
|
79
60
|
};
|
|
80
61
|
};
|
|
81
62
|
exports.parseReserveAssetDataEvent = parseReserveAssetDataEvent;
|
package/core/parsers/deps.d.ts
CHANGED
|
@@ -6,10 +6,10 @@ export interface Deps {
|
|
|
6
6
|
PoolRewardManager: any;
|
|
7
7
|
PoolReward: any;
|
|
8
8
|
simulate: {
|
|
9
|
+
calculateUtilizationPercent: (reserve: Deps["Reserve"]) => BigNumber;
|
|
10
|
+
calculateBorrowAprPercent: (reserve: Deps["Reserve"]) => BigNumber;
|
|
11
|
+
calculateDepositAprPercent: (reserve: Deps["Reserve"]) => BigNumber;
|
|
9
12
|
cTokenRatio: (reserve: Deps["Reserve"]) => BigNumber;
|
|
10
|
-
calculateBorrowApr: (reserve: Deps["Reserve"]) => BigNumber;
|
|
11
|
-
calculateSupplyApr: (reserve: Deps["Reserve"]) => BigNumber;
|
|
12
|
-
calculateUtilizationRate: (reserve: Deps["Reserve"]) => BigNumber;
|
|
13
13
|
};
|
|
14
14
|
RateLimiter: any;
|
|
15
15
|
}
|
|
@@ -15,6 +15,8 @@ export declare const parseObligation: ({ Obligation }: Pick<Deps, "Obligation">,
|
|
|
15
15
|
borrowLimitUsd: BigNumber;
|
|
16
16
|
minPriceBorrowLimitUsd: BigNumber;
|
|
17
17
|
unhealthyBorrowValueUsd: BigNumber;
|
|
18
|
+
depositPositionCount: number;
|
|
19
|
+
borrowPositionCount: number;
|
|
18
20
|
positionCount: number;
|
|
19
21
|
deposits: {
|
|
20
22
|
coinType: string;
|
|
@@ -15,13 +15,14 @@ const parseObligation = ({ Obligation }, obligation, parsedReserveMap) => {
|
|
|
15
15
|
let borrowLimitUsd = new bignumber_js_1.default(0);
|
|
16
16
|
let minPriceBorrowLimitUsd = new bignumber_js_1.default(0);
|
|
17
17
|
let unhealthyBorrowValueUsd = new bignumber_js_1.default(0);
|
|
18
|
-
let
|
|
18
|
+
let depositPositionCount = 0;
|
|
19
|
+
let borrowPositionCount = 0;
|
|
19
20
|
const deposits = obligation.deposits.map((deposit) => {
|
|
20
21
|
const coinType = (0, utils_1.normalizeStructTag)(deposit.coinType.name);
|
|
21
22
|
const reserve = parsedReserveMap[coinType];
|
|
22
23
|
if (!reserve)
|
|
23
24
|
throw new Error(`Reserve with coinType ${deposit.coinType.name} not found`);
|
|
24
|
-
|
|
25
|
+
depositPositionCount++;
|
|
25
26
|
const depositedCtokenAmount = new bignumber_js_1.default(deposit.depositedCtokenAmount.toString()).div(10 ** reserve.mintDecimals);
|
|
26
27
|
const depositedAmount = depositedCtokenAmount.times(reserve.cTokenExchangeRate);
|
|
27
28
|
const depositedAmountUsd = depositedAmount.times(reserve.price);
|
|
@@ -50,7 +51,7 @@ const parseObligation = ({ Obligation }, obligation, parsedReserveMap) => {
|
|
|
50
51
|
const reserve = parsedReserveMap[coinType];
|
|
51
52
|
if (!reserve)
|
|
52
53
|
throw new Error(`Reserve with coinType ${borrow.coinType.name} not found`);
|
|
53
|
-
|
|
54
|
+
borrowPositionCount++;
|
|
54
55
|
const cumulativeBorrowRate = new bignumber_js_1.default(borrow.cumulativeBorrowRate.value.toString()).div(constants_1.WAD);
|
|
55
56
|
const borrowedAmountInitial = new bignumber_js_1.default(borrow.borrowedAmount.value.toString())
|
|
56
57
|
.div(constants_1.WAD)
|
|
@@ -90,7 +91,9 @@ const parseObligation = ({ Obligation }, obligation, parsedReserveMap) => {
|
|
|
90
91
|
borrowLimitUsd,
|
|
91
92
|
minPriceBorrowLimitUsd,
|
|
92
93
|
unhealthyBorrowValueUsd,
|
|
93
|
-
|
|
94
|
+
depositPositionCount,
|
|
95
|
+
borrowPositionCount,
|
|
96
|
+
positionCount: depositPositionCount + borrowPositionCount,
|
|
94
97
|
deposits,
|
|
95
98
|
borrows,
|
|
96
99
|
weightedConservativeBorrowUtilizationPercent,
|
|
@@ -5,6 +5,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.parseRateLimiterConfig = exports.parseRateLimiter = void 0;
|
|
7
7
|
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
|
+
const constants_1 = require("../constants");
|
|
8
9
|
const parseRateLimiter = ({ RateLimiter }, rateLimiter, currentTime) => {
|
|
9
10
|
const config = (0, exports.parseRateLimiterConfig)({ RateLimiter }, rateLimiter);
|
|
10
11
|
const $typeName = rateLimiter.$typeName;
|
|
@@ -18,7 +19,7 @@ const parseRateLimiter = ({ RateLimiter }, rateLimiter, currentTime) => {
|
|
|
18
19
|
const currentOutflow = prevWeight
|
|
19
20
|
.times(new bignumber_js_1.default(prevQty.toString()))
|
|
20
21
|
.plus(new bignumber_js_1.default(curQty.toString()))
|
|
21
|
-
.div(
|
|
22
|
+
.div(constants_1.WAD);
|
|
22
23
|
const remainingOutflow = currentOutflow.gt(config.maxOutflow.toString())
|
|
23
24
|
? new bignumber_js_1.default(0)
|
|
24
25
|
: new bignumber_js_1.default(config.maxOutflow.toString()).minus(currentOutflow);
|
package/core/parsers/reserve.js
CHANGED
|
@@ -44,11 +44,9 @@ const parseReserve = ({ Reserve, PoolRewardManager, PoolReward, simulate, }, res
|
|
|
44
44
|
.minus(unclaimedSpreadFees);
|
|
45
45
|
const depositedAmountUsd = depositedAmount.times(price);
|
|
46
46
|
const cTokenExchangeRate = simulate.cTokenRatio(reserve);
|
|
47
|
-
const borrowAprPercent = simulate.
|
|
48
|
-
const depositAprPercent = simulate.
|
|
49
|
-
const utilizationPercent = simulate
|
|
50
|
-
.calculateUtilizationRate(reserve)
|
|
51
|
-
.times(100);
|
|
47
|
+
const borrowAprPercent = simulate.calculateBorrowAprPercent(reserve);
|
|
48
|
+
const depositAprPercent = simulate.calculateDepositAprPercent(reserve);
|
|
49
|
+
const utilizationPercent = simulate.calculateUtilizationPercent(reserve);
|
|
52
50
|
const symbol = coinMetadata.symbol;
|
|
53
51
|
const name = coinMetadata.name;
|
|
54
52
|
const iconUrl = coinMetadata.iconUrl;
|
package/core/types.d.ts
CHANGED
|
@@ -672,6 +672,27 @@ export interface MigrateArgs {
|
|
|
672
672
|
lendingMarketOwnerCap: ObjectArg;
|
|
673
673
|
lendingMarket: ObjectArg;
|
|
674
674
|
}
|
|
675
|
+
export type ApiInterestUpdateEvent = {
|
|
676
|
+
id: number;
|
|
677
|
+
lendingMarketId: string;
|
|
678
|
+
coinType: string;
|
|
679
|
+
reserveId: string;
|
|
680
|
+
cumulativeBorrowRate: string;
|
|
681
|
+
availableAmount: string;
|
|
682
|
+
borrowedAmount: string;
|
|
683
|
+
unclaimedSpreadFees: string;
|
|
684
|
+
ctokenSupply: string;
|
|
685
|
+
borrowInterestPaid: string;
|
|
686
|
+
spreadFee: string;
|
|
687
|
+
supplyInterestEarned: string;
|
|
688
|
+
borrowInterestPaidUsdEstimate: string;
|
|
689
|
+
protocolFeeUsdEstimate: string;
|
|
690
|
+
supplyInterestEarnedUsdEstimate: string;
|
|
691
|
+
timestamp: number;
|
|
692
|
+
digest: string;
|
|
693
|
+
eventIndex: number;
|
|
694
|
+
sender: string;
|
|
695
|
+
};
|
|
675
696
|
export type ApiReserveAssetDataEvent = {
|
|
676
697
|
id: number;
|
|
677
698
|
lendingMarketId: string;
|
|
@@ -698,3 +719,146 @@ export type ApiReserveAssetDataEvent = {
|
|
|
698
719
|
export type DownsampledApiReserveAssetDataEvent = ApiReserveAssetDataEvent & {
|
|
699
720
|
sampletimestamp: number;
|
|
700
721
|
};
|
|
722
|
+
export type ApiMintEvent = {
|
|
723
|
+
id: number;
|
|
724
|
+
lendingMarketId: string;
|
|
725
|
+
coinType: string;
|
|
726
|
+
reserveId: string;
|
|
727
|
+
liquidityAmount: string;
|
|
728
|
+
ctokenAmount: string;
|
|
729
|
+
timestamp: number;
|
|
730
|
+
digest: string;
|
|
731
|
+
eventIndex: number;
|
|
732
|
+
sender: string;
|
|
733
|
+
};
|
|
734
|
+
export type ApiRedeemEvent = {
|
|
735
|
+
id: number;
|
|
736
|
+
lendingMarketId: string;
|
|
737
|
+
coinType: string;
|
|
738
|
+
reserveId: string;
|
|
739
|
+
ctokenAmount: string;
|
|
740
|
+
liquidityAmount: string;
|
|
741
|
+
timestamp: number;
|
|
742
|
+
digest: string;
|
|
743
|
+
eventIndex: number;
|
|
744
|
+
sender: string;
|
|
745
|
+
};
|
|
746
|
+
export type ApiDepositEvent = {
|
|
747
|
+
id: number;
|
|
748
|
+
lendingMarketId: string;
|
|
749
|
+
coinType: string;
|
|
750
|
+
reserveId: string;
|
|
751
|
+
obligationId: string;
|
|
752
|
+
ctokenAmount: string;
|
|
753
|
+
timestamp: number;
|
|
754
|
+
digest: string;
|
|
755
|
+
eventIndex: number;
|
|
756
|
+
sender: string;
|
|
757
|
+
};
|
|
758
|
+
export type ApiWithdrawEvent = {
|
|
759
|
+
id: number;
|
|
760
|
+
lendingMarketId: string;
|
|
761
|
+
coinType: string;
|
|
762
|
+
reserveId: string;
|
|
763
|
+
obligationId: string;
|
|
764
|
+
ctokenAmount: string;
|
|
765
|
+
timestamp: number;
|
|
766
|
+
digest: string;
|
|
767
|
+
eventIndex: number;
|
|
768
|
+
sender: string;
|
|
769
|
+
};
|
|
770
|
+
export type ApiBorrowEvent = {
|
|
771
|
+
id: number;
|
|
772
|
+
lendingMarketId: string;
|
|
773
|
+
coinType: string;
|
|
774
|
+
reserveId: string;
|
|
775
|
+
obligationId: string;
|
|
776
|
+
liquidityAmount: string;
|
|
777
|
+
originationFeeAmount: string;
|
|
778
|
+
timestamp: number;
|
|
779
|
+
digest: string;
|
|
780
|
+
eventIndex: number;
|
|
781
|
+
sender: string;
|
|
782
|
+
};
|
|
783
|
+
export type ApiRepayEvent = {
|
|
784
|
+
id: number;
|
|
785
|
+
lendingMarketId: string;
|
|
786
|
+
coinType: string;
|
|
787
|
+
reserveId: string;
|
|
788
|
+
obligationId: string;
|
|
789
|
+
liquidityAmount: string;
|
|
790
|
+
timestamp: number;
|
|
791
|
+
digest: string;
|
|
792
|
+
eventIndex: number;
|
|
793
|
+
sender: string;
|
|
794
|
+
};
|
|
795
|
+
export type ApiLiquidateEvent = {
|
|
796
|
+
id: number;
|
|
797
|
+
lendingMarketId: string;
|
|
798
|
+
repayReserveId: string;
|
|
799
|
+
withdrawReserveId: string;
|
|
800
|
+
obligationId: string;
|
|
801
|
+
repayAmount: string;
|
|
802
|
+
withdrawAmount: string;
|
|
803
|
+
protocolFeeAmount: string;
|
|
804
|
+
liquidatorBonusAmount: string;
|
|
805
|
+
timestamp: number;
|
|
806
|
+
digest: string;
|
|
807
|
+
eventIndex: number;
|
|
808
|
+
sender: string;
|
|
809
|
+
};
|
|
810
|
+
export type ApiClaimRewardEvent = {
|
|
811
|
+
id: number;
|
|
812
|
+
lendingMarketId: string;
|
|
813
|
+
reserveId: string;
|
|
814
|
+
obligationId: string;
|
|
815
|
+
isDepositReward: boolean;
|
|
816
|
+
poolRewardId: string;
|
|
817
|
+
coinType: string;
|
|
818
|
+
liquidityAmount: string;
|
|
819
|
+
timestamp: number;
|
|
820
|
+
digest: string;
|
|
821
|
+
eventIndex: number;
|
|
822
|
+
sender: string;
|
|
823
|
+
};
|
|
824
|
+
export type ApiObligationDataEvent = {
|
|
825
|
+
id: number;
|
|
826
|
+
lendingMarketId: string;
|
|
827
|
+
obligationId: string;
|
|
828
|
+
depositedValueUsd: string;
|
|
829
|
+
allowedBorrowValueUsd: string;
|
|
830
|
+
unhealthyBorrowValueUsd: string;
|
|
831
|
+
superUnhealthyBorrowValueUsd: string;
|
|
832
|
+
unweightedBorrowedValueUsd: string;
|
|
833
|
+
weightedBorrowedValueUsd: string;
|
|
834
|
+
weightedBorrowedValueUpperBoundUsd: string;
|
|
835
|
+
borrowingIsolatedAsset: boolean;
|
|
836
|
+
badDebtUsd: string;
|
|
837
|
+
closable: boolean;
|
|
838
|
+
timestamp: number;
|
|
839
|
+
digest: string;
|
|
840
|
+
eventIndex: number;
|
|
841
|
+
sender: string;
|
|
842
|
+
/**
|
|
843
|
+
* {
|
|
844
|
+
* coin_type: TypeName;
|
|
845
|
+
* reserve_array_index: u64;
|
|
846
|
+
* deposited_ctoken_amount: u64;
|
|
847
|
+
* market_value: Decimal;
|
|
848
|
+
* user_reward_manager_index: u64;
|
|
849
|
+
* attributed_borrow_value: Decimal;
|
|
850
|
+
* }[]
|
|
851
|
+
*/
|
|
852
|
+
depositsJson: string;
|
|
853
|
+
/**
|
|
854
|
+
* {
|
|
855
|
+
* coin_type: TypeName;
|
|
856
|
+
* reserve_array_index: u64;
|
|
857
|
+
* borrowed_amount: Decimal;
|
|
858
|
+
* cumulative_borrow_rate: Decimal;
|
|
859
|
+
* market_value: Decimal;
|
|
860
|
+
* user_reward_manager_index: u64;
|
|
861
|
+
* }[]
|
|
862
|
+
*/
|
|
863
|
+
borrowsJson: string;
|
|
864
|
+
};
|