@suilend/sdk 1.1.8 → 1.1.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.d.ts +1 -1
- package/client.js +8 -9
- package/package.json +1 -1
- package/parsers/lendingMarket.js +2 -1
package/client.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export declare class SuilendClient {
|
|
|
27
27
|
static getLendingMarketOwnerCapId(ownerId: string, lendingMarketTypeArgs: string[], client: SuiClient): Promise<string | null>;
|
|
28
28
|
getLendingMarketOwnerCapId(ownerId: string): Promise<string | null>;
|
|
29
29
|
createReserve(lendingMarketOwnerCapId: string, transaction: Transaction, pythPriceId: string, coinType: string, createReserveConfigArgs: CreateReserveConfigArgs): Promise<import("@mysten/sui/transactions").TransactionResult>;
|
|
30
|
-
addReward(ownerId: string, lendingMarketOwnerCapId: string, reserveArrayIndex: bigint, isDepositReward: boolean, rewardCoinType: string, rewardValue: string, startTimeMs: bigint, endTimeMs: bigint, transaction: Transaction): Promise<import("@mysten/sui/transactions").TransactionResult>;
|
|
30
|
+
addReward(ownerId: string, lendingMarketOwnerCapId: string, reserveArrayIndex: bigint, isDepositReward: boolean, rewardCoinType: string, rewardValue: string, startTimeMs: bigint, endTimeMs: bigint, transaction: Transaction, mergeCoins?: boolean): Promise<import("@mysten/sui/transactions").TransactionResult>;
|
|
31
31
|
cancelReward(lendingMarketOwnerCapId: string, reserveArrayIndex: bigint, isDepositReward: boolean, rewardIndex: bigint, rewardCoinType: string, transaction: Transaction): import("@mysten/sui/transactions").TransactionResult;
|
|
32
32
|
closeReward(lendingMarketOwnerCapId: string, reserveArrayIndex: bigint, isDepositReward: boolean, rewardIndex: bigint, rewardCoinType: string, transaction: Transaction): import("@mysten/sui/transactions").TransactionResult;
|
|
33
33
|
claimReward(obligationOwnerCapId: string, reserveArrayIndex: bigint, rewardIndex: bigint, rewardType: string, side: Side, transaction: Transaction): import("@mysten/sui/transactions").TransactionResult;
|
package/client.js
CHANGED
|
@@ -176,18 +176,17 @@ class SuilendClient {
|
|
|
176
176
|
});
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
|
-
addReward(
|
|
180
|
-
return __awaiter(this,
|
|
179
|
+
addReward(ownerId_1, lendingMarketOwnerCapId_1, reserveArrayIndex_1, isDepositReward_1, rewardCoinType_1, rewardValue_1, startTimeMs_1, endTimeMs_1, transaction_1) {
|
|
180
|
+
return __awaiter(this, arguments, void 0, function* (ownerId, lendingMarketOwnerCapId, reserveArrayIndex, isDepositReward, rewardCoinType, rewardValue, startTimeMs, endTimeMs, transaction, mergeCoins = true) {
|
|
181
181
|
const isSui = (0, utils_1.normalizeStructTag)(rewardCoinType) === (0, utils_1.normalizeStructTag)(SUI_COINTYPE);
|
|
182
182
|
const coins = (yield this.client.getCoins({
|
|
183
183
|
owner: ownerId,
|
|
184
184
|
coinType: rewardCoinType,
|
|
185
185
|
})).data;
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
transaction.mergeCoins(transaction.object(mergeCoin.coinObjectId), coins.map((c) => transaction.object(c.coinObjectId)).slice(1));
|
|
186
|
+
if (coins.length > 1 && !isSui && mergeCoins) {
|
|
187
|
+
transaction.mergeCoins(transaction.object(coins[0].coinObjectId), coins.map((c) => transaction.object(c.coinObjectId)).slice(1));
|
|
189
188
|
}
|
|
190
|
-
const [rewardCoin] = transaction.splitCoins(isSui ? transaction.gas : transaction.object(
|
|
189
|
+
const [rewardCoin] = transaction.splitCoins(isSui ? transaction.gas : transaction.object(coins[0].coinObjectId), [rewardValue]);
|
|
191
190
|
return (0, functions_1.addPoolReward)(transaction, [this.lendingMarket.$typeArgs[0], rewardCoinType], {
|
|
192
191
|
lendingMarketOwnerCap: transaction.object(lendingMarketOwnerCapId),
|
|
193
192
|
lendingMarket: transaction.object(this.lendingMarket.id),
|
|
@@ -206,7 +205,7 @@ class SuilendClient {
|
|
|
206
205
|
lendingMarket: transaction.object(this.lendingMarket.id),
|
|
207
206
|
reserveArrayIndex: transaction.pure.u64(reserveArrayIndex),
|
|
208
207
|
isDepositReward: transaction.pure.bool(isDepositReward),
|
|
209
|
-
rewardIndex,
|
|
208
|
+
rewardIndex: transaction.pure.u64(rewardIndex),
|
|
210
209
|
clock: transaction.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
211
210
|
});
|
|
212
211
|
}
|
|
@@ -216,7 +215,7 @@ class SuilendClient {
|
|
|
216
215
|
lendingMarket: transaction.object(this.lendingMarket.id),
|
|
217
216
|
reserveArrayIndex: transaction.pure.u64(reserveArrayIndex),
|
|
218
217
|
isDepositReward: transaction.pure.bool(isDepositReward),
|
|
219
|
-
rewardIndex,
|
|
218
|
+
rewardIndex: transaction.pure.u64(rewardIndex),
|
|
220
219
|
clock: transaction.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
221
220
|
});
|
|
222
221
|
}
|
|
@@ -226,7 +225,7 @@ class SuilendClient {
|
|
|
226
225
|
cap: transaction.object(obligationOwnerCapId),
|
|
227
226
|
clock: transaction.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
228
227
|
reserveId: transaction.pure.u64(reserveArrayIndex),
|
|
229
|
-
rewardIndex,
|
|
228
|
+
rewardIndex: transaction.pure.u64(rewardIndex),
|
|
230
229
|
isDepositReward: transaction.pure.bool(side === types_1.Side.DEPOSIT),
|
|
231
230
|
});
|
|
232
231
|
}
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@suilend/sdk","version":"1.1.
|
|
1
|
+
{"name":"@suilend/sdk","version":"1.1.10","private":false,"description":"A TypeScript SDK for interacting with the Suilend program","author":"Suilend","license":"MIT","main":"./index.js","exports":{".":"./index.js","./client":"./client.js","./constants":"./constants.js","./types":"./types.js","./utils":"./utils/index.js","./api/events":"./api/events.js","./api":"./api/index.js","./parsers/apiReserveAssetDataEvent":"./parsers/apiReserveAssetDataEvent.js","./parsers":"./parsers/index.js","./parsers/lendingMarket":"./parsers/lendingMarket.js","./parsers/obligation":"./parsers/obligation.js","./parsers/rateLimiter":"./parsers/rateLimiter.js","./parsers/reserve":"./parsers/reserve.js","./utils/events":"./utils/events.js","./utils/obligation":"./utils/obligation.js","./utils/simulate":"./utils/simulate.js","./_generated/_framework/reified":"./_generated/_framework/reified.js","./_generated/_framework/util":"./_generated/_framework/util.js","./_generated/_framework/vector":"./_generated/_framework/vector.js","./_generated/suilend":"./_generated/suilend/index.js","./_generated/suilend/cell/structs":"./_generated/suilend/cell/structs.js","./_generated/suilend/decimal/structs":"./_generated/suilend/decimal/structs.js","./_generated/suilend/lending-market/functions":"./_generated/suilend/lending-market/functions.js","./_generated/suilend/lending-market/structs":"./_generated/suilend/lending-market/structs.js","./_generated/suilend/lending-market-registry/functions":"./_generated/suilend/lending-market-registry/functions.js","./_generated/suilend/liquidity-mining/structs":"./_generated/suilend/liquidity-mining/structs.js","./_generated/suilend/obligation/structs":"./_generated/suilend/obligation/structs.js","./_generated/suilend/rate-limiter/functions":"./_generated/suilend/rate-limiter/functions.js","./_generated/suilend/rate-limiter/structs":"./_generated/suilend/rate-limiter/structs.js","./_generated/suilend/reserve/structs":"./_generated/suilend/reserve/structs.js","./_generated/suilend/reserve-config/functions":"./_generated/suilend/reserve-config/functions.js","./_generated/suilend/reserve-config/structs":"./_generated/suilend/reserve-config/structs.js","./_generated/_dependencies/source/0x1":"./_generated/_dependencies/source/0x1/index.js","./_generated/_dependencies/source/0x2":"./_generated/_dependencies/source/0x2/index.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/index.js","./_generated/_dependencies/source/0x1/ascii/structs":"./_generated/_dependencies/source/0x1/ascii/structs.js","./_generated/_dependencies/source/0x1/option/structs":"./_generated/_dependencies/source/0x1/option/structs.js","./_generated/_dependencies/source/0x1/type-name/structs":"./_generated/_dependencies/source/0x1/type-name/structs.js","./_generated/_dependencies/source/0x2/bag/structs":"./_generated/_dependencies/source/0x2/bag/structs.js","./_generated/_dependencies/source/0x2/balance/structs":"./_generated/_dependencies/source/0x2/balance/structs.js","./_generated/_dependencies/source/0x2/object/structs":"./_generated/_dependencies/source/0x2/object/structs.js","./_generated/_dependencies/source/0x2/object-table/structs":"./_generated/_dependencies/source/0x2/object-table/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js"},"types":"./index.js","scripts":{"build":"rm -rf ./dist && bun tsc","eslint":"eslint --fix \"./src/**/*.ts\"","prettier":"prettier --write \"./src/**/*\"","lint":"bun eslint && bun prettier && bun tsc","release":"bun run build && bun ts-node ./prepublish.ts && cd ./dist && npm publish --access public"},"repository":{"type":"git","url":"git+https://github.com/solendprotocol/suilend-public.git"},"bugs":{"url":"https://github.com/solendprotocol/suilend-public/issues"},"homepage":"https://github.com/solendprotocol/suilend-public/tree/HEAD/sdk#readme","dependencies":{"@mysten/bcs":"1.1.0","@mysten/sui":"1.14.1","@pythnetwork/pyth-sui-js":"^2.1.0","bignumber.js":"^9.1.2","p-limit":"3.1.0","uuid":"^9.0.1"},"devDependencies":{"@types/node":"^20.12.7","ts-node":"^10.9.2","typescript":"^5.3.3"}}
|
package/parsers/lendingMarket.js
CHANGED
|
@@ -14,11 +14,12 @@ const parseLendingMarket = (lendingMarket, reserves, coinMetadataMap, currentTim
|
|
|
14
14
|
.map((reserve) => (0, reserve_1.parseReserve)(reserve, coinMetadataMap))
|
|
15
15
|
.sort((a, b) => {
|
|
16
16
|
const customOrder = [
|
|
17
|
+
"sSUI",
|
|
17
18
|
"SUI",
|
|
18
19
|
"USDC",
|
|
19
20
|
"wUSDC",
|
|
20
21
|
"USDT",
|
|
21
|
-
"
|
|
22
|
+
"suiETH",
|
|
22
23
|
"WETH",
|
|
23
24
|
"SOL",
|
|
24
25
|
"AUSD",
|