@suilend/sdk 1.1.85 → 1.1.87
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/_generated/_dependencies/source/0x1/ascii/structs.d.ts +7 -11
- package/_generated/_dependencies/source/0x1/option/structs.d.ts +4 -6
- package/_generated/_dependencies/source/0x1/type-name/structs.d.ts +6 -10
- package/_generated/_dependencies/source/0x2/bag/structs.d.ts +8 -15
- package/_generated/_dependencies/source/0x2/balance/structs.d.ts +6 -10
- package/_generated/_dependencies/source/0x2/object/structs.d.ts +8 -14
- package/_generated/_dependencies/source/0x2/object-table/structs.d.ts +8 -15
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.d.ts +4 -7
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.d.ts +12 -23
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.d.ts +30 -58
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.d.ts +4 -6
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.d.ts +75 -146
- package/_generated/_framework/util.d.ts +4 -16
- package/_generated/_framework/vector.d.ts +12 -5
- package/_generated/suilend/cell/structs.d.ts +6 -10
- package/_generated/suilend/decimal/structs.d.ts +3 -5
- package/_generated/suilend/lending-market/structs.d.ts +392 -368
- package/_generated/suilend/liquidity-mining/structs.d.ts +160 -134
- package/_generated/suilend/obligation/structs.d.ts +217 -332
- package/_generated/suilend/rate-limiter/structs.d.ts +17 -32
- package/_generated/suilend/reserve/structs.d.ts +393 -383
- package/_generated/suilend/reserve-config/structs.d.ts +40 -76
- package/client.d.ts +1 -1
- package/client.js +15 -7
- package/lib/initialize.d.ts +1 -2
- package/lib/initialize.js +67 -54
- package/lib/liquidityMining.d.ts +2 -2
- package/lib/liquidityMining.js +3 -3
- package/lib/strategyOwnerCap.js +24 -16
- package/lib/types.d.ts +0 -1
- package/mmt.d.ts +2 -0
- package/mmt.js +5 -0
- package/package.json +1 -1
- package/parsers/lendingMarket.d.ts +0 -1
- package/parsers/lendingMarket.js +2 -3
- package/strategies.d.ts +86 -1
- package/strategies.js +1788 -1
- package/swap/quote.js +0 -35
- package/swap/transaction.js +0 -35
- package/utils/index.d.ts +10 -0
- package/utils/index.js +34 -1
- package/utils/obligation.d.ts +2 -0
- package/utils/obligation.js +8 -0
|
@@ -61,65 +61,38 @@ export declare class ReserveConfig implements StructClass {
|
|
|
61
61
|
static get r(): reified.StructClassReified<ReserveConfig, ReserveConfigFields>;
|
|
62
62
|
static phantom(): PhantomReified<ToTypeStr<ReserveConfig>>;
|
|
63
63
|
static get p(): reified.PhantomReified<"0x1f54a9a2d71799553197e9ea24557797c6398d6a65f2d4d3818c9304b75d5e21::reserve_config::ReserveConfig" | "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf::reserve_config::ReserveConfig">;
|
|
64
|
-
static get bcs(): import("@mysten/sui/bcs").
|
|
65
|
-
open_ltv_pct: number
|
|
66
|
-
close_ltv_pct: number
|
|
67
|
-
max_close_ltv_pct: number
|
|
68
|
-
borrow_weight_bps: string
|
|
69
|
-
deposit_limit: string
|
|
70
|
-
borrow_limit: string
|
|
71
|
-
liquidation_bonus_bps: string
|
|
72
|
-
max_liquidation_bonus_bps: string
|
|
73
|
-
deposit_limit_usd: string
|
|
74
|
-
borrow_limit_usd: string
|
|
75
|
-
interest_rate_utils: number[]
|
|
76
|
-
interest_rate_aprs: string[];
|
|
77
|
-
borrow_fee_bps: string;
|
|
78
|
-
spread_fee_bps: string;
|
|
79
|
-
protocol_liquidation_fee_bps: string;
|
|
80
|
-
isolated: boolean;
|
|
81
|
-
open_attributed_borrow_limit_usd: string;
|
|
82
|
-
close_attributed_borrow_limit_usd: string;
|
|
83
|
-
additional_fields: {
|
|
84
|
-
id: {
|
|
85
|
-
id: {
|
|
86
|
-
bytes: string;
|
|
87
|
-
};
|
|
88
|
-
};
|
|
89
|
-
size: string;
|
|
90
|
-
};
|
|
91
|
-
}, {
|
|
92
|
-
open_ltv_pct: number;
|
|
93
|
-
close_ltv_pct: number;
|
|
94
|
-
max_close_ltv_pct: number;
|
|
95
|
-
borrow_weight_bps: string | number | bigint;
|
|
96
|
-
deposit_limit: string | number | bigint;
|
|
97
|
-
borrow_limit: string | number | bigint;
|
|
98
|
-
liquidation_bonus_bps: string | number | bigint;
|
|
99
|
-
max_liquidation_bonus_bps: string | number | bigint;
|
|
100
|
-
deposit_limit_usd: string | number | bigint;
|
|
101
|
-
borrow_limit_usd: string | number | bigint;
|
|
102
|
-
interest_rate_utils: Iterable<number> & {
|
|
64
|
+
static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
|
|
65
|
+
open_ltv_pct: import("@mysten/sui/bcs").BcsType<number, number, "u8">;
|
|
66
|
+
close_ltv_pct: import("@mysten/sui/bcs").BcsType<number, number, "u8">;
|
|
67
|
+
max_close_ltv_pct: import("@mysten/sui/bcs").BcsType<number, number, "u8">;
|
|
68
|
+
borrow_weight_bps: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
69
|
+
deposit_limit: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
70
|
+
borrow_limit: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
71
|
+
liquidation_bonus_bps: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
72
|
+
max_liquidation_bonus_bps: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
73
|
+
deposit_limit_usd: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
74
|
+
borrow_limit_usd: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
75
|
+
interest_rate_utils: import("@mysten/sui/bcs").BcsType<number[], Iterable<number> & {
|
|
103
76
|
length: number;
|
|
104
|
-
}
|
|
105
|
-
interest_rate_aprs: Iterable<string | number | bigint> & {
|
|
77
|
+
}, string>;
|
|
78
|
+
interest_rate_aprs: import("@mysten/sui/bcs").BcsType<string[], Iterable<string | number | bigint> & {
|
|
106
79
|
length: number;
|
|
107
|
-
}
|
|
108
|
-
borrow_fee_bps: string | number | bigint
|
|
109
|
-
spread_fee_bps: string | number | bigint
|
|
110
|
-
protocol_liquidation_fee_bps: string | number | bigint
|
|
111
|
-
isolated: boolean
|
|
112
|
-
open_attributed_borrow_limit_usd: string | number | bigint
|
|
113
|
-
close_attributed_borrow_limit_usd: string | number | bigint
|
|
114
|
-
additional_fields: {
|
|
115
|
-
id: {
|
|
116
|
-
id: {
|
|
117
|
-
bytes: string
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
size: string | number | bigint
|
|
121
|
-
}
|
|
122
|
-
}>;
|
|
80
|
+
}, string>;
|
|
81
|
+
borrow_fee_bps: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
82
|
+
spread_fee_bps: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
83
|
+
protocol_liquidation_fee_bps: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
84
|
+
isolated: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
|
|
85
|
+
open_attributed_borrow_limit_usd: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
86
|
+
close_attributed_borrow_limit_usd: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
87
|
+
additional_fields: import("@mysten/sui/bcs").BcsStruct<{
|
|
88
|
+
id: import("@mysten/sui/bcs").BcsStruct<{
|
|
89
|
+
id: import("@mysten/sui/bcs").BcsStruct<{
|
|
90
|
+
bytes: import("@mysten/sui/bcs").BcsType<string, string, string>;
|
|
91
|
+
}, string>;
|
|
92
|
+
}, string>;
|
|
93
|
+
size: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
94
|
+
}, string>;
|
|
95
|
+
}, string>;
|
|
123
96
|
static fromFields(fields: Record<string, any>): ReserveConfig;
|
|
124
97
|
static fromFieldsWithTypes(item: FieldsWithTypes): ReserveConfig;
|
|
125
98
|
static fromBcs(data: Uint8Array): ReserveConfig;
|
|
@@ -199,25 +172,16 @@ export declare class ReserveConfigBuilder implements StructClass {
|
|
|
199
172
|
static get r(): reified.StructClassReified<ReserveConfigBuilder, ReserveConfigBuilderFields>;
|
|
200
173
|
static phantom(): PhantomReified<ToTypeStr<ReserveConfigBuilder>>;
|
|
201
174
|
static get p(): reified.PhantomReified<"0x1f54a9a2d71799553197e9ea24557797c6398d6a65f2d4d3818c9304b75d5e21::reserve_config::ReserveConfigBuilder" | "0xf95b06141ed4a174f239417323bde3f209b972f5930d8521ea38a52aff3a6ddf::reserve_config::ReserveConfigBuilder">;
|
|
202
|
-
static get bcs(): import("@mysten/sui/bcs").
|
|
203
|
-
fields: {
|
|
204
|
-
id: {
|
|
205
|
-
id: {
|
|
206
|
-
bytes: string
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
size: string
|
|
210
|
-
}
|
|
211
|
-
},
|
|
212
|
-
fields: {
|
|
213
|
-
id: {
|
|
214
|
-
id: {
|
|
215
|
-
bytes: string;
|
|
216
|
-
};
|
|
217
|
-
};
|
|
218
|
-
size: string | number | bigint;
|
|
219
|
-
};
|
|
220
|
-
}>;
|
|
175
|
+
static get bcs(): import("@mysten/sui/bcs").BcsStruct<{
|
|
176
|
+
fields: import("@mysten/sui/bcs").BcsStruct<{
|
|
177
|
+
id: import("@mysten/sui/bcs").BcsStruct<{
|
|
178
|
+
id: import("@mysten/sui/bcs").BcsStruct<{
|
|
179
|
+
bytes: import("@mysten/sui/bcs").BcsType<string, string, string>;
|
|
180
|
+
}, string>;
|
|
181
|
+
}, string>;
|
|
182
|
+
size: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
|
|
183
|
+
}, string>;
|
|
184
|
+
}, string>;
|
|
221
185
|
static fromFields(fields: Record<string, any>): ReserveConfigBuilder;
|
|
222
186
|
static fromFieldsWithTypes(item: FieldsWithTypes): ReserveConfigBuilder;
|
|
223
187
|
static fromBcs(data: Uint8Array): ReserveConfigBuilder;
|
package/client.d.ts
CHANGED
|
@@ -46,7 +46,7 @@ export declare class SuilendClient {
|
|
|
46
46
|
getObligation(obligationId: string): Promise<Obligation<string>>;
|
|
47
47
|
static getLendingMarketOwnerCapId(ownerId: string, lendingMarketTypeArgs: string[], client: SuiClient): Promise<string | undefined>;
|
|
48
48
|
getLendingMarketOwnerCapId(ownerId: string): Promise<string | undefined>;
|
|
49
|
-
createReserve(lendingMarketOwnerCapId: string, transaction: Transaction, pythPriceId: string, coinType: string, createReserveConfigArgs: CreateReserveConfigArgs): Promise<import("@mysten/sui/transactions").TransactionResult>;
|
|
49
|
+
createReserve(lendingMarketOwnerCapId: string, transaction: Transaction, pythPriceId: string, coinType: string, createReserveConfigArgs: CreateReserveConfigArgs, coinMetadataIdOverride?: string): Promise<import("@mysten/sui/transactions").TransactionResult>;
|
|
50
50
|
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>;
|
|
51
51
|
cancelReward(lendingMarketOwnerCapId: string, reserveArrayIndex: bigint, isDepositReward: boolean, rewardIndex: bigint, rewardCoinType: string, transaction: Transaction): import("@mysten/sui/transactions").TransactionResult;
|
|
52
52
|
closeReward(lendingMarketOwnerCapId: string, reserveArrayIndex: bigint, isDepositReward: boolean, rewardIndex: bigint, rewardCoinType: string, transaction: Transaction): import("@mysten/sui/transactions").TransactionResult;
|
package/client.js
CHANGED
|
@@ -192,7 +192,7 @@ class SuilendClient {
|
|
|
192
192
|
return SuilendClient.getLendingMarketOwnerCapId(ownerId, this.lendingMarket.$typeArgs, this.client);
|
|
193
193
|
});
|
|
194
194
|
}
|
|
195
|
-
createReserve(lendingMarketOwnerCapId, transaction, pythPriceId, coinType, createReserveConfigArgs) {
|
|
195
|
+
createReserve(lendingMarketOwnerCapId, transaction, pythPriceId, coinType, createReserveConfigArgs, coinMetadataIdOverride) {
|
|
196
196
|
return __awaiter(this, void 0, void 0, function* () {
|
|
197
197
|
const [config] = (0, functions_4.createReserveConfig)(transaction, createReserveConfigArgs);
|
|
198
198
|
// Assumes the pyth price feed exists
|
|
@@ -200,18 +200,26 @@ class SuilendClient {
|
|
|
200
200
|
pythPriceId,
|
|
201
201
|
]);
|
|
202
202
|
const priceInfoObjectIds = yield this.pythClient.updatePriceFeeds(transaction, priceUpdateData, [pythPriceId]);
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
203
|
+
let coinMetadataId;
|
|
204
|
+
if (coinMetadataIdOverride !== undefined)
|
|
205
|
+
coinMetadataId = coinMetadataIdOverride;
|
|
206
|
+
else {
|
|
207
|
+
const coinMetadata = yield this.client.getCoinMetadata({
|
|
208
|
+
coinType: coinType,
|
|
209
|
+
});
|
|
210
|
+
console.log("[createReserve] coinMetadata", coinMetadata);
|
|
211
|
+
if (!coinMetadata)
|
|
212
|
+
throw new Error("Error: CoinMetadata not found");
|
|
213
|
+
if (!coinMetadata.id)
|
|
214
|
+
throw new Error("Error: CoinMetadata.id not found");
|
|
215
|
+
coinMetadataId = coinMetadata.id;
|
|
208
216
|
}
|
|
209
217
|
return (0, functions_1.addReserve)(transaction, [this.lendingMarket.$typeArgs[0], coinType], {
|
|
210
218
|
lendingMarketOwnerCap: transaction.object(lendingMarketOwnerCapId),
|
|
211
219
|
lendingMarket: transaction.object(this.lendingMarket.id),
|
|
212
220
|
priceInfo: transaction.object(priceInfoObjectIds[0]),
|
|
213
221
|
config: transaction.object(config),
|
|
214
|
-
coinMetadata: transaction.object(
|
|
222
|
+
coinMetadata: transaction.object(coinMetadataId),
|
|
215
223
|
clock: transaction.object(utils_1.SUI_CLOCK_OBJECT_ID),
|
|
216
224
|
});
|
|
217
225
|
});
|
package/lib/initialize.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { Reserve } from "../_generated/suilend/reserve/structs";
|
|
|
4
4
|
import { SuilendClient } from "../client";
|
|
5
5
|
import { ParsedReserve } from "../parsers";
|
|
6
6
|
import { LendingMarketMetadata, StrategyOwnerCap } from "./types";
|
|
7
|
-
export declare const RESERVES_CUSTOM_ORDER: string[]
|
|
7
|
+
export declare const RESERVES_CUSTOM_ORDER: Record<string, string[]>;
|
|
8
8
|
export declare const NORMALIZED_MAYA_COINTYPE: string;
|
|
9
9
|
export declare const NORMALIZED_mPOINTS_COINTYPE: string;
|
|
10
10
|
export declare const NORMALIZED_TREATS_COINTYPE: string;
|
|
@@ -141,7 +141,6 @@ export declare const initializeSuilend: (suiClient: SuiClient, suilendClient: Su
|
|
|
141
141
|
type: string;
|
|
142
142
|
ownerCapId: string | undefined;
|
|
143
143
|
name: string;
|
|
144
|
-
slug: string;
|
|
145
144
|
isHidden: boolean;
|
|
146
145
|
totalSupplyUsd: BigNumber;
|
|
147
146
|
totalBorrowUsd: BigNumber;
|
package/lib/initialize.js
CHANGED
|
@@ -55,50 +55,61 @@ const parsers_1 = require("../parsers");
|
|
|
55
55
|
const simulate = __importStar(require("../utils/simulate"));
|
|
56
56
|
const constants_1 = require("./constants");
|
|
57
57
|
const strategyOwnerCap_1 = require("./strategyOwnerCap");
|
|
58
|
-
exports.RESERVES_CUSTOM_ORDER =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
58
|
+
exports.RESERVES_CUSTOM_ORDER = {
|
|
59
|
+
[client_1.LENDING_MARKET_ID]: [
|
|
60
|
+
// MAIN ASSETS
|
|
61
|
+
sui_fe_1.NORMALIZED_sSUI_COINTYPE,
|
|
62
|
+
// MAIN ASSETS - Ecosystem LSTs
|
|
63
|
+
sui_fe_1.NORMALIZED_mSUI_COINTYPE,
|
|
64
|
+
sui_fe_1.NORMALIZED_fudSUI_COINTYPE,
|
|
65
|
+
sui_fe_1.NORMALIZED_kSUI_COINTYPE,
|
|
66
|
+
sui_fe_1.NORMALIZED_trevinSUI_COINTYPE,
|
|
67
|
+
sui_fe_1.NORMALIZED_upSUI_COINTYPE,
|
|
68
|
+
sui_fe_1.NORMALIZED_yapSUI_COINTYPE,
|
|
69
|
+
sui_fe_1.NORMALIZED_iSUI_COINTYPE,
|
|
70
|
+
sui_fe_1.NORMALIZED_flSUI_COINTYPE,
|
|
71
|
+
sui_fe_1.NORMALIZED_oshiSUI_COINTYPE,
|
|
72
|
+
sui_fe_1.NORMALIZED_jugSUI_COINTYPE,
|
|
73
|
+
sui_fe_1.NORMALIZED_stratSUI_COINTYPE,
|
|
74
|
+
sui_fe_1.NORMALIZED_fpSUI_COINTYPE,
|
|
75
|
+
sui_fe_1.NORMALIZED_SUI_COINTYPE,
|
|
76
|
+
sui_fe_1.NORMALIZED_USDC_COINTYPE,
|
|
77
|
+
sui_fe_1.NORMALIZED_wUSDC_COINTYPE,
|
|
78
|
+
sui_fe_1.NORMALIZED_suiUSDT_COINTYPE,
|
|
79
|
+
sui_fe_1.NORMALIZED_wUSDT_COINTYPE,
|
|
80
|
+
sui_fe_1.NORMALIZED_AUSD_COINTYPE,
|
|
81
|
+
sui_fe_1.NORMALIZED_LBTC_COINTYPE,
|
|
82
|
+
sui_fe_1.NORMALIZED_wBTC_COINTYPE,
|
|
83
|
+
sui_fe_1.NORMALIZED_xBTC_COINTYPE,
|
|
84
|
+
sui_fe_1.NORMALIZED_suiETH_COINTYPE,
|
|
85
|
+
sui_fe_1.NORMALIZED_WETH_COINTYPE,
|
|
86
|
+
sui_fe_1.NORMALIZED_SOL_COINTYPE,
|
|
87
|
+
sui_fe_1.NORMALIZED_DEEP_COINTYPE,
|
|
88
|
+
sui_fe_1.NORMALIZED_WAL_COINTYPE,
|
|
89
|
+
// ISOLATED ASSETS
|
|
90
|
+
sui_fe_1.NORMALIZED_SEND_COINTYPE,
|
|
91
|
+
sui_fe_1.NORMALIZED_IKA_COINTYPE,
|
|
92
|
+
sui_fe_1.NORMALIZED_HAEDAL_COINTYPE,
|
|
93
|
+
sui_fe_1.NORMALIZED_BLUE_COINTYPE,
|
|
94
|
+
sui_fe_1.NORMALIZED_NS_COINTYPE,
|
|
95
|
+
sui_fe_1.NORMALIZED_UP_COINTYPE,
|
|
96
|
+
sui_fe_1.NORMALIZED_DMC_COINTYPE,
|
|
97
|
+
sui_fe_1.NORMALIZED_ALKIMI_COINTYPE,
|
|
98
|
+
sui_fe_1.NORMALIZED_KOBAN_COINTYPE,
|
|
99
|
+
sui_fe_1.NORMALIZED_mUSD_COINTYPE,
|
|
100
|
+
sui_fe_1.NORMALIZED_BUCK_COINTYPE,
|
|
101
|
+
sui_fe_1.NORMALIZED_HIPPO_COINTYPE,
|
|
102
|
+
sui_fe_1.NORMALIZED_FUD_COINTYPE,
|
|
103
|
+
],
|
|
104
|
+
"0x0d3a7f758d19d11e8526f66cca43403a99da16862c570c43efe0f8c4a500f7f2": [
|
|
105
|
+
sui_fe_1.NORMALIZED_sdeUSD_COINTYPE,
|
|
106
|
+
sui_fe_1.NORMALIZED_USDC_COINTYPE,
|
|
107
|
+
],
|
|
108
|
+
"0x8a8d8e138a28de1c637d0b0955e621b017da7010de388db5a18493eca99c5e82": [
|
|
109
|
+
sui_fe_1.NORMALIZED_XAUm_COINTYPE,
|
|
110
|
+
sui_fe_1.NORMALIZED_USDC_COINTYPE,
|
|
111
|
+
],
|
|
112
|
+
};
|
|
102
113
|
const MAYA_COINTYPE = "0x3bf0aeb7b9698b18ec7937290a5701088fcd5d43ad11a2564b074d022a6d71ec::maya::MAYA";
|
|
103
114
|
const mPOINTS_COINTYPE = "0x7bae0b3b7b6c3da899fe3f4af95b7110633499c02b8c6945110d799d99deaa68::mpoints::MPOINTS";
|
|
104
115
|
const TREATS_COINTYPE = "0x0dadb7fa2771c2952f96161fc1f0c105d1f22d53926b9ff2498a8eea2f6eb204::treats::TREATS";
|
|
@@ -189,16 +200,18 @@ const initializeSuilend = (suiClient, suilendClient, lendingMarketMetadata) => _
|
|
|
189
200
|
// (walReserve.smoothedPrice.value as bigint) = walPrice;
|
|
190
201
|
// }
|
|
191
202
|
const lendingMarket = (0, parsers_1.parseLendingMarket)(suilendClient.lendingMarket, refreshedRawReserves, coinMetadataMap, nowS, lendingMarketMetadata);
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
203
|
+
if (!!exports.RESERVES_CUSTOM_ORDER[lendingMarket.id]) {
|
|
204
|
+
lendingMarket.reserves = lendingMarket.reserves.slice().sort((a, b) => {
|
|
205
|
+
const aCustomOrderIndex = exports.RESERVES_CUSTOM_ORDER[lendingMarket.id].indexOf(a.coinType);
|
|
206
|
+
const bCustomOrderIndex = exports.RESERVES_CUSTOM_ORDER[lendingMarket.id].indexOf(b.coinType);
|
|
207
|
+
if (aCustomOrderIndex > -1 && bCustomOrderIndex > -1)
|
|
208
|
+
return aCustomOrderIndex - bCustomOrderIndex;
|
|
209
|
+
else if (aCustomOrderIndex === -1 && bCustomOrderIndex === -1)
|
|
210
|
+
return 0;
|
|
211
|
+
else
|
|
212
|
+
return aCustomOrderIndex > -1 ? -1 : 1;
|
|
213
|
+
});
|
|
214
|
+
}
|
|
202
215
|
const reserveMap = lendingMarket.reserves.reduce((acc, reserve) => (Object.assign(Object.assign({}, acc), { [reserve.coinType]: reserve })), {});
|
|
203
216
|
return {
|
|
204
217
|
lendingMarket,
|
package/lib/liquidityMining.d.ts
CHANGED
|
@@ -49,11 +49,11 @@ 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, lstStatsMap: Record<string, {
|
|
53
53
|
aprPercent: BigNumber;
|
|
54
54
|
}>) => BigNumber | undefined;
|
|
55
55
|
export declare const getTotalAprPercent: (side: Side, aprPercent: BigNumber, filteredRewards: RewardSummary[], stakingYieldAprPercent?: BigNumber) => BigNumber;
|
|
56
|
-
export declare const getNetAprPercent: (obligation: ParsedObligation, rewardMap: RewardMap,
|
|
56
|
+
export declare const getNetAprPercent: (obligation: ParsedObligation, rewardMap: RewardMap, lstStatsMap: Record<string, {
|
|
57
57
|
aprPercent: BigNumber;
|
|
58
58
|
}>, noShares?: boolean) => BigNumber;
|
|
59
59
|
export declare const getRewardsMap: (obligation: ParsedObligation | undefined, rewardMap: RewardMap, coinMetadataMap: Record<string, CoinMetadata>) => RewardsMap;
|
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, lstStatsMap) => { var _a; return (side === types_1.Side.DEPOSIT ? (_a = lstStatsMap[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, lstStatsMap, 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, lstStatsMap)) !== 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/lib/strategyOwnerCap.js
CHANGED
|
@@ -244,26 +244,34 @@ const strategyClaimRewardsAndSwapForCoinType = (address, cetusSdk, cetusPartnerI
|
|
|
244
244
|
const amountsAndSortedQuotesMap = Object.fromEntries(yield Promise.all(Object.entries(mergedCoinsMap)
|
|
245
245
|
.filter(([coinType]) => swappedCoinTypes.includes(coinType))
|
|
246
246
|
.map(([coinType, coin]) => (() => __awaiter(void 0, void 0, void 0, function* () {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
247
|
+
try {
|
|
248
|
+
// Get amount
|
|
249
|
+
const { rawAmount: amount } = filteredRewardsMap[coinType]; // Use underestimate (rewards keep accruing)
|
|
250
|
+
// Get routes
|
|
251
|
+
const routers = yield cetusSdk.findRouters({
|
|
252
|
+
from: coinType,
|
|
253
|
+
target: depositReserve.coinType,
|
|
254
|
+
amount: new bn_js_1.default(amount.toString()), // Underestimate (rewards keep accruing)
|
|
255
|
+
byAmountIn: true,
|
|
256
|
+
});
|
|
257
|
+
if (!routers)
|
|
258
|
+
throw new Error(`No swap quote found for ${coinType}`);
|
|
259
|
+
console.log("[strategyClaimRewardsAndSwapForCoinType] routers", {
|
|
260
|
+
coinType,
|
|
261
|
+
routers,
|
|
262
|
+
});
|
|
263
|
+
return [coinType, { coin, routers }];
|
|
264
|
+
}
|
|
265
|
+
catch (err) {
|
|
266
|
+
console.error(err);
|
|
267
|
+
return [coinType, { coin, routers: undefined }];
|
|
268
|
+
}
|
|
263
269
|
}))())));
|
|
264
270
|
console.log("[strategyClaimRewardsAndSwapForCoinType] amountsAndSortedQuotesMap", { amountsAndSortedQuotesMap });
|
|
265
271
|
// 3.2.2) Swap
|
|
266
272
|
for (const [coinType, { coin: coinIn, routers }] of Object.entries(amountsAndSortedQuotesMap)) {
|
|
273
|
+
if (routers === undefined)
|
|
274
|
+
continue; // Skip coin if no swap quote found
|
|
267
275
|
console.log("[strategyClaimRewardsAndSwapForCoinType] swapping coinType", coinType);
|
|
268
276
|
let coinOut;
|
|
269
277
|
try {
|
package/lib/types.d.ts
CHANGED
package/mmt.d.ts
ADDED
package/mmt.js
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MMT_VERSION_OBJECT_ID = exports.MMT_CONTRACT_PACKAGE_ID = void 0;
|
|
4
|
+
exports.MMT_CONTRACT_PACKAGE_ID = "0xcf60a40f45d46fc1e828871a647c1e25a0915dec860d2662eb10fdb382c3c1d1";
|
|
5
|
+
exports.MMT_VERSION_OBJECT_ID = "0x2375a0b1ec12010aaea3b2545acfa2ad34cfbba03ce4b59f4c39e1e25eed1b2a";
|
package/package.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"@suilend/sdk","version":"1.1.
|
|
1
|
+
{"name":"@suilend/sdk","version":"1.1.87","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","./mmt":"./mmt.js","./strategies":"./strategies.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.5","@pythnetwork/pyth-sui-js":"^2.2.0","@suilend/springsui-sdk":"^1.0.27","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.8.1","@mysten/sui":"1.42.0","@suilend/sui-fe":"^0.3.38"},"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"}}
|
|
@@ -136,7 +136,6 @@ export declare const parseLendingMarket: (lendingMarket: LendingMarket<string>,
|
|
|
136
136
|
type: string;
|
|
137
137
|
ownerCapId: string | undefined;
|
|
138
138
|
name: string;
|
|
139
|
-
slug: string;
|
|
140
139
|
isHidden: boolean;
|
|
141
140
|
/**
|
|
142
141
|
* @deprecated since version 1.0.3. Use `depositedAmountUsd` instead.
|
package/parsers/lendingMarket.js
CHANGED
|
@@ -8,7 +8,7 @@ const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
|
8
8
|
const rateLimiter_1 = require("./rateLimiter");
|
|
9
9
|
const reserve_1 = require("./reserve");
|
|
10
10
|
const parseLendingMarket = (lendingMarket, reserves, coinMetadataMap, nowS, lendingMarketMetadata) => {
|
|
11
|
-
var _a, _b, _c
|
|
11
|
+
var _a, _b, _c;
|
|
12
12
|
const id = lendingMarket.id;
|
|
13
13
|
const type = lendingMarket.$typeArgs[0];
|
|
14
14
|
const version = lendingMarket.version;
|
|
@@ -43,8 +43,7 @@ const parseLendingMarket = (lendingMarket, reserves, coinMetadataMap, nowS, lend
|
|
|
43
43
|
type,
|
|
44
44
|
ownerCapId: (_a = lendingMarketMetadata === null || lendingMarketMetadata === void 0 ? void 0 : lendingMarketMetadata.lendingMarketOwnerCapId) !== null && _a !== void 0 ? _a : undefined,
|
|
45
45
|
name: (_b = lendingMarketMetadata === null || lendingMarketMetadata === void 0 ? void 0 : lendingMarketMetadata.name) !== null && _b !== void 0 ? _b : type.split("::").slice(1).join(" "),
|
|
46
|
-
|
|
47
|
-
isHidden: (_d = lendingMarketMetadata === null || lendingMarketMetadata === void 0 ? void 0 : lendingMarketMetadata.isHidden) !== null && _d !== void 0 ? _d : true,
|
|
46
|
+
isHidden: (_c = lendingMarketMetadata === null || lendingMarketMetadata === void 0 ? void 0 : lendingMarketMetadata.isHidden) !== null && _c !== void 0 ? _c : true,
|
|
48
47
|
/**
|
|
49
48
|
* @deprecated since version 1.0.3. Use `depositedAmountUsd` instead.
|
|
50
49
|
*/
|