@suilend/sdk 1.1.82 → 1.1.83
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.js +12 -39
- package/lib/liquidityMining.d.ts +6 -2
- package/lib/liquidityMining.js +3 -3
- package/package.json +1 -1
package/client.js
CHANGED
|
@@ -451,14 +451,8 @@ class SuilendClient {
|
|
|
451
451
|
}
|
|
452
452
|
depositIntoObligation(ownerId, coinType, value, transaction, obligationOwnerCap) {
|
|
453
453
|
return __awaiter(this, void 0, void 0, function* () {
|
|
454
|
-
const coins =
|
|
455
|
-
|
|
456
|
-
coinType,
|
|
457
|
-
})).data;
|
|
458
|
-
const mergeCoin = coins[0];
|
|
459
|
-
if (coins.length > 1 && !isSui(coinType)) {
|
|
460
|
-
transaction.mergeCoins(transaction.object(mergeCoin.coinObjectId), coins.map((c) => transaction.object(c.coinObjectId)).slice(1));
|
|
461
|
-
}
|
|
454
|
+
const coins = yield (0, sui_fe_1.getAllCoins)(this.client, ownerId, coinType);
|
|
455
|
+
const mergeCoin = (0, sui_fe_1.mergeAllCoins)(coinType, transaction, coins);
|
|
462
456
|
const [sendCoin] = transaction.splitCoins(isSui(coinType)
|
|
463
457
|
? transaction.gas
|
|
464
458
|
: transaction.object(mergeCoin.coinObjectId), [value]);
|
|
@@ -467,14 +461,8 @@ class SuilendClient {
|
|
|
467
461
|
}
|
|
468
462
|
depositLiquidityAndGetCTokens(ownerId, coinType, value, transaction) {
|
|
469
463
|
return __awaiter(this, void 0, void 0, function* () {
|
|
470
|
-
const coins =
|
|
471
|
-
|
|
472
|
-
coinType,
|
|
473
|
-
})).data;
|
|
474
|
-
const mergeCoin = coins[0];
|
|
475
|
-
if (coins.length > 1 && !isSui(coinType)) {
|
|
476
|
-
transaction.mergeCoins(transaction.object(mergeCoin.coinObjectId), coins.map((c) => transaction.object(c.coinObjectId)).slice(1));
|
|
477
|
-
}
|
|
464
|
+
const coins = yield (0, sui_fe_1.getAllCoins)(this.client, ownerId, coinType);
|
|
465
|
+
const mergeCoin = (0, sui_fe_1.mergeAllCoins)(coinType, transaction, coins);
|
|
478
466
|
const [sendCoin] = transaction.splitCoins(isSui(coinType)
|
|
479
467
|
? transaction.gas
|
|
480
468
|
: transaction.object(mergeCoin.coinObjectId), [value]);
|
|
@@ -587,14 +575,8 @@ class SuilendClient {
|
|
|
587
575
|
}
|
|
588
576
|
repayIntoObligation(ownerId, obligationId, coinType, value, transaction) {
|
|
589
577
|
return __awaiter(this, void 0, void 0, function* () {
|
|
590
|
-
const coins =
|
|
591
|
-
|
|
592
|
-
coinType,
|
|
593
|
-
})).data;
|
|
594
|
-
const mergeCoin = coins[0];
|
|
595
|
-
if (coins.length > 1 && !isSui(coinType)) {
|
|
596
|
-
transaction.mergeCoins(transaction.object(mergeCoin.coinObjectId), coins.map((c) => transaction.object(c.coinObjectId)).slice(1));
|
|
597
|
-
}
|
|
578
|
+
const coins = yield (0, sui_fe_1.getAllCoins)(this.client, ownerId, coinType);
|
|
579
|
+
const mergeCoin = (0, sui_fe_1.mergeAllCoins)(coinType, transaction, coins);
|
|
598
580
|
const [sendCoin] = transaction.splitCoins(isSui(coinType)
|
|
599
581
|
? transaction.gas
|
|
600
582
|
: transaction.object(mergeCoin.coinObjectId), [value]);
|
|
@@ -652,23 +634,14 @@ class SuilendClient {
|
|
|
652
634
|
}
|
|
653
635
|
redeemCtokensAndWithdrawLiquidity(ownerId, ctokenCoinTypes, transaction) {
|
|
654
636
|
return __awaiter(this, void 0, void 0, function* () {
|
|
655
|
-
const
|
|
637
|
+
const mergeCoinMap = {};
|
|
656
638
|
for (const ctokenCoinType of ctokenCoinTypes) {
|
|
657
|
-
const coins =
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
if (coins.length === 0)
|
|
662
|
-
continue;
|
|
663
|
-
if (mergeCoinsMap[ctokenCoinType] === undefined)
|
|
664
|
-
mergeCoinsMap[ctokenCoinType] = [];
|
|
665
|
-
mergeCoinsMap[ctokenCoinType].push(...coins);
|
|
639
|
+
const coins = yield (0, sui_fe_1.getAllCoins)(this.client, ownerId, ctokenCoinType);
|
|
640
|
+
const mergeCoin = (0, sui_fe_1.mergeAllCoins)(ctokenCoinType, transaction, coins);
|
|
641
|
+
if (mergeCoinMap[ctokenCoinType] === undefined)
|
|
642
|
+
mergeCoinMap[ctokenCoinType] = mergeCoin;
|
|
666
643
|
}
|
|
667
|
-
for (const [ctokenCoinType,
|
|
668
|
-
const mergeCoin = mergeCoins[0];
|
|
669
|
-
if (mergeCoins.length > 1) {
|
|
670
|
-
transaction.mergeCoins(transaction.object(mergeCoin.coinObjectId), mergeCoins.map((mc) => transaction.object(mc.coinObjectId)).slice(1));
|
|
671
|
-
}
|
|
644
|
+
for (const [ctokenCoinType, mergeCoin] of Object.entries(mergeCoinMap)) {
|
|
672
645
|
const coinType = (0, sui_fe_1.extractCTokenCoinType)(ctokenCoinType);
|
|
673
646
|
const [exemption] = transaction.moveCall({
|
|
674
647
|
target: `0x1::option::none`,
|
package/lib/liquidityMining.d.ts
CHANGED
|
@@ -49,8 +49,12 @@ export declare const getFilteredRewards: (rewards: RewardSummary[]) => RewardSum
|
|
|
49
49
|
export declare const getDedupedAprRewards: (filteredRewards: RewardSummary[]) => AprRewardSummary[];
|
|
50
50
|
export declare const getDedupedPerDayRewards: (filteredRewards: RewardSummary[]) => PerDayRewardSummary[];
|
|
51
51
|
export declare const getRewardsAprPercent: (side: Side, filteredRewards: RewardSummary[]) => BigNumber;
|
|
52
|
-
export declare const getStakingYieldAprPercent: (side: Side, coinType: string,
|
|
52
|
+
export declare const getStakingYieldAprPercent: (side: Side, coinType: string, lstMap: Record<string, {
|
|
53
|
+
aprPercent: BigNumber;
|
|
54
|
+
}>) => BigNumber | undefined;
|
|
53
55
|
export declare const getTotalAprPercent: (side: Side, aprPercent: BigNumber, filteredRewards: RewardSummary[], stakingYieldAprPercent?: BigNumber) => BigNumber;
|
|
54
|
-
export declare const getNetAprPercent: (obligation: ParsedObligation, rewardMap: RewardMap,
|
|
56
|
+
export declare const getNetAprPercent: (obligation: ParsedObligation, rewardMap: RewardMap, lstMap: Record<string, {
|
|
57
|
+
aprPercent: BigNumber;
|
|
58
|
+
}>, noShares?: boolean) => BigNumber;
|
|
55
59
|
export declare const getRewardsMap: (obligation: ParsedObligation | undefined, rewardMap: RewardMap, coinMetadataMap: Record<string, CoinMetadata>) => RewardsMap;
|
|
56
60
|
export {};
|
package/lib/liquidityMining.js
CHANGED
|
@@ -145,17 +145,17 @@ const getDedupedPerDayRewards = (filteredRewards) => {
|
|
|
145
145
|
exports.getDedupedPerDayRewards = getDedupedPerDayRewards;
|
|
146
146
|
const getRewardsAprPercent = (side, filteredRewards) => (0, exports.getDedupedAprRewards)(filteredRewards).reduce((acc, reward) => acc.plus(reward.stats.aprPercent.times(side === types_1.Side.DEPOSIT ? 1 : -1)), new bignumber_js_1.default(0));
|
|
147
147
|
exports.getRewardsAprPercent = getRewardsAprPercent;
|
|
148
|
-
const getStakingYieldAprPercent = (side, coinType,
|
|
148
|
+
const getStakingYieldAprPercent = (side, coinType, lstMap) => { var _a; return (side === types_1.Side.DEPOSIT ? (_a = lstMap[coinType]) === null || _a === void 0 ? void 0 : _a.aprPercent : undefined); };
|
|
149
149
|
exports.getStakingYieldAprPercent = getStakingYieldAprPercent;
|
|
150
150
|
const getTotalAprPercent = (side, aprPercent, filteredRewards, stakingYieldAprPercent) => aprPercent
|
|
151
151
|
.plus((0, exports.getRewardsAprPercent)(side, filteredRewards))
|
|
152
152
|
.plus(stakingYieldAprPercent !== null && stakingYieldAprPercent !== void 0 ? stakingYieldAprPercent : 0);
|
|
153
153
|
exports.getTotalAprPercent = getTotalAprPercent;
|
|
154
|
-
const getNetAprPercent = (obligation, rewardMap,
|
|
154
|
+
const getNetAprPercent = (obligation, rewardMap, lstMap, noShares) => {
|
|
155
155
|
const weightedDepositedAmountUsd_aprPercent = obligation.deposits.reduce((acc, deposit) => {
|
|
156
156
|
var _a;
|
|
157
157
|
const weightedDepositedAmountUsd_baseAprPercent = deposit.reserve.depositAprPercent.times(deposit.depositedAmountUsd);
|
|
158
|
-
const weightedDepositedAmountUsd_stakingYieldAprPercent = new bignumber_js_1.default((_a = (0, exports.getStakingYieldAprPercent)(types_1.Side.DEPOSIT, deposit.reserve.coinType,
|
|
158
|
+
const weightedDepositedAmountUsd_stakingYieldAprPercent = new bignumber_js_1.default((_a = (0, exports.getStakingYieldAprPercent)(types_1.Side.DEPOSIT, deposit.reserve.coinType, lstMap)) !== null && _a !== void 0 ? _a : 0).times(deposit.depositedAmountUsd);
|
|
159
159
|
const weightedDepositedAmountUsd_rewardsAprPercent = (0, exports.getRewardsAprPercent)(types_1.Side.DEPOSIT, (0, exports.getFilteredRewards)(rewardMap[deposit.reserve.coinType].deposit)).times(!noShares
|
|
160
160
|
? getDepositShareUsd(deposit.reserve, new bignumber_js_1.default(deposit.userRewardManager.share.toString()))
|
|
161
161
|
: deposit.depositedAmountUsd);
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@suilend/sdk","version":"1.1.
|
|
1
|
+
{"name":"@suilend/sdk","version":"1.1.83","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","./api/events":"./api/events.js","./api":"./api/index.js","./lib/constants":"./lib/constants.js","./lib":"./lib/index.js","./lib/initialize":"./lib/initialize.js","./lib/liquidityMining":"./lib/liquidityMining.js","./lib/strategyOwnerCap":"./lib/strategyOwnerCap.js","./lib/transactions":"./lib/transactions.js","./lib/types":"./lib/types.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","./swap":"./swap/index.js","./swap/quote":"./swap/quote.js","./swap/transaction":"./swap/transaction.js","./utils/events":"./utils/events.js","./utils":"./utils/index.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/i64/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js","./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs":"./_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/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 --noEmit","release":"bun run build && bun ts-node ./release.ts && cd ./dist && npm publish --access public"},"repository":{"type":"git","url":"git+https://github.com/suilend/suilend-fe-public.git"},"bugs":{"url":"https://github.com/suilend/suilend-fe-public/issues"},"dependencies":{"@7kprotocol/sdk-ts":"^3.4.1","@cetusprotocol/aggregator-sdk":"^1.2.1","@flowx-finance/sdk":"^1.13.4","@pythnetwork/pyth-sui-js":"^2.2.0","aftermath-ts-sdk":"^1.3.22","bignumber.js":"^9.1.2","bn.js":"^5.2.2","crypto-js":"^4.2.0","lodash":"^4.17.21","p-limit":"3.1.0","uuid":"^11.0.3"},"devDependencies":{"@types/bn.js":"^5.2.0","@types/lodash":"^4.17.20","ts-node":"^10.9.2"},"peerDependencies":{"@mysten/bcs":"1.6.0","@mysten/sui":"1.28.2","@suilend/sui-fe":"^0.3.29"},"overrides":{"chalk":"5.3.0","strip-ansi":"7.1.0","color-convert":"2.0.1","color-name":"1.1.4","is-core-module":"2.13.1","error-ex":"1.3.2","has-ansi":"5.0.1"}}
|