@suilend/sdk 1.0.6 → 1.0.8

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/README.md CHANGED
@@ -4,4 +4,8 @@ A TypeScript SDK for interacting with the Suilend program published on npm as [`
4
4
 
5
5
  For examples, please see [suilend-public/frontend](https://github.com/solendprotocol/suilend-public/tree/HEAD/frontend), an open-source Suilend client powered by and developed alongside the Suilend SDK, in the Suilend monorepo.
6
6
 
7
- Note: `suilend-public/frontend` imports the SDK directly from the Suilend monorepo via aliased paths (see [suilend-public/frontend/tsconfig.ts](https://github.com/solendprotocol/suilend-public/tree/HEAD/frontend/tsconfig.json)) instead of the npm package, so the import paths may look slightly different.
7
+ Note: `suilend-public/frontend` imports the SDK directly from the Suilend monorepo via aliased paths (see [suilend-public/frontend/tsconfig.ts](https://github.com/solendprotocol/suilend-public/tree/HEAD/frontend/tsconfig.json)) and does not use the npm package, so the import paths may look slightly different.
8
+
9
+ ---
10
+
11
+ Got a suggestion, running into issues, or have a question? Join our [#dev-support](https://discord.com/channels/1202984617087598622/1238023733403193385) channel on Discord.
@@ -0,0 +1,5 @@
1
+ import { DownsampledApiReserveAssetDataEvent } from "../types";
2
+ /**
3
+ * Note: This SDK function is experimental and may change or require authentication in the future.
4
+ */
5
+ export declare const fetchDownsampledApiReserveAssetDataEvents: (reserveId: string, days: number, sampleIntervalS: number) => Promise<DownsampledApiReserveAssetDataEvent[]>;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.fetchDownsampledApiReserveAssetDataEvents = void 0;
13
+ /**
14
+ * Note: This SDK function is experimental and may change or require authentication in the future.
15
+ */
16
+ const fetchDownsampledApiReserveAssetDataEvents = (reserveId, days, sampleIntervalS) => __awaiter(void 0, void 0, void 0, function* () {
17
+ const url = `https://api.suilend.fi/events/downsampled-reserve-asset-data?reserveId=${reserveId}&days=${days}&sampleIntervalS=${sampleIntervalS}`;
18
+ const res = yield fetch(url);
19
+ const json = yield res.json();
20
+ return json;
21
+ });
22
+ exports.fetchDownsampledApiReserveAssetDataEvents = fetchDownsampledApiReserveAssetDataEvents;
@@ -1,2 +1,3 @@
1
- export declare const maxU64: bigint;
2
- export declare const WAD: bigint;
1
+ import BigNumber from "bignumber.js";
2
+ export declare const maxU64: BigNumber;
3
+ export declare const WAD: BigNumber;
package/core/constants.js CHANGED
@@ -1,5 +1,9 @@
1
1
  "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
2
5
  Object.defineProperty(exports, "__esModule", { value: true });
3
6
  exports.WAD = exports.maxU64 = void 0;
