@suilend/sdk 1.1.99 → 2.0.1

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.
Files changed (91) hide show
  1. package/_generated/_dependencies/source/0x1/ascii/structs.d.ts +7 -7
  2. package/_generated/_dependencies/source/0x1/ascii/structs.js +35 -75
  3. package/_generated/_dependencies/source/0x1/index.js +3 -6
  4. package/_generated/_dependencies/source/0x1/option/structs.d.ts +3 -3
  5. package/_generated/_dependencies/source/0x1/option/structs.js +31 -69
  6. package/_generated/_dependencies/source/0x1/type-name/structs.d.ts +5 -5
  7. package/_generated/_dependencies/source/0x1/type-name/structs.js +20 -25
  8. package/_generated/_dependencies/source/0x2/bag/structs.d.ts +7 -7
  9. package/_generated/_dependencies/source/0x2/bag/structs.js +24 -29
  10. package/_generated/_dependencies/source/0x2/balance/structs.d.ts +7 -7
  11. package/_generated/_dependencies/source/0x2/balance/structs.js +49 -56
  12. package/_generated/_dependencies/source/0x2/index.js +3 -6
  13. package/_generated/_dependencies/source/0x2/object/structs.d.ts +8 -8
  14. package/_generated/_dependencies/source/0x2/object/structs.js +34 -41
  15. package/_generated/_dependencies/source/0x2/object-table/structs.d.ts +7 -7
  16. package/_generated/_dependencies/source/0x2/object-table/structs.js +31 -36
  17. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.d.ts +5 -5
  18. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.js +23 -28
  19. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/index.js +4 -7
  20. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.d.ts +11 -11
  21. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.js +32 -37
  22. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.d.ts +23 -23
  23. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.js +29 -34
  24. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.d.ts +4 -4
  25. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js +21 -59
  26. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.d.ts +55 -55
  27. package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.js +46 -53
  28. package/_generated/_framework/reified.d.ts +2 -2
  29. package/_generated/_framework/reified.js +27 -40
  30. package/_generated/_framework/util.js +26 -40
  31. package/_generated/_framework/vector.d.ts +4 -4
  32. package/_generated/_framework/vector.js +16 -21
  33. package/_generated/suilend/cell/structs.d.ts +4 -4
  34. package/_generated/suilend/cell/structs.js +31 -36
  35. package/_generated/suilend/decimal/structs.d.ts +4 -4
  36. package/_generated/suilend/decimal/structs.js +19 -24
  37. package/_generated/suilend/index.js +8 -12
  38. package/_generated/suilend/lending-market/functions.d.ts +1 -0
  39. package/_generated/suilend/lending-market/functions.js +271 -302
  40. package/_generated/suilend/lending-market/structs.d.ts +146 -146
  41. package/_generated/suilend/lending-market/structs.js +549 -617
  42. package/_generated/suilend/lending-market-registry/functions.js +7 -11
  43. package/_generated/suilend/liquidity-mining/structs.d.ts +50 -50
  44. package/_generated/suilend/liquidity-mining/structs.js +159 -205
  45. package/_generated/suilend/obligation/structs.d.ts +106 -106
  46. package/_generated/suilend/obligation/structs.js +313 -363
  47. package/_generated/suilend/rate-limiter/functions.js +23 -31
  48. package/_generated/suilend/rate-limiter/structs.d.ts +15 -15
  49. package/_generated/suilend/rate-limiter/structs.js +49 -56
  50. package/_generated/suilend/reserve/structs.d.ts +139 -139
  51. package/_generated/suilend/reserve/structs.js +397 -451
  52. package/_generated/suilend/reserve-config/functions.js +149 -190
  53. package/_generated/suilend/reserve-config/structs.d.ts +33 -33
  54. package/_generated/suilend/reserve-config/structs.js +109 -149
  55. package/api/events.js +1 -5
  56. package/api/index.js +1 -17
  57. package/client.d.ts +10 -10
  58. package/client.js +118 -128
  59. package/index.js +7 -23
  60. package/lib/constants.js +3 -9
  61. package/lib/index.js +5 -21
  62. package/lib/initialize.d.ts +3 -3
  63. package/lib/initialize.js +103 -140
  64. package/lib/liquidityMining.d.ts +3 -3
  65. package/lib/liquidityMining.js +57 -72
  66. package/lib/pyth.js +9 -14
  67. package/lib/strategyOwnerCap.js +106 -119
  68. package/lib/transactions.js +2 -7
  69. package/lib/types.js +4 -7
  70. package/mmt.js +2 -5
  71. package/package.json +1 -1
  72. package/parsers/apiReserveAssetDataEvent.js +25 -33
  73. package/parsers/index.js +5 -21
  74. package/parsers/lendingMarket.d.ts +1 -1
  75. package/parsers/lendingMarket.js +12 -19
  76. package/parsers/obligation.js +19 -26
  77. package/parsers/rateLimiter.js +11 -19
  78. package/parsers/reserve.d.ts +1 -1
  79. package/parsers/reserve.js +42 -85
  80. package/strategies.d.ts +11 -11
  81. package/strategies.js +547 -586
  82. package/swap/index.js +2 -18
  83. package/swap/quote.js +57 -65
  84. package/swap/transaction.d.ts +2 -2
  85. package/swap/transaction.js +40 -35
  86. package/utils/events.d.ts +3 -3
  87. package/utils/events.js +18 -35
  88. package/utils/index.js +16 -40
  89. package/utils/obligation.d.ts +4 -4
  90. package/utils/obligation.js +17 -60
  91. package/utils/simulate.js +118 -143
package/client.js CHANGED
@@ -1,4 +1,3 @@
1
- "use strict";
2
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,39 +7,36 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
8
  });
10
9
  };
11
- var _a, _b;
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- exports.SuilendClient = exports.STEAMM_LM_LENDING_MARKET_TYPE = exports.STEAMM_LM_LENDING_MARKET_ID = exports.LENDING_MARKET_TYPE = exports.LENDING_MARKET_ID = exports.LENDING_MARKET_REGISTRY_ID = exports.ADMIN_ADDRESS = void 0;
14
- const utils_1 = require("@mysten/sui/utils");
15
- const pyth_sui_js_1 = require("@pythnetwork/pyth-sui-js");
16
- const sui_fe_1 = require("@suilend/sui-fe");
17
- const structs_1 = require("./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs");
18
- const reified_1 = require("./_generated/_framework/reified");
19
- const suilend_1 = require("./_generated/suilend");
20
- const suilend_2 = require("./_generated/suilend");
21
- const functions_1 = require("./_generated/suilend/lending-market/functions");
22
- const structs_2 = require("./_generated/suilend/lending-market/structs");
23
- const functions_2 = require("./_generated/suilend/lending-market-registry/functions");
24
- const structs_3 = require("./_generated/suilend/obligation/structs");
25
- const functions_3 = require("./_generated/suilend/rate-limiter/functions");
26
- const functions_4 = require("./_generated/suilend/reserve-config/functions");
27
- const pyth_1 = require("./lib/pyth");
28
- const types_1 = require("./lib/types");
10
+ import { SUI_CLOCK_OBJECT_ID, SUI_SYSTEM_STATE_OBJECT_ID, fromBase64, normalizeStructTag, toHex, } from "@mysten/sui/utils";
11
+ import { SuiPriceServiceConnection, SuiPythClient, } from "@pythnetwork/pyth-sui-js";
12
+ import { extractCTokenCoinType, getAllCoins, mergeAllCoins, } from "@suilend/sui-fe";
13
+ import { PriceInfoObject } from "./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs";
14
+ import { phantom } from "./_generated/_framework/reified";
15
+ import { PKG_V10, setPublishedAt } from "./_generated/suilend";
16
+ import { PACKAGE_ID, PUBLISHED_AT } from "./_generated/suilend";
17
+ import { addPoolReward, addReserve, addReserveV2, borrowRequest, cancelPoolReward, changeReservePriceFeed, claimFees, claimRewards, claimRewardsAndDeposit, closePoolReward, depositCtokensIntoObligation, depositLiquidityAndMintCtokens, fulfillLiquidityRequest, liquidate, migrate, newObligationOwnerCap, rebalanceStaker, redeemCtokensAndWithdrawLiquidityRequest, refreshReservePrice, repay, setFeeReceivers, unstakeSuiFromStaker, updateRateLimiterConfig, updateReserveConfig, withdrawCtokens, } from "./_generated/suilend/lending-market/functions";
18
+ import { LendingMarket, ObligationOwnerCap, } from "./_generated/suilend/lending-market/structs";
19
+ import { createLendingMarket } from "./_generated/suilend/lending-market-registry/functions";
20
+ import { Obligation } from "./_generated/suilend/obligation/structs";
21
+ import { newConfig as createRateLimiterConfig, } from "./_generated/suilend/rate-limiter/functions";
22
+ import { createReserveConfig, } from "./_generated/suilend/reserve-config/functions";
23
+ import { PRIMARY_PYTH_ENDPOINT } from "./lib/pyth";
24
+ import { Side } from "./lib/types";
29
25
  const SUI_COINTYPE = "0x2::sui::SUI";
30
- const NORMALIZED_SUI_COINTYPE = (0, utils_1.normalizeStructTag)(SUI_COINTYPE);
31
- const isSui = (coinType) => (0, utils_1.normalizeStructTag)(coinType) === NORMALIZED_SUI_COINTYPE;
26
+ const NORMALIZED_SUI_COINTYPE = normalizeStructTag(SUI_COINTYPE);
27
+ const isSui = (coinType) => normalizeStructTag(coinType) === NORMALIZED_SUI_COINTYPE;
32
28
  const WORMHOLE_STATE_ID = "0xaeab97f96cf9877fee2883315d459552b2b921edc16d7ceac6eab944dd88919c";
33
29
  const PYTH_STATE_ID = "0x1f9310238ee9298fb703c3419030b35b22bb1cc37113e3bb5007c99aec79e5b8";
34
- exports.ADMIN_ADDRESS = process.env.NEXT_PUBLIC_SUILEND_USE_BETA_MARKET === "true"
30
+ export const ADMIN_ADDRESS = process.env.NEXT_PUBLIC_SUILEND_USE_BETA_MARKET === "true"
35
31
  ? "0xa902504c338e17f44dfee1bd1c3cad1ff03326579b9cdcfe2762fc12c46fc033" // beta owner
36
32
  : "0xb1ffbc2e1915f44b8f271a703becc1bf8aa79bc22431a58900a102892b783c25";
37
33
  const SUILEND_UPGRADE_CAP_ID = process.env.NEXT_PUBLIC_SUILEND_USE_BETA_MARKET === "true"
38
34
  ? "0x05da14368a42a351e106806c09727968ae26be77a6741a018239ef0f99d5185e"
39
35
  : "0x3d4ef1859c3ee9fc72858f588b56a09da5466e64f8cc4e90a7b3b909fba8a7ae";
40
- exports.LENDING_MARKET_REGISTRY_ID = process.env.NEXT_PUBLIC_SUILEND_USE_BETA_MARKET === "true"
36
+ export const LENDING_MARKET_REGISTRY_ID = process.env.NEXT_PUBLIC_SUILEND_USE_BETA_MARKET === "true"
41
37
  ? "0x925c9a2336b02fc2b68099837bd66f6b5b4d45cd460e0a4b81708bac6c440eff"
42
38
  : "0x64faff8d91a56c4f55debbb44767b009ee744a70bc2cc8e3bbd2718c92f85931";