4
- exports.maxU64 = BigInt(2) ** BigInt(64) - BigInt(1);
5
- exports.WAD = BigInt(10) ** BigInt(18);
7
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
8
+ exports.maxU64 = new bignumber_js_1.default(2).pow(64).minus(1);
9
+ exports.WAD = new bignumber_js_1.default(10).pow(18);
@@ -0,0 +1,58 @@
1
+ import BigNumber from "bignumber.js";
2
+ import { ApiReserveAssetDataEvent, DownsampledApiReserveAssetDataEvent } from "../types";
3
+ import { ParsedReserve } from "./reserve";
4
+ export type ParsedReserveAssetDataEvent = ReturnType<typeof parseReserveAssetDataEvent>;
5
+ export declare const parseReserveAssetDataEvent: (event: ApiReserveAssetDataEvent, reserve: ParsedReserve) => {
6
+ id: number;
7
+ lendingMarketId: string;
8
+ coinType: string;
9
+ reserveId: string;
10
+ availableAmount: BigNumber;
11
+ depositedAmount: BigNumber;
12
+ borrowedAmount: BigNumber;
13
+ availableAmountUsd: BigNumber;
14
+ depositedAmountUsd: BigNumber;
15
+ borrowedAmountUsd: BigNumber;
16
+ borrowAprPercent: BigNumber;
17
+ depositAprPercent: BigNumber;
18
+ ctokenSupply: BigNumber;
19
+ cumulativeBorrowRate: BigNumber;
20
+ price: BigNumber;
21
+ smoothedPrice: BigNumber;
22
+ minPrice: BigNumber;
23
+ maxPrice: BigNumber;
24
+ priceLastUpdateTimestampS: number;
25
+ timestampS: number;
26
+ digest: string;
27
+ eventIndex: number;
28
+ sender: string;
29
+ utilizationPercent: BigNumber;
30
+ };
31
+ export type ParsedDownsampledApiReserveAssetDataEvent = ReturnType<typeof parseDownsampledApiReserveAssetDataEvent>;
32
+ export declare const parseDownsampledApiReserveAssetDataEvent: (event: DownsampledApiReserveAssetDataEvent, reserve: ParsedReserve) => {
33
+ sampleTimestampS: number;
34
+ id: number;
35
+ lendingMarketId: string;
36
+ coinType: string;
37
+ reserveId: string;
38
+ availableAmount: BigNumber;
39
+ depositedAmount: BigNumber;
40
+ borrowedAmount: BigNumber;
41
+ availableAmountUsd: BigNumber;
42
+ depositedAmountUsd: BigNumber;
43
+ borrowedAmountUsd: BigNumber;
44
+ borrowAprPercent: BigNumber;
45
+ depositAprPercent: BigNumber;
46
+ ctokenSupply: BigNumber;
47
+ cumulativeBorrowRate: BigNumber;
48
+ price: BigNumber;
49
+ smoothedPrice: BigNumber;
50
+ minPrice: BigNumber;
51
+ maxPrice: BigNumber;
52
+ priceLastUpdateTimestampS: number;
53
+ timestampS: number;
54
+ digest: string;
55
+ eventIndex: number;
56
+ sender: string;
57
+ utilizationPercent: BigNumber;
58
+ };
@@ -0,0 +1,66 @@
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.parseDownsampledApiReserveAssetDataEvent = exports.parseReserveAssetDataEvent = void 0;
7
+ const utils_1 = require("@mysten/sui.js/utils");
8
+ const bignumber_js_1 = __importDefault(require("bignumber.js"));
9
+ const constants_1 = require("../constants");
10
+ const parseReserveAssetDataEvent = (event, reserve) => {
11
+ const availableAmount = new bignumber_js_1.default(event.availableAmount)
12
+ .div(constants_1.WAD)
13
+ .div(10 ** reserve.mintDecimals);
14
+ const depositedAmount = new bignumber_js_1.default(event.supplyAmount)
15
+ .div(constants_1.WAD)
16
+ .div(10 ** reserve.mintDecimals);
17
+ const borrowedAmount = new bignumber_js_1.default(event.borrowedAmount)
18
+ .div(constants_1.WAD)
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);
25
+ const ctokenSupply = new bignumber_js_1.default(event.ctokenSupply).div(10 ** reserve.mintDecimals);
26
+ const cumulativeBorrowRate = new bignumber_js_1.default(event.cumulativeBorrowRate).div(constants_1.WAD);
27
+ const price = new bignumber_js_1.default(event.price).div(constants_1.WAD);
28
+ const smoothedPrice = new bignumber_js_1.default(event.smoothedPrice).div(constants_1.WAD);
29
+ const minPrice = bignumber_js_1.default.min(price, smoothedPrice);
30
+ const maxPrice = bignumber_js_1.default.max(price, smoothedPrice);
31
+ // Custom
32
+ const utilizationPercent = depositedAmount.eq(0)
33
+ ? new bignumber_js_1.default(0)
34
+ : borrowedAmount.div(depositedAmount).times(100);
35
+ return {
36
+ id: event.id,
37
+ lendingMarketId: event.lendingMarketId,
38
+ coinType: (0, utils_1.normalizeStructTag)(event.coinType),
39
+ reserveId: event.reserveId,
40
+ availableAmount,
41
+ depositedAmount,
42
+ borrowedAmount,
43
+ availableAmountUsd,
44
+ depositedAmountUsd,
45
+ borrowedAmountUsd,
46
+ borrowAprPercent,
47
+ depositAprPercent,
48
+ ctokenSupply,
49
+ cumulativeBorrowRate,
50
+ price,
51
+ smoothedPrice,
52
+ minPrice,
53
+ maxPrice,
54
+ priceLastUpdateTimestampS: event.priceLastUpdateTimestampS,
55
+ timestampS: event.timestamp,
56
+ digest: event.digest,
57
+ eventIndex: event.eventIndex,
58
+ sender: event.sender,
59
+ utilizationPercent,
60
+ };
61
+ };
62
+ exports.parseReserveAssetDataEvent = parseReserveAssetDataEvent;
63
+ const parseDownsampledApiReserveAssetDataEvent = (event, reserve) => {
64
+ return Object.assign(Object.assign({}, (0, exports.parseReserveAssetDataEvent)(event, reserve)), { sampleTimestampS: event.sampletimestamp });
65
+ };
66
+ exports.parseDownsampledApiReserveAssetDataEvent = parseDownsampledApiReserveAssetDataEvent;
@@ -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
  }