43
- _a = process.env.NEXT_PUBLIC_SUILEND_USE_BETA_MARKET === "true"
39
+ export const [LENDING_MARKET_ID, LENDING_MARKET_TYPE] = process.env.NEXT_PUBLIC_SUILEND_USE_BETA_MARKET === "true"
44
40
  ? [
45
41
  "0x12e46de3eafaf0308a2dd64f1158782ed19e6621835bf883a1dd6b3061115667",
46
42
  "0x83556891f4a0f233ce7b05cfe7f957d4020492a34f5405b2cb9377d060bef4bf::spring_sui::SPRING_SUI",
@@ -48,8 +44,8 @@ _a = process.env.NEXT_PUBLIC_SUILEND_USE_BETA_MARKET === "true"
48
44
  : [
49
45
  "0x84030d26d85eaa7035084a057f2f11f701b7e2e4eda87551becbc7c97505ece1",
50
46
  "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf::suilend::MAIN_POOL",
51
- ], exports.LENDING_MARKET_ID = _a[0], exports.LENDING_MARKET_TYPE = _a[1];
52
- _b = process.env.NEXT_PUBLIC_SUILEND_USE_BETA_MARKET === "true"
47
+ ];
48
+ export const [STEAMM_LM_LENDING_MARKET_ID, STEAMM_LM_LENDING_MARKET_TYPE] = process.env.NEXT_PUBLIC_SUILEND_USE_BETA_MARKET === "true"
53
49
  ? [
54
50
  "0xb1d89cf9082cedce09d3647f0ebda4a8b5db125aff5d312a8bfd7eefa715bd35",
55
51
  "0xdeeb7a4662eec9f2f3def03fb937a663dddaa2e215b8078a284d026b7946c270::deep::DEEP",
@@ -57,7 +53,7 @@ _b = process.env.NEXT_PUBLIC_SUILEND_USE_BETA_MARKET === "true"
57
53
  : [
58
54
  "0xc1888ec1b81a414e427a44829310508352aec38252ee0daa9f8b181b6947de9f",
59
55
  "0x0a071f4976abae1a7f722199cf0bfcbe695ef9408a878e7d12a7ca87b7e582a6::lp_rewards::LP_REWARDS",
60
- ], exports.STEAMM_LM_LENDING_MARKET_ID = _b[0], exports.STEAMM_LM_LENDING_MARKET_TYPE = _b[1];
56
+ ];
61
57
  function getLatestPackageId(client, upgradeCapId) {
62
58
  return __awaiter(this, void 0, void 0, function* () {
63
59
  var _a;
@@ -70,23 +66,23 @@ function getLatestPackageId(client, upgradeCapId) {
70
66
  return ((_a = object.data) === null || _a === void 0 ? void 0 : _a.content).fields.package;
71
67
  });
72
68
  }
73
- class SuilendClient {
69
+ export class SuilendClient {
74
70
  constructor(lendingMarket, client) {
75
71
  this.lendingMarket = lendingMarket;
76
72
  this.client = client;
77
- this.pythClient = new pyth_sui_js_1.SuiPythClient(client, PYTH_STATE_ID, WORMHOLE_STATE_ID);
78
- const pythEndpoint = pyth_1.PRIMARY_PYTH_ENDPOINT; // TODO: Use getWorkingPythEndpoint
79
- this.pythConnection = new pyth_sui_js_1.SuiPriceServiceConnection(pythEndpoint, {
73
+ this.pythClient = new SuiPythClient(client, PYTH_STATE_ID, WORMHOLE_STATE_ID);
74
+ const pythEndpoint = PRIMARY_PYTH_ENDPOINT; // TODO: Use getWorkingPythEndpoint
75
+ this.pythConnection = new SuiPriceServiceConnection(pythEndpoint, {
80
76
  timeout: 30 * 1000,
81
77
  });
82
78
  }
83
79
  static initialize(lendingMarketId, lendingMarketType, client, logPackageId) {
84
80
  return __awaiter(this, void 0, void 0, function* () {
85
- const lendingMarket = yield structs_2.LendingMarket.fetch(client, (0, reified_1.phantom)(lendingMarketType), lendingMarketId);
81
+ const lendingMarket = yield LendingMarket.fetch(client, phantom(lendingMarketType), lendingMarketId);
86
82
  const publishedAt = yield getLatestPackageId(client, SUILEND_UPGRADE_CAP_ID);
87
83
  if (logPackageId)
88
84
  console.log("@suilend/sdk | publishedAt:", publishedAt);
89
- (0, suilend_1.setPublishedAt)(publishedAt);
85
+ setPublishedAt(publishedAt);
90
86
  return new SuilendClient(lendingMarket, client);
91
87
  });
92
88
  }
@@ -96,7 +92,7 @@ class SuilendClient {
96
92
  const feeReceiver = yield client.getDynamicFieldObject({
97
93
  parentId: lendingMarketId,
98
94
  name: {
99
- type: `${suilend_1.PKG_V10}::lending_market::FeeReceiversKey`,
95
+ type: `${PKG_V10}::lending_market::FeeReceiversKey`,
100
96
  value: {
101
97
  dummy_field: false,
102
98
  },
@@ -110,10 +106,10 @@ class SuilendClient {
110
106
  });
111
107
  }
112
108
  static createNewLendingMarket(registryId, lendingMarketType, transaction) {
113
- const [ownerCap, lendingMarket] = (0, functions_2.createLendingMarket)(transaction, lendingMarketType, transaction.object(registryId));
109
+ const [ownerCap, lendingMarket] = createLendingMarket(transaction, lendingMarketType, transaction.object(registryId));
114
110
  transaction.moveCall({
115
111
  target: `0x2::transfer::public_share_object`,
116
- typeArguments: [`${structs_2.LendingMarket.$typeName}<${lendingMarketType}>}`],
112
+ typeArguments: [`${LendingMarket.$typeName}<${lendingMarketType}>}`],
117
113
  arguments: [lendingMarket],
118
114
  });
119
115
  return ownerCap;
@@ -128,7 +124,7 @@ class SuilendClient {
128
124
  owner: ownerId,
129
125
  cursor,
130
126
  filter: {
131
- StructType: `${suilend_2.PACKAGE_ID}::lending_market::ObligationOwnerCap<${lendingMarketTypeArgs[0]}>`,
127
+ StructType: `${PACKAGE_ID}::lending_market::ObligationOwnerCap<${lendingMarketTypeArgs[0]}>`,
132
128
  },
133
129
  });
134
130
  allObjs.push(...objs.data);
@@ -148,7 +144,7 @@ class SuilendClient {
148
144
  var _a, _b, _c, _d;
149
145
  if (((_b = (_a = obj.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject")
150
146
  throw new Error("Error: invalid data type");
151
- obligationOwnerCaps.push(structs_2.ObligationOwnerCap.fromBcs((0, reified_1.phantom)(lendingMarketTypeArgs[0]), (0, utils_1.fromB64)((_d = (_c = obj.data) === null || _c === void 0 ? void 0 : _c.bcs) === null || _d === void 0 ? void 0 : _d.bcsBytes)));
147
+ obligationOwnerCaps.push(ObligationOwnerCap.fromBcs(phantom(lendingMarketTypeArgs[0]), fromBase64((_d = (_c = obj.data) === null || _c === void 0 ? void 0 : _c.bcs) === null || _d === void 0 ? void 0 : _d.bcsBytes)));
152
148
  });
153
149
  return obligationOwnerCaps;
154
150
  }
@@ -167,7 +163,7 @@ class SuilendClient {
167
163
  if (((_b = (_a = obligationData.data) === null || _a === void 0 ? void 0 : _a.bcs) === null || _b === void 0 ? void 0 : _b.dataType) !== "moveObject") {
168
164
  throw new Error("Error: invalid data type");
169
165
  }
170
- const obligation = structs_3.Obligation.fromBcs((0, reified_1.phantom)(lendingMarketTypeArgs[0]), (0, utils_1.fromB64)(obligationData.data.bcs.bcsBytes));
166
+ const obligation = Obligation.fromBcs(phantom(lendingMarketTypeArgs[0]), fromBase64(obligationData.data.bcs.bcsBytes));
171
167
  return obligation;
172
168
  });
173
169
  }
@@ -182,7 +178,7 @@ class SuilendClient {
182
178
  const objs = yield client.getOwnedObjects({
183
179
  owner: ownerId,
184
180
  filter: {
185
- StructType: `${suilend_2.PACKAGE_ID}::lending_market::LendingMarketOwnerCap<${lendingMarketTypeArgs[0]}>`,
181
+ StructType: `${PACKAGE_ID}::lending_market::LendingMarketOwnerCap<${lendingMarketTypeArgs[0]}>`,
186
182
  },
187
183
  });
188
184
  if (objs.data.length > 0)
@@ -196,35 +192,30 @@ class SuilendClient {
196
192
  return SuilendClient.getLendingMarketOwnerCapId(ownerId, this.lendingMarket.$typeArgs, this.client);
197
193
  });
198
194
  }
199
- createReserve(lendingMarketOwnerCapId, transaction, pythPriceId, coinType, createReserveConfigArgs, coinMetadataIdOverride) {
195
+ createReserve(lendingMarketOwnerCapId, transaction, pythPriceId, coinType, createReserveConfigArgs, useV2) {
200
196
  return __awaiter(this, void 0, void 0, function* () {
201
- const [config] = (0, functions_4.createReserveConfig)(transaction, createReserveConfigArgs);
197
+ const [config] = createReserveConfig(transaction, createReserveConfigArgs);
202
198
  // Assumes the pyth price feed exists
203
199
  const priceUpdateData = yield this.pythConnection.getPriceFeedsUpdateData([
204
200
  pythPriceId,
205
201
  ]);
206
202
  const priceInfoObjectIds = yield this.pythClient.updatePriceFeeds(transaction, priceUpdateData, [pythPriceId]);
207
- let coinMetadataId;
208
- if (coinMetadataIdOverride !== undefined)
209
- coinMetadataId = coinMetadataIdOverride;
210
- else {
211
- const coinMetadata = yield this.client.getCoinMetadata({
212
- coinType: coinType,
213
- });
214
- console.log("[createReserve] coinMetadata", coinMetadata);
215
- if (!coinMetadata)
216
- throw new Error("Error: CoinMetadata not found");
217
- if (!coinMetadata.id)
218
- throw new Error("Error: CoinMetadata.id not found");
219
- coinMetadataId = coinMetadata.id;
220
- }
221
- return (0, functions_1.addReserve)(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
203
+ const coinMetadata = yield this.client.getCoinMetadata({
204
+ coinType: coinType,
205
+ });
206
+ console.log("[createReserve] coinMetadata", coinMetadata);
207
+ if (!coinMetadata)
208
+ throw new Error("Error: CoinMetadata not found");
209
+ if (!coinMetadata.id)
210
+ throw new Error("Error: CoinMetadata.id not found");
211
+ const addReserveFn = useV2 ? addReserveV2 : addReserve;
212
+ return addReserveFn(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
222
213
  lendingMarketOwnerCap: transaction.object(lendingMarketOwnerCapId),
223
214
  lendingMarket: transaction.object(this.lendingMarket.id),
224
215
  priceInfo: transaction.object(priceInfoObjectIds[0]),
225
216
  config: transaction.object(config),
226
- coinMetadata: transaction.object(coinMetadataId),
227
- clock: transaction.object(utils_1.SUI_CLOCK_OBJECT_ID),
217
+ coinMetadata: transaction.object(coinMetadata.id),
218
+ clock: transaction.object(SUI_CLOCK_OBJECT_ID),
228
219
  });
229
220
  });
230
221
  }
@@ -240,7 +231,7 @@ class SuilendClient {
240
231
  const [rewardCoin] = transaction.splitCoins(isSui(rewardCoinType)
241
232
  ? transaction.gas
242
233
  : transaction.object(coins[0].coinObjectId), [rewardValue]);
243
- return (0, functions_1.addPoolReward)(transaction, [this.lendingMarket.$typeArgs[0], rewardCoinType], {
234
+ return addPoolReward(transaction, [this.lendingMarket.$typeArgs[0], rewardCoinType], {
244
235
  lendingMarketOwnerCap: transaction.object(lendingMarketOwnerCapId),
245
236
  lendingMarket: transaction.object(this.lendingMarket.id),
246
237
  reserveArrayIndex: transaction.pure.u64(reserveArrayIndex),
@@ -248,48 +239,48 @@ class SuilendClient {
248
239
  rewards: transaction.object(rewardCoin),
249
240
  startTimeMs: transaction.pure.u64(startTimeMs),
250
241
  endTimeMs: transaction.pure.u64(endTimeMs),
251
- clock: transaction.object(utils_1.SUI_CLOCK_OBJECT_ID),
242
+ clock: transaction.object(SUI_CLOCK_OBJECT_ID),
252
243
  });
253
244
  });
254
245
  }
255
246
  cancelReward(lendingMarketOwnerCapId, reserveArrayIndex, isDepositReward, rewardIndex, rewardCoinType, transaction) {
256
- return (0, functions_1.cancelPoolReward)(transaction, [this.lendingMarket.$typeArgs[0], rewardCoinType], {
247
+ return cancelPoolReward(transaction, [this.lendingMarket.$typeArgs[0], rewardCoinType], {
257
248
  lendingMarketOwnerCap: transaction.object(lendingMarketOwnerCapId),
258
249
  lendingMarket: transaction.object(this.lendingMarket.id),
259
250
  reserveArrayIndex: transaction.pure.u64(reserveArrayIndex),
260
251
  isDepositReward: transaction.pure.bool(isDepositReward),
261
252
  rewardIndex: transaction.pure.u64(rewardIndex),
262
- clock: transaction.object(utils_1.SUI_CLOCK_OBJECT_ID),
253
+ clock: transaction.object(SUI_CLOCK_OBJECT_ID),
263
254
  });
264
255
  }
265
256
  closeReward(lendingMarketOwnerCapId, reserveArrayIndex, isDepositReward, rewardIndex, rewardCoinType, transaction) {
266
- return (0, functions_1.closePoolReward)(transaction, [this.lendingMarket.$typeArgs[0], rewardCoinType], {
257
+ return closePoolReward(transaction, [this.lendingMarket.$typeArgs[0], rewardCoinType], {
267
258
  lendingMarketOwnerCap: transaction.object(lendingMarketOwnerCapId),
268
259
  lendingMarket: transaction.object(this.lendingMarket.id),
269
260
  reserveArrayIndex: transaction.pure.u64(reserveArrayIndex),
270
261
  isDepositReward: transaction.pure.bool(isDepositReward),
271
262
  rewardIndex: transaction.pure.u64(rewardIndex),
272
- clock: transaction.object(utils_1.SUI_CLOCK_OBJECT_ID),
263
+ clock: transaction.object(SUI_CLOCK_OBJECT_ID),
273
264
  });
274
265
  }
275
266
  claimReward(obligationOwnerCap, reserveArrayIndex, rewardIndex, rewardType, side, transaction) {
276
- return (0, functions_1.claimRewards)(transaction, [this.lendingMarket.$typeArgs[0], rewardType], {
267
+ return claimRewards(transaction, [this.lendingMarket.$typeArgs[0], rewardType], {
277
268
  lendingMarket: transaction.object(this.lendingMarket.id),
278
269
  cap: transaction.object(obligationOwnerCap),
279
- clock: transaction.object(utils_1.SUI_CLOCK_OBJECT_ID),
270
+ clock: transaction.object(SUI_CLOCK_OBJECT_ID),
280
271
  reserveId: transaction.pure.u64(reserveArrayIndex),
281
272
  rewardIndex: transaction.pure.u64(rewardIndex),
282
- isDepositReward: transaction.pure.bool(side === types_1.Side.DEPOSIT),
273
+ isDepositReward: transaction.pure.bool(side === Side.DEPOSIT),
283
274
  });
284
275
  }
285
276
  claimRewardAndDeposit(obligationId, rewardReserveArrayIndex, rewardIndex, rewardCoinType, side, depositReserveArrayIndex, transaction) {
286
- return (0, functions_1.claimRewardsAndDeposit)(transaction, [this.lendingMarket.$typeArgs[0], rewardCoinType], {
277
+ return claimRewardsAndDeposit(transaction, [this.lendingMarket.$typeArgs[0], rewardCoinType], {
287
278
  lendingMarket: transaction.object(this.lendingMarket.id),
288
279
  obligationId: transaction.pure.id(obligationId),
289
- clock: transaction.object(utils_1.SUI_CLOCK_OBJECT_ID),
280
+ clock: transaction.object(SUI_CLOCK_OBJECT_ID),
290
281
  rewardReserveId: transaction.pure.u64(rewardReserveArrayIndex),
291
282
  rewardIndex: transaction.pure.u64(rewardIndex),
292
- isDepositReward: transaction.pure.bool(side === types_1.Side.DEPOSIT),
283
+ isDepositReward: transaction.pure.bool(side === Side.DEPOSIT),
293
284
  depositReserveId: transaction.pure.u64(depositReserveArrayIndex),
294
285
  });
295
286
  }
@@ -325,12 +316,12 @@ class SuilendClient {
325
316
  return transaction_;
326
317
  }
327
318
  findReserveArrayIndex(coinType) {
328
- const arrayIndex = this.lendingMarket.reserves.findIndex((r) => (0, utils_1.normalizeStructTag)(r.coinType.name) === (0, utils_1.normalizeStructTag)(coinType));
319
+ const arrayIndex = this.lendingMarket.reserves.findIndex((r) => normalizeStructTag(r.coinType.name) === normalizeStructTag(coinType));
329
320
  return BigInt(arrayIndex);
330
321
  }
331
322
  updateReserveConfig(lendingMarketOwnerCapId, transaction, coinType, createReserveConfigArgs) {
332
- const [config] = (0, functions_4.createReserveConfig)(transaction, createReserveConfigArgs);
333
- return (0, functions_1.updateReserveConfig)(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
323
+ const [config] = createReserveConfig(transaction, createReserveConfigArgs);
324
+ return updateReserveConfig(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
334
325
  lendingMarketOwnerCap: transaction.object(lendingMarketOwnerCapId),
335
326
  lendingMarket: transaction.object(this.lendingMarket.id),
336
327
  reserveArrayIndex: transaction.pure.u64(this.findReserveArrayIndex(coinType)),
@@ -338,7 +329,7 @@ class SuilendClient {
338
329
  });
339
330
  }
340
331
  newObligationOwnerCap(transaction, lendingMarketOwnerCapId, destinationAddress, obligationId) {
341
- const [obligationOwnerCap] = (0, functions_1.newObligationOwnerCap)(transaction, this.lendingMarket.$typeArgs[0], {
332
+ const [obligationOwnerCap] = newObligationOwnerCap(transaction, this.lendingMarket.$typeArgs[0], {
342
333
  lendingMarketOwnerCap: transaction.object(lendingMarketOwnerCapId),
343
334
  lendingMarket: transaction.object(this.lendingMarket.id),
344
335
  obligationId: transaction.pure.id(obligationId),
@@ -346,11 +337,11 @@ class SuilendClient {
346
337
  transaction.transferObjects([obligationOwnerCap], transaction.pure.address(destinationAddress));
347
338
  }
348
339
  updateRateLimiterConfig(lendingMarketOwnerCapId, transaction, newRateLimiterConfigArgs) {
349
- const [config] = (0, functions_3.newConfig)(transaction, newRateLimiterConfigArgs);
350
- return (0, functions_1.updateRateLimiterConfig)(transaction, this.lendingMarket.$typeArgs[0], {
340
+ const [config] = createRateLimiterConfig(transaction, newRateLimiterConfigArgs);
341
+ return updateRateLimiterConfig(transaction, this.lendingMarket.$typeArgs[0], {
351
342
  lendingMarketOwnerCap: transaction.object(lendingMarketOwnerCapId),
352
343
  lendingMarket: transaction.object(this.lendingMarket.id),
353
- clock: transaction.object(utils_1.SUI_CLOCK_OBJECT_ID),
344
+ clock: transaction.object(SUI_CLOCK_OBJECT_ID),
354
345
  config: transaction.object(config),
355
346
  });
356
347
  }
@@ -360,18 +351,18 @@ class SuilendClient {
360
351
  pythPriceId,
361
352
  ]);
362
353
  const priceInfoObjectIds = yield this.pythClient.updatePriceFeeds(transaction, priceUpdateData, [pythPriceId]);
363
- return (0, functions_1.changeReservePriceFeed)(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
354
+ return changeReservePriceFeed(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
364
355
  lendingMarketOwnerCap: transaction.object(lendingMarketOwnerCapId),
365
356
  lendingMarket: transaction.object(this.lendingMarket.id),
366
357
  reserveArrayIndex: transaction.pure.u64(this.findReserveArrayIndex(coinType)),
367
358
  priceInfoObj: transaction.object(priceInfoObjectIds[0]),
368
- clock: transaction.object(utils_1.SUI_CLOCK_OBJECT_ID),
359
+ clock: transaction.object(SUI_CLOCK_OBJECT_ID),
369
360
  });
370
361
  });
371
362
  }
372
363
  createObligation(transaction) {
373
364
  return transaction.moveCall({
374
- target: `${suilend_2.PUBLISHED_AT}::lending_market::create_obligation`,
365
+ target: `${PUBLISHED_AT}::lending_market::create_obligation`,
375
366
  arguments: [transaction.object(this.lendingMarket.id)],
376
367
  typeArguments: this.lendingMarket.$typeArgs,
377
368
  });
@@ -382,11 +373,11 @@ class SuilendClient {
382
373
  if (obligation) {
383
374
  obligation.deposits.forEach((deposit) => {
384
375
  const reserve = this.lendingMarket.reserves[Number(deposit.reserveArrayIndex)];
385
- reserveArrayIndexToPriceId.set(deposit.reserveArrayIndex, (0, utils_1.toHEX)(new Uint8Array(reserve.priceIdentifier.bytes)));
376
+ reserveArrayIndexToPriceId.set(deposit.reserveArrayIndex, toHex(new Uint8Array(reserve.priceIdentifier.bytes)));
386
377
  });
387
378
  obligation.borrows.forEach((borrow) => {
388
379
  const reserve = this.lendingMarket.reserves[Number(borrow.reserveArrayIndex)];
389
- reserveArrayIndexToPriceId.set(borrow.reserveArrayIndex, (0, utils_1.toHEX)(new Uint8Array(reserve.priceIdentifier.bytes)));
380
+ reserveArrayIndexToPriceId.set(borrow.reserveArrayIndex, toHex(new Uint8Array(reserve.priceIdentifier.bytes)));
390
381
  });
391
382
  }
392
383
  if (coinTypes !== undefined) {
@@ -395,7 +386,7 @@ class SuilendClient {
395
386
  if (reserveArrayIndex >= 0 &&
396
387
  reserveArrayIndex < BigInt(this.lendingMarket.reserves.length)) {
397
388
  const reserve = this.lendingMarket.reserves[Number(reserveArrayIndex)];
398
- reserveArrayIndexToPriceId.set(reserveArrayIndex, (0, utils_1.toHEX)(new Uint8Array(reserve.priceIdentifier.bytes)));
389
+ reserveArrayIndexToPriceId.set(reserveArrayIndex, toHex(new Uint8Array(reserve.priceIdentifier.bytes)));
399
390
  }
400
391
  }
401
392
  }
@@ -409,7 +400,7 @@ class SuilendClient {
409
400
  }))()));
410
401
  const stalePriceIdentifiers = [];
411
402
  yield Promise.all(Object.entries(priceInfoObjectIds).map(([i, priceInfoObjectId]) => (() => __awaiter(this, void 0, void 0, function* () {
412
- const priceInfoObject = yield structs_1.PriceInfoObject.fetch(this.client, priceInfoObjectId);
403
+ const priceInfoObject = yield PriceInfoObject.fetch(this.client, priceInfoObjectId);
413
404
  const publishTime = priceInfoObject.priceInfo.priceFeed.price.timestamp;
414
405
  const stalenessSeconds = Date.now() / 1000 - Number(publishTime);
415
406
  if (stalenessSeconds > 20) {
@@ -431,40 +422,40 @@ class SuilendClient {
431
422
  if (priceInfoObjectId == null) {
432
423
  return;
433
424
  }
434
- (0, functions_1.refreshReservePrice)(transaction, this.lendingMarket.$typeArgs[0], {
425
+ refreshReservePrice(transaction, this.lendingMarket.$typeArgs[0], {
435
426
  lendingMarket: transaction.object(this.lendingMarket.id),
436
427
  reserveArrayIndex: transaction.pure.u64(reserveArrayIndex),
437
- clock: transaction.object(utils_1.SUI_CLOCK_OBJECT_ID),
428
+ clock: transaction.object(SUI_CLOCK_OBJECT_ID),
438
429
  priceInfo: transaction.object(priceInfoObjectId),
439
430
  });
440
431
  });
441
432
  }
442
433
  deposit(sendCoin, coinType, obligationOwnerCap, transaction) {
443
- const [ctokens] = (0, functions_1.depositLiquidityAndMintCtokens)(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
434
+ const [ctokens] = depositLiquidityAndMintCtokens(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
444
435
  lendingMarket: transaction.object(this.lendingMarket.id),
445
436
  reserveArrayIndex: transaction.pure.u64(this.findReserveArrayIndex(coinType)),
446
- clock: transaction.object(utils_1.SUI_CLOCK_OBJECT_ID),
437
+ clock: transaction.object(SUI_CLOCK_OBJECT_ID),
447
438
  deposit: sendCoin,
448
439
  });
449
- (0, functions_1.depositCtokensIntoObligation)(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
440
+ depositCtokensIntoObligation(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
450
441
  lendingMarket: transaction.object(this.lendingMarket.id),
451
442
  reserveArrayIndex: transaction.pure.u64(this.findReserveArrayIndex(coinType)),
452
443
  obligationOwnerCap,
453
- clock: transaction.object(utils_1.SUI_CLOCK_OBJECT_ID),
444
+ clock: transaction.object(SUI_CLOCK_OBJECT_ID),
454
445
  deposit: ctokens,
455
446
  });
456
447
  if (isSui(coinType)) {
457
- (0, functions_1.rebalanceStaker)(transaction, this.lendingMarket.$typeArgs[0], {
448
+ rebalanceStaker(transaction, this.lendingMarket.$typeArgs[0], {
458
449
  lendingMarket: transaction.object(this.lendingMarket.id),
459
450
  suiReserveArrayIndex: transaction.pure.u64(this.findReserveArrayIndex(coinType)),
460
- systemState: transaction.object(utils_1.SUI_SYSTEM_STATE_OBJECT_ID),
451
+ systemState: transaction.object(SUI_SYSTEM_STATE_OBJECT_ID),
461
452
  });
462
453
  }
463
454
  }
464
455
  depositIntoObligation(ownerId, coinType, value, transaction, obligationOwnerCap) {
465
456
  return __awaiter(this, void 0, void 0, function* () {
466
- const coins = yield (0, sui_fe_1.getAllCoins)(this.client, ownerId, coinType);
467
- const mergeCoin = (0, sui_fe_1.mergeAllCoins)(coinType, transaction, coins);
457
+ const coins = yield getAllCoins(this.client, ownerId, coinType);
458
+ const mergeCoin = mergeAllCoins(coinType, transaction, coins);
468
459
  const [sendCoin] = transaction.splitCoins(isSui(coinType)
469
460
  ? transaction.gas
470
461
  : transaction.object(mergeCoin.coinObjectId), [value]);
@@ -473,15 +464,15 @@ class SuilendClient {
473
464
  }
474
465
  depositLiquidityAndGetCTokens(ownerId, coinType, value, transaction) {
475
466
  return __awaiter(this, void 0, void 0, function* () {
476
- const coins = yield (0, sui_fe_1.getAllCoins)(this.client, ownerId, coinType);
477
- const mergeCoin = (0, sui_fe_1.mergeAllCoins)(coinType, transaction, coins);
467
+ const coins = yield getAllCoins(this.client, ownerId, coinType);
468
+ const mergeCoin = mergeAllCoins(coinType, transaction, coins);
478
469
  const [sendCoin] = transaction.splitCoins(isSui(coinType)
479
470
  ? transaction.gas
480
471
  : transaction.object(mergeCoin.coinObjectId), [value]);
481
- const [ctokens] = (0, functions_1.depositLiquidityAndMintCtokens)(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
472
+ const [ctokens] = depositLiquidityAndMintCtokens(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
482
473
  lendingMarket: transaction.object(this.lendingMarket.id),
483
474
  reserveArrayIndex: transaction.pure.u64(this.findReserveArrayIndex(coinType)),
484
- clock: transaction.object(utils_1.SUI_CLOCK_OBJECT_ID),
475
+ clock: transaction.object(SUI_CLOCK_OBJECT_ID),
485
476
  deposit: sendCoin,
486
477
  });
487
478
  transaction.transferObjects([ctokens], transaction.pure.address(ownerId));
@@ -495,17 +486,17 @@ class SuilendClient {
495
486
  throw new Error("Error: no obligation");
496
487
  yield this.refreshAll(transaction, obligation);
497
488
  }
498
- const [ctokens] = (0, functions_1.withdrawCtokens)(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
489
+ const [ctokens] = withdrawCtokens(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
499
490
  lendingMarket: transaction.object(this.lendingMarket.id),
500
491
  reserveArrayIndex: transaction.pure.u64(this.findReserveArrayIndex(coinType)),
501
492
  obligationOwnerCap,
502
- clock: transaction.object(utils_1.SUI_CLOCK_OBJECT_ID),
493
+ clock: transaction.object(SUI_CLOCK_OBJECT_ID),
503
494
  amount: BigInt(value),
504
495
  });
505
496
  const [exemption] = transaction.moveCall({
506
497
  target: `0x1::option::none`,
507
498
  typeArguments: [
508
- `${suilend_2.PACKAGE_ID}::lending_market::RateLimiterExemption<${this.lendingMarket.$typeArgs[0]}, ${coinType}>`,
499
+ `${PACKAGE_ID}::lending_market::RateLimiterExemption<${this.lendingMarket.$typeArgs[0]}, ${coinType}>`,
509
500
  ],
510
501
  arguments: [],
511
502
  });
@@ -513,22 +504,22 @@ class SuilendClient {
513
504
  });
514
505
  }
515
506
  redeem(ctokens, coinType, exemption, transaction) {
516
- const [liquidityRequest] = (0, functions_1.redeemCtokensAndWithdrawLiquidityRequest)(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
507
+ const [liquidityRequest] = redeemCtokensAndWithdrawLiquidityRequest(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
517
508
  lendingMarket: transaction.object(this.lendingMarket.id),
518
509
  reserveArrayIndex: transaction.pure.u64(this.findReserveArrayIndex(coinType)),
519
- clock: transaction.object(utils_1.SUI_CLOCK_OBJECT_ID),
510
+ clock: transaction.object(SUI_CLOCK_OBJECT_ID),
520
511
  ctokens,
521
512
  rateLimiterExemption: exemption,
522
513
  });
523
514
  if (isSui(coinType)) {
524
- (0, functions_1.unstakeSuiFromStaker)(transaction, this.lendingMarket.$typeArgs[0], {
515
+ unstakeSuiFromStaker(transaction, this.lendingMarket.$typeArgs[0], {
525
516
  lendingMarket: transaction.object(this.lendingMarket.id),
526
517
  suiReserveArrayIndex: transaction.pure.u64(this.findReserveArrayIndex(coinType)),
527
518
  liquidityRequest,
528
- systemState: transaction.object(utils_1.SUI_SYSTEM_STATE_OBJECT_ID),
519
+ systemState: transaction.object(SUI_SYSTEM_STATE_OBJECT_ID),
529
520
  });
530
521
  }
531
- return (0, functions_1.fulfillLiquidityRequest)(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
522
+ return fulfillLiquidityRequest(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
532
523
  lendingMarket: transaction.object(this.lendingMarket.id),
533
524
  reserveArrayIndex: transaction.pure.u64(this.findReserveArrayIndex(coinType)),
534
525
  liquidityRequest,
@@ -548,22 +539,22 @@ class SuilendClient {
548
539
  throw new Error("Error: no obligation");
549
540
  yield this.refreshAll(transaction, obligation, [coinType]);
550
541
  }
551
- const [liquidityRequest] = (0, functions_1.borrowRequest)(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
542
+ const [liquidityRequest] = borrowRequest(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
552
543
  lendingMarket: transaction.object(this.lendingMarket.id),
553
544
  reserveArrayIndex: transaction.pure.u64(this.findReserveArrayIndex(coinType)),
554
545
  obligationOwnerCap,
555
- clock: transaction.object(utils_1.SUI_CLOCK_OBJECT_ID),
546
+ clock: transaction.object(SUI_CLOCK_OBJECT_ID),
556
547
  amount: BigInt(value),
557
548
  });
558
549
  if (isSui(coinType)) {
559
- (0, functions_1.unstakeSuiFromStaker)(transaction, this.lendingMarket.$typeArgs[0], {
550
+ unstakeSuiFromStaker(transaction, this.lendingMarket.$typeArgs[0], {
560
551
  lendingMarket: transaction.object(this.lendingMarket.id),
561
552
  suiReserveArrayIndex: transaction.pure.u64(this.findReserveArrayIndex(coinType)),
562
553
  liquidityRequest,
563
- systemState: transaction.object(utils_1.SUI_SYSTEM_STATE_OBJECT_ID),
554
+ systemState: transaction.object(SUI_SYSTEM_STATE_OBJECT_ID),
564
555
  });
565
556
  }
566
- return (0, functions_1.fulfillLiquidityRequest)(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
557
+ return fulfillLiquidityRequest(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
567
558
  lendingMarket: transaction.object(this.lendingMarket.id),
568
559
  reserveArrayIndex: transaction.pure.u64(this.findReserveArrayIndex(coinType)),
569
560
  liquidityRequest,
@@ -577,18 +568,18 @@ class SuilendClient {
577
568
  });
578
569
  }
579
570
  repay(obligationId, coinType, coin, transaction) {
580
- return (0, functions_1.repay)(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
571
+ return repay(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
581
572
  lendingMarket: transaction.object(this.lendingMarket.id),
582
573
  reserveArrayIndex: transaction.pure.u64(this.findReserveArrayIndex(coinType)),
583
574
  obligationId: transaction.pure.id(obligationId),
584
- clock: transaction.object(utils_1.SUI_CLOCK_OBJECT_ID),
575
+ clock: transaction.object(SUI_CLOCK_OBJECT_ID),
585
576
  maxRepayCoins: coin,
586
577
  });
587
578
  }
588
579
  repayIntoObligation(ownerId, obligationId, coinType, value, transaction) {
589
580
  return __awaiter(this, void 0, void 0, function* () {
590
- const coins = yield (0, sui_fe_1.getAllCoins)(this.client, ownerId, coinType);
591
- const mergeCoin = (0, sui_fe_1.mergeAllCoins)(coinType, transaction, coins);
581
+ const coins = yield getAllCoins(this.client, ownerId, coinType);
582
+ const mergeCoin = mergeAllCoins(coinType, transaction, coins);
592
583
  const [sendCoin] = transaction.splitCoins(isSui(coinType)
593
584
  ? transaction.gas
594
585
  : transaction.object(mergeCoin.coinObjectId), [value]);
@@ -603,7 +594,7 @@ class SuilendClient {
603
594
  const [optionalExemption] = transaction.moveCall({
604
595
  target: `0x1::option::some`,
605
596
  typeArguments: [
606
- `${suilend_2.PUBLISHED_AT}::lending_market::RateLimiterExemption<${this.lendingMarket.$typeArgs[0]}, ${withdrawCoinType}>`,
597
+ `${PUBLISHED_AT}::lending_market::RateLimiterExemption<${this.lendingMarket.$typeArgs[0]}, ${withdrawCoinType}>`,
607
598
  ],
608
599
  arguments: [exemption],
609
600
  });
@@ -613,31 +604,31 @@ class SuilendClient {
613
604
  liquidate(transaction, obligation, repayCoinType, withdrawCoinType, repayCoinId) {
614
605
  return __awaiter(this, void 0, void 0, function* () {
615
606
  yield this.refreshAll(transaction, obligation);
616
- return (0, functions_1.liquidate)(transaction, [this.lendingMarket.$typeArgs[0], repayCoinType, withdrawCoinType], {
607
+ return liquidate(transaction, [this.lendingMarket.$typeArgs[0], repayCoinType, withdrawCoinType], {
617
608
  lendingMarket: transaction.object(this.lendingMarket.id),
618
609
  obligationId: obligation.id,
619
610
  repayReserveArrayIndex: transaction.pure.u64(this.findReserveArrayIndex(repayCoinType)),
620
611
  withdrawReserveArrayIndex: transaction.pure.u64(this.findReserveArrayIndex(withdrawCoinType)),
621
- clock: transaction.object(utils_1.SUI_CLOCK_OBJECT_ID),
612
+ clock: transaction.object(SUI_CLOCK_OBJECT_ID),
622
613
  repayCoins: repayCoinId,
623
614
  });
624
615
  });
625
616
  }
626
617
  migrate(transaction, lendingMarketOwnerCapId) {
627
- return (0, functions_1.migrate)(transaction, this.lendingMarket.$typeArgs[0], {
618
+ return migrate(transaction, this.lendingMarket.$typeArgs[0], {
628
619
  lendingMarketOwnerCap: transaction.object(lendingMarketOwnerCapId),
629
620
  lendingMarket: transaction.object(this.lendingMarket.id),
630
621
  });
631
622
  }
632
623
  claimFees(transaction, coinType) {
633
- return (0, functions_1.claimFees)(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
624
+ return claimFees(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
634
625
  lendingMarket: transaction.object(this.lendingMarket.id),
635
626
  reserveArrayIndex: transaction.pure.u64(this.findReserveArrayIndex(coinType)),
636
- systemState: transaction.object(utils_1.SUI_SYSTEM_STATE_OBJECT_ID),
627
+ systemState: transaction.object(SUI_SYSTEM_STATE_OBJECT_ID),
637
628
  });
638
629
  }
639
630
  setFeeReceiversAndWeights(transaction, lendingMarketOwnerCapId, receivers, weights) {
640
- return (0, functions_1.setFeeReceivers)(transaction, this.lendingMarket.$typeArgs[0], {
631
+ return setFeeReceivers(transaction, this.lendingMarket.$typeArgs[0], {
641
632
  lendingMarketOwnerCap: transaction.object(lendingMarketOwnerCapId),
642
633
  lendingMarket: transaction.object(this.lendingMarket.id),
643
634
  receivers,
@@ -648,16 +639,16 @@ class SuilendClient {
648
639
  return __awaiter(this, void 0, void 0, function* () {
649
640
  const mergeCoinMap = {};
650
641
  for (const ctokenCoinType of ctokenCoinTypes) {
651
- const coins = yield (0, sui_fe_1.getAllCoins)(this.client, ownerId, ctokenCoinType);
652
- const mergeCoin = (0, sui_fe_1.mergeAllCoins)(ctokenCoinType, transaction, coins);
642
+ const coins = yield getAllCoins(this.client, ownerId, ctokenCoinType);
643
+ const mergeCoin = mergeAllCoins(ctokenCoinType, transaction, coins);
653
644
  mergeCoinMap[ctokenCoinType] = mergeCoin;
654
645
  }
655
646
  for (const [ctokenCoinType, mergeCoin] of Object.entries(mergeCoinMap)) {
656
- const coinType = (0, sui_fe_1.extractCTokenCoinType)(ctokenCoinType);
647
+ const coinType = extractCTokenCoinType(ctokenCoinType);
657
648
  const [exemption] = transaction.moveCall({
658
649
  target: `0x1::option::none`,
659
650
  typeArguments: [
660
- `${suilend_2.PACKAGE_ID}::lending_market::RateLimiterExemption<${this.lendingMarket.$typeArgs[0]}, ${coinType}>`,
651
+ `${PACKAGE_ID}::lending_market::RateLimiterExemption<${this.lendingMarket.$typeArgs[0]}, ${coinType}>`,
661
652
  ],
662
653
  arguments: [],
663
654
  });
@@ -667,4 +658,3 @@ class SuilendClient {
667
658
  });
668
659
  }
669
660
  }
670
- exports.SuilendClient = SuilendClient;