@@ -51,9 +51,9 @@ const parseObligation = ({ Obligation }, obligation, parsedReserveMap) => {
51
51
  if (!reserve)
52
52
  throw new Error(`Reserve with coinType ${borrow.coinType.name} not found`);
53
53
  positionCount++;
54
- const cumulativeBorrowRate = new bignumber_js_1.default(borrow.cumulativeBorrowRate.value.toString()).div(constants_1.WAD.toString());
54
+ const cumulativeBorrowRate = new bignumber_js_1.default(borrow.cumulativeBorrowRate.value.toString()).div(constants_1.WAD);
55
55
  const borrowedAmountInitial = new bignumber_js_1.default(borrow.borrowedAmount.value.toString())
56
- .div(constants_1.WAD.toString())
56
+ .div(constants_1.WAD)
57
57
  .div(10 ** reserve.mintDecimals);
58
58
  const borrowInterestIndex = reserve.cumulativeBorrowRate.div(cumulativeBorrowRate);
59
59
  const borrowedAmount = borrowedAmountInitial.times(borrowInterestIndex);
@@ -77,7 +77,7 @@ const parseObligation = ({ Obligation }, obligation, parsedReserveMap) => {
77
77
  };
78
78
  });
79
79
  const netValueUsd = totalDepositedAmountUsd.minus(totalBorrowedAmountUsd);
80
- const weightedConservativeBorrowUtilizationPercent = minPriceBorrowLimitUsd.isZero()
80
+ const weightedConservativeBorrowUtilizationPercent = minPriceBorrowLimitUsd.eq(0)
81
81
  ? new bignumber_js_1.default(0)
82
82
  : maxPriceWeightedBorrowsUsd.div(minPriceBorrowLimitUsd).times(100);
83
83
  return {
@@ -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(10 ** 18);
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);
@@ -18,20 +18,20 @@ const parseReserve = ({ Reserve, PoolRewardManager, PoolReward, simulate, }, res
18
18
  const coinMetadata = coinMetadataMap[coinType];
19
19
  const mintDecimals = reserve.mintDecimals;
20
20
  const priceIdentifier = `0x${(0, utils_2.toHexString)(reserve.priceIdentifier.bytes)}`;
21
- const price = new bignumber_js_1.default(reserve.price.value.toString()).div(constants_1.WAD.toString());
22
- const smoothedPrice = new bignumber_js_1.default(reserve.smoothedPrice.value.toString()).div(constants_1.WAD.toString());
21
+ const price = new bignumber_js_1.default(reserve.price.value.toString()).div(constants_1.WAD);
22
+ const smoothedPrice = new bignumber_js_1.default(reserve.smoothedPrice.value.toString()).div(constants_1.WAD);
23
23
  const minPrice = bignumber_js_1.default.min(price, smoothedPrice);
24
24
  const maxPrice = bignumber_js_1.default.max(price, smoothedPrice);
25
25
  const priceLastUpdateTimestampS = reserve.priceLastUpdateTimestampS;
26
26
  const availableAmount = new bignumber_js_1.default(reserve.availableAmount.toString()).div(10 ** mintDecimals);
27
27
  const ctokenSupply = new bignumber_js_1.default(reserve.ctokenSupply.toString()).div(10 ** mintDecimals);
28
28
  const borrowedAmount = new bignumber_js_1.default(reserve.borrowedAmount.value.toString())
29
- .div(constants_1.WAD.toString())
29
+ .div(constants_1.WAD)
30
30
  .div(10 ** mintDecimals);
31
- const cumulativeBorrowRate = new bignumber_js_1.default(reserve.cumulativeBorrowRate.value.toString()).div(constants_1.WAD.toString());
31
+ const cumulativeBorrowRate = new bignumber_js_1.default(reserve.cumulativeBorrowRate.value.toString()).div(constants_1.WAD);
32
32
  const interestLastUpdateTimestampS = reserve.interestLastUpdateTimestampS;
33
33
  const unclaimedSpreadFees = new bignumber_js_1.default(reserve.unclaimedSpreadFees.value.toString())
34
- .div(constants_1.WAD.toString())
34
+ .div(constants_1.WAD)
35
35
  .div(10 ** mintDecimals);
36
36
  const attributedBorrowValue = new bignumber_js_1.default(reserve.attributedBorrowValue.value.toString());
37
37
  const depositsPoolRewardManager = (0, exports.parsePoolRewardManager)({ PoolRewardManager, PoolReward }, reserve.depositsPoolRewardManager, coinMetadataMap);
@@ -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.calculateBorrowApr(reserve);
48
- const depositAprPercent = simulate.calculateSupplyApr(reserve);
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;
@@ -176,10 +174,10 @@ const parsePoolReward = ({ PoolReward }, poolReward, rewardIndex, coinMetadataMa
176
174
  const endTimeMs = Number(poolReward.endTimeMs);
177
175
  const totalRewards = new bignumber_js_1.default(poolReward.totalRewards.toString()).div(10 ** coinMetadata.decimals);
178
176
  const allocatedRewards = new bignumber_js_1.default(poolReward.allocatedRewards.value.toString())
179
- .div(constants_1.WAD.toString())
177
+ .div(constants_1.WAD)
180
178
  .div(10 ** coinMetadata.decimals);
181
179
  const cumulativeRewardsPerShare = new bignumber_js_1.default(poolReward.cumulativeRewardsPerShare.value.toString())
182
- .div(constants_1.WAD.toString())
180
+ .div(constants_1.WAD)
183
181
  .div(10 ** coinMetadata.decimals);
184
182
  const numUserRewardManagers = poolReward.numUserRewardManagers;
185
183
  // additionalFields
package/core/types.d.ts CHANGED
@@ -672,3 +672,193 @@ 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
+ };
696
+ export type ApiReserveAssetDataEvent = {
697
+ id: number;
698
+ lendingMarketId: string;
699
+ coinType: string;
700
+ reserveId: string;
701
+ availableAmount: string;
702
+ supplyAmount: string;
703
+ borrowedAmount: string;
704
+ availableAmountUsdEstimate: string;
705
+ supplyAmountUsdEstimate: string;
706
+ borrowedAmountUsdEstimate: string;
707
+ borrowApr: string;
708
+ supplyApr: string;
709
+ ctokenSupply: string;
710
+ cumulativeBorrowRate: string;
711
+ price: string;
712
+ smoothedPrice: string;
713
+ priceLastUpdateTimestampS: number;
714
+ timestamp: number;
715
+ digest: string;
716
+ eventIndex: number;
717
+ sender: string;
718
+ };
719
+ export type DownsampledApiReserveAssetDataEvent = ApiReserveAssetDataEvent & {
720
+ sampletimestamp: number;
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
+ };
@@ -0,0 +1,176 @@
1
+ import { SuiClient, SuiEvent } from "@mysten/sui.js/client";
2
+ type TypeName = {
3
+ name: string;
4
+ };
5
+ type Decimal = {
6
+ value: string;
7
+ };
8
+ type address = string;
9
+ type u64 = string;
10
+ export declare enum SuilendEventType {
11
+ InterestUpdateEvent = "InterestUpdateEvent",
12
+ ReserveAssetDataEvent = "ReserveAssetDataEvent",
13
+ MintEvent = "MintEvent",
14
+ RedeemEvent = "RedeemEvent",
15
+ DepositEvent = "DepositEvent",
16
+ WithdrawEvent = "WithdrawEvent",
17
+ BorrowEvent = "BorrowEvent",
18
+ RepayEvent = "RepayEvent",
19
+ LiquidateEvent = "LiquidateEvent",
20
+ ClaimRewardEvent = "ClaimRewardEvent",
21
+ ObligationDataEvent = "ObligationDataEvent"
22
+ }
23
+ export declare enum SuilendTransactionModule {
24
+ LendingMarket = "lending_market",
25
+ Reserve = "reserve"
26
+ }
27
+ declare class TypedParamsSuiEvent<T> {
28
+ event: SuiEvent;
29
+ constructor(event: SuiEvent);
30
+ params(): T;
31
+ isType(module: SuilendTransactionModule, eventType: SuilendEventType): boolean;
32
+ }
33
+ export declare class GenericSuilendEvent extends TypedParamsSuiEvent<{}> {
34
+ }
35
+ export declare class InterestUpdateEvent extends TypedParamsSuiEvent<{
36
+ lending_market_id: address;
37
+ coin_type: TypeName;
38
+ reserve_id: address;
39
+ cumulative_borrow_rate: Decimal;
40
+ available_amount: u64;
41
+ borrowed_amount: Decimal;
42
+ unclaimed_spread_fees: Decimal;
43
+ ctoken_supply: u64;
44
+ borrow_interest_paid: Decimal;
45
+ spread_fee: Decimal;
46
+ supply_interest_earned: Decimal;
47
+ borrow_interest_paid_usd_estimate: Decimal;
48
+ protocol_fee_usd_estimate: Decimal;
49
+ supply_interest_earned_usd_estimate: Decimal;
50
+ }> {
51
+ }
52
+ export declare class ReserveAssetDataEvent extends TypedParamsSuiEvent<{
53
+ lending_market_id: address;
54
+ coin_type: TypeName;
55
+ reserve_id: address;
56
+ available_amount: Decimal;
57
+ supply_amount: Decimal;
58
+ borrowed_amount: Decimal;
59
+ available_amount_usd_estimate: Decimal;
60
+ supply_amount_usd_estimate: Decimal;
61
+ borrowed_amount_usd_estimate: Decimal;
62
+ borrow_apr: Decimal;
63
+ supply_apr: Decimal;
64
+ ctoken_supply: u64;
65
+ cumulative_borrow_rate: Decimal;
66
+ price: Decimal;
67
+ smoothed_price: Decimal;
68
+ price_last_update_timestamp_s: u64;
69
+ }> {
70
+ }
71
+ export declare class MintEvent extends TypedParamsSuiEvent<{
72
+ lending_market_id: address;
73
+ coin_type: TypeName;
74
+ reserve_id: address;
75
+ liquidity_amount: u64;
76
+ ctoken_amount: u64;
77
+ }> {
78
+ }
79
+ export declare class RedeemEvent extends TypedParamsSuiEvent<{
80
+ lending_market_id: address;
81
+ coin_type: TypeName;
82
+ reserve_id: address;
83
+ ctoken_amount: u64;
84
+ liquidity_amount: u64;
85
+ }> {
86
+ }
87
+ export declare class DepositEvent extends TypedParamsSuiEvent<{
88
+ lending_market_id: address;
89
+ coin_type: TypeName;
90
+ reserve_id: address;
91
+ obligation_id: address;
92
+ ctoken_amount: u64;
93
+ }> {
94
+ }
95
+ export declare class WithdrawEvent extends TypedParamsSuiEvent<{
96
+ lending_market_id: address;
97
+ coin_type: TypeName;
98
+ reserve_id: address;
99
+ obligation_id: address;
100
+ ctoken_amount: u64;
101
+ }> {
102
+ }
103
+ export declare class BorrowEvent extends TypedParamsSuiEvent<{
104
+ lending_market_id: address;
105
+ coin_type: TypeName;
106
+ reserve_id: address;
107
+ obligation_id: address;
108
+ liquidity_amount: u64;
109
+ origination_fee_amount: u64;
110
+ }> {
111
+ }
112
+ export declare class RepayEvent extends TypedParamsSuiEvent<{
113
+ lending_market_id: address;
114
+ coin_type: TypeName;
115
+ reserve_id: address;
116
+ obligation_id: address;
117
+ liquidity_amount: u64;
118
+ }> {
119
+ }
120
+ export declare class LiquidateEvent extends TypedParamsSuiEvent<{
121
+ lending_market_id: address;
122
+ repay_reserve_id: address;
123
+ withdraw_reserve_id: address;
124
+ obligation_id: address;
125
+ repay_coin_type: TypeName;
126
+ withdraw_coin_type: TypeName;
127
+ repay_amount: u64;
128
+ withdraw_amount: u64;
129
+ protocol_fee_amount: u64;
130
+ liquidator_bonus_amount: u64;
131
+ }> {
132
+ }
133
+ export declare class ClaimRewardEvent extends TypedParamsSuiEvent<{
134
+ lending_market_id: address;
135
+ reserve_id: address;
136
+ obligation_id: address;
137
+ is_deposit_reward: boolean;
138
+ pool_reward_id: address;
139
+ coin_type: TypeName;
140
+ liquidity_amount: u64;
141
+ }> {
142
+ }
143
+ export declare class ObligationDataEvent extends TypedParamsSuiEvent<{
144
+ lending_market_id: address;
145
+ obligation_id: address;
146
+ deposits: {
147
+ coin_type: TypeName;
148
+ reserve_array_index: u64;
149
+ deposited_ctoken_amount: u64;
150
+ market_value: Decimal;
151
+ user_reward_manager_index: u64;
152
+ attributed_borrow_value: Decimal;
153
+ }[];
154
+ borrows: {
155
+ coin_type: TypeName;
156
+ reserve_array_index: u64;
157
+ borrowed_amount: Decimal;
158
+ cumulative_borrow_rate: Decimal;
159
+ market_value: Decimal;
160
+ user_reward_manager_index: u64;
161
+ }[];
162
+ deposited_value_usd: Decimal;
163
+ allowed_borrow_value_usd: Decimal;
164
+ unhealthy_borrow_value_usd: Decimal;
165
+ super_unhealthy_borrow_value_usd: Decimal;
166
+ unweighted_borrowed_value_usd: Decimal;
167
+ weighted_borrowed_value_usd: Decimal;
168
+ weighted_borrowed_value_upper_bound_usd: Decimal;
169
+ borrowing_isolated_asset: boolean;
170
+ bad_debt_usd: Decimal;
171
+ closable: boolean;
172
+ }> {
173
+ }
174
+ export declare function getEvents(client: SuiClient, digest: string): Promise<GenericSuilendEvent[]>;
175
+ export declare function getRedeemEvent(client: SuiClient, digest: string): Promise<RedeemEvent | null>;
176
+ export {};