@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.
- package/_generated/_dependencies/source/0x1/ascii/structs.d.ts +7 -7
- package/_generated/_dependencies/source/0x1/ascii/structs.js +35 -75
- package/_generated/_dependencies/source/0x1/index.js +3 -6
- package/_generated/_dependencies/source/0x1/option/structs.d.ts +3 -3
- package/_generated/_dependencies/source/0x1/option/structs.js +31 -69
- package/_generated/_dependencies/source/0x1/type-name/structs.d.ts +5 -5
- package/_generated/_dependencies/source/0x1/type-name/structs.js +20 -25
- package/_generated/_dependencies/source/0x2/bag/structs.d.ts +7 -7
- package/_generated/_dependencies/source/0x2/bag/structs.js +24 -29
- package/_generated/_dependencies/source/0x2/balance/structs.d.ts +7 -7
- package/_generated/_dependencies/source/0x2/balance/structs.js +49 -56
- package/_generated/_dependencies/source/0x2/index.js +3 -6
- package/_generated/_dependencies/source/0x2/object/structs.d.ts +8 -8
- package/_generated/_dependencies/source/0x2/object/structs.js +34 -41
- package/_generated/_dependencies/source/0x2/object-table/structs.d.ts +7 -7
- package/_generated/_dependencies/source/0x2/object-table/structs.js +31 -36
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.d.ts +5 -5
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/i64/structs.js +23 -28
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/index.js +4 -7
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.d.ts +11 -11
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price/structs.js +32 -37
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.d.ts +23 -23
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-feed/structs.js +29 -34
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.d.ts +4 -4
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-identifier/structs.js +21 -59
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.d.ts +55 -55
- package/_generated/_dependencies/source/0x8d97f1cd6ac663735be08d1d2b6d02a159e711586461306ce60a2b7a6a565a9e/price-info/structs.js +46 -53
- package/_generated/_framework/reified.d.ts +2 -2
- package/_generated/_framework/reified.js +27 -40
- package/_generated/_framework/util.js +26 -40
- package/_generated/_framework/vector.d.ts +4 -4
- package/_generated/_framework/vector.js +16 -21
- package/_generated/suilend/cell/structs.d.ts +4 -4
- package/_generated/suilend/cell/structs.js +31 -36
- package/_generated/suilend/decimal/structs.d.ts +4 -4
- package/_generated/suilend/decimal/structs.js +19 -24
- package/_generated/suilend/index.js +8 -12
- package/_generated/suilend/lending-market/functions.d.ts +1 -0
- package/_generated/suilend/lending-market/functions.js +271 -302
- package/_generated/suilend/lending-market/structs.d.ts +146 -146
- package/_generated/suilend/lending-market/structs.js +549 -617
- package/_generated/suilend/lending-market-registry/functions.js +7 -11
- package/_generated/suilend/liquidity-mining/structs.d.ts +50 -50
- package/_generated/suilend/liquidity-mining/structs.js +159 -205
- package/_generated/suilend/obligation/structs.d.ts +106 -106
- package/_generated/suilend/obligation/structs.js +313 -363
- package/_generated/suilend/rate-limiter/functions.js +23 -31
- package/_generated/suilend/rate-limiter/structs.d.ts +15 -15
- package/_generated/suilend/rate-limiter/structs.js +49 -56
- package/_generated/suilend/reserve/structs.d.ts +139 -139
- package/_generated/suilend/reserve/structs.js +397 -451
- package/_generated/suilend/reserve-config/functions.js +149 -190
- package/_generated/suilend/reserve-config/structs.d.ts +33 -33
- package/_generated/suilend/reserve-config/structs.js +109 -149
- package/api/events.js +1 -5
- package/api/index.js +1 -17
- package/client.d.ts +10 -10
- package/client.js +118 -128
- package/index.js +7 -23
- package/lib/constants.js +3 -9
- package/lib/index.js +5 -21
- package/lib/initialize.d.ts +3 -3
- package/lib/initialize.js +103 -140
- package/lib/liquidityMining.d.ts +3 -3
- package/lib/liquidityMining.js +57 -72
- package/lib/pyth.js +9 -14
- package/lib/strategyOwnerCap.js +106 -119
- package/lib/transactions.js +2 -7
- package/lib/types.js +4 -7
- package/mmt.js +2 -5
- package/package.json +1 -1
- package/parsers/apiReserveAssetDataEvent.js +25 -33
- package/parsers/index.js +5 -21
- package/parsers/lendingMarket.d.ts +1 -1
- package/parsers/lendingMarket.js +12 -19
- package/parsers/obligation.js +19 -26
- package/parsers/rateLimiter.js +11 -19
- package/parsers/reserve.d.ts +1 -1
- package/parsers/reserve.js +42 -85
- package/strategies.d.ts +11 -11
- package/strategies.js +547 -586
- package/swap/index.js +2 -18
- package/swap/quote.js +57 -65
- package/swap/transaction.d.ts +2 -2
- package/swap/transaction.js +40 -35
- package/utils/events.d.ts +3 -3
- package/utils/events.js +18 -35
- package/utils/index.js +16 -40
- package/utils/obligation.d.ts +4 -4
- package/utils/obligation.js +17 -60
- package/utils/simulate.js +118 -143
package/index.js
CHANGED
|
@@ -1,23 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./api"), exports);
|
|
18
|
-
__exportStar(require("./lib"), exports);
|
|
19
|
-
__exportStar(require("./parsers"), exports);
|
|
20
|
-
__exportStar(require("./strategies"), exports);
|
|
21
|
-
__exportStar(require("./swap"), exports);
|
|
22
|
-
__exportStar(require("./utils"), exports);
|
|
23
|
-
__exportStar(require("./client"), exports);
|
|
1
|
+
export * from "./api";
|
|
2
|
+
export * from "./lib";
|
|
3
|
+
export * from "./parsers";
|
|
4
|
+
export * from "./strategies";
|
|
5
|
+
export * from "./swap";
|
|
6
|
+
export * from "./utils";
|
|
7
|
+
export * from "./client";
|
package/lib/constants.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.msPerYear = exports.WAD = void 0;
|
|
7
|
-
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
8
|
-
exports.WAD = new bignumber_js_1.default(10).pow(18);
|
|
9
|
-
exports.msPerYear = 31556952000; // Approx. 1000 * 60 * 60 * 24 * 365; // Used by external dependencies (e.g. msafe-sui-app-store)
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
export const WAD = new BigNumber(10).pow(18);
|
|
3
|
+
export const msPerYear = 31556952000; // Approx. 1000 * 60 * 60 * 24 * 365; // Used by external dependencies (e.g. msafe-sui-app-store)
|
package/lib/index.js
CHANGED
|
@@ -1,21 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./constants"), exports);
|
|
18
|
-
__exportStar(require("./initialize"), exports);
|
|
19
|
-
__exportStar(require("./liquidityMining"), exports);
|
|
20
|
-
__exportStar(require("./transactions"), exports);
|
|
21
|
-
__exportStar(require("./types"), exports);
|
|
1
|
+
export * from "./constants";
|
|
2
|
+
export * from "./initialize";
|
|
3
|
+
export * from "./liquidityMining";
|
|
4
|
+
export * from "./transactions";
|
|
5
|
+
export * from "./types";
|
package/lib/initialize.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CoinMetadata,
|
|
1
|
+
import { CoinMetadata, SuiJsonRpcClient } from "@mysten/sui/jsonRpc";
|
|
2
2
|
import BigNumber from "bignumber.js";
|
|
3
3
|
import { Reserve } from "../_generated/suilend/reserve/structs";
|
|
4
4
|
import { SuilendClient } from "../client";
|
|
@@ -8,7 +8,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;
|
|
11
|
-
export declare const initializeSuilend: (suiClient:
|
|
11
|
+
export declare const initializeSuilend: (suiClient: SuiJsonRpcClient, suilendClient: SuilendClient, lendingMarketMetadata?: LendingMarketMetadata, fallbackPythEndpoint?: string) => Promise<{
|
|
12
12
|
lendingMarket: {
|
|
13
13
|
version: bigint;
|
|
14
14
|
reserves: {
|
|
@@ -264,7 +264,7 @@ export declare const initializeSuilend: (suiClient: SuiClient, suilendClient: Su
|
|
|
264
264
|
export declare const initializeSuilendRewards: (reserveMap: Record<string, ParsedReserve>, activeRewardCoinTypes: string[]) => Promise<{
|
|
265
265
|
rewardPriceMap: Record<string, BigNumber | undefined>;
|
|
266
266
|
}>;
|
|
267
|
-
export declare const initializeObligations: (suiClient:
|
|
267
|
+
export declare const initializeObligations: (suiClient: SuiJsonRpcClient, suilendClient: SuilendClient, refreshedRawReserves: Reserve<string>[], reserveMap: Record<string, ParsedReserve>, address?: string) => Promise<{
|
|
268
268
|
strategyOwnerCaps: StrategyOwnerCap[];
|
|
269
269
|
strategyObligations: {
|
|
270
270
|
id: string;
|
package/lib/initialize.js
CHANGED
|
@@ -1,37 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
1
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
2
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
3
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -41,92 +7,92 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
41
7
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
8
|
});
|
|
43
9
|
};
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
const constants_1 = require("./constants");
|
|
57
|
-
const pyth_1 = require("./pyth");
|
|
58
|
-
const strategyOwnerCap_1 = require("./strategyOwnerCap");
|
|
59
|
-
exports.RESERVES_CUSTOM_ORDER = {
|
|
60
|
-
[client_1.LENDING_MARKET_ID]: [
|
|
10
|
+
import { normalizeStructTag } from "@mysten/sui/utils";
|
|
11
|
+
import { SuiPriceServiceConnection } from "@pythnetwork/pyth-sui-js";
|
|
12
|
+
import BigNumber from "bignumber.js";
|
|
13
|
+
import { NORMALIZED_ALKIMI_COINTYPE, NORMALIZED_AUSD_COINTYPE, NORMALIZED_BLUE_COINTYPE, NORMALIZED_BUCK_COINTYPE, NORMALIZED_DEEP_COINTYPE, NORMALIZED_DMC_COINTYPE, NORMALIZED_FUD_COINTYPE, NORMALIZED_HAEDAL_COINTYPE, NORMALIZED_HIPPO_COINTYPE, NORMALIZED_IKA_COINTYPE, NORMALIZED_KOBAN_COINTYPE, NORMALIZED_LBTC_COINTYPE, NORMALIZED_NS_COINTYPE, NORMALIZED_SEND_COINTYPE, NORMALIZED_SEND_POINTS_S1_COINTYPE, NORMALIZED_SEND_POINTS_S2_COINTYPE, NORMALIZED_SOL_COINTYPE, NORMALIZED_SUI_COINTYPE, NORMALIZED_UP_COINTYPE, NORMALIZED_USDB_COINTYPE, NORMALIZED_USDC_COINTYPE, NORMALIZED_WAL_COINTYPE, NORMALIZED_WBTC_COINTYPE, NORMALIZED_WETH_COINTYPE, NORMALIZED_XAUm_COINTYPE, NORMALIZED_eTHIRD_COINTYPE, NORMALIZED_flSUI_COINTYPE, NORMALIZED_fpSUI_COINTYPE, NORMALIZED_fudSUI_COINTYPE, NORMALIZED_iSUI_COINTYPE, NORMALIZED_jugSUI_COINTYPE, NORMALIZED_kSUI_COINTYPE, NORMALIZED_mSUI_COINTYPE, NORMALIZED_mUSD_COINTYPE, NORMALIZED_oshiSUI_COINTYPE, NORMALIZED_sSUI_COINTYPE, NORMALIZED_sdeUSD_COINTYPE, NORMALIZED_stratSUI_COINTYPE, NORMALIZED_suiETH_COINTYPE, NORMALIZED_suiUSDT_COINTYPE, NORMALIZED_suiUSDe_COINTYPE, NORMALIZED_suiWBTC_COINTYPE, NORMALIZED_trevinSUI_COINTYPE, NORMALIZED_upSUI_COINTYPE, NORMALIZED_wUSDC_COINTYPE, NORMALIZED_wUSDT_COINTYPE, NORMALIZED_xBTC_COINTYPE, NORMALIZED_yapSUI_COINTYPE, TEMPORARY_PYTH_PRICE_FEED_COINTYPES, getAllOwnedObjects, getCoinMetadataMap, getPrice, isSendPoints, isSteammPoints, } from "@suilend/sui-fe";
|
|
14
|
+
import { LENDING_MARKET_ID, SuilendClient } from "../client";
|
|
15
|
+
import { parseLendingMarket, parseObligation } from "../parsers";
|
|
16
|
+
import * as simulate from "../utils/simulate";
|
|
17
|
+
import { WAD } from "./constants";
|
|
18
|
+
import { getWorkingPythEndpoint } from "./pyth";
|
|
19
|
+
import { STRATEGY_WRAPPER_PACKAGE_ID_V1, } from "./strategyOwnerCap";
|
|
20
|
+
export const RESERVES_CUSTOM_ORDER = {
|
|
21
|
+
[LENDING_MARKET_ID]: [
|
|
61
22
|
// MAIN ASSETS
|
|
62
|
-
|
|
23
|
+
NORMALIZED_sSUI_COINTYPE,
|
|
63
24
|
// MAIN ASSETS - Ecosystem LSTs
|
|
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
|
-
|
|
25
|
+
NORMALIZED_mSUI_COINTYPE,
|
|
26
|
+
NORMALIZED_fudSUI_COINTYPE,
|
|
27
|
+
NORMALIZED_kSUI_COINTYPE,
|
|
28
|
+
NORMALIZED_trevinSUI_COINTYPE,
|
|
29
|
+
NORMALIZED_upSUI_COINTYPE,
|
|
30
|
+
NORMALIZED_yapSUI_COINTYPE,
|
|
31
|
+
NORMALIZED_iSUI_COINTYPE,
|
|
32
|
+
NORMALIZED_flSUI_COINTYPE,
|
|
33
|
+
NORMALIZED_oshiSUI_COINTYPE,
|
|
34
|
+
NORMALIZED_jugSUI_COINTYPE,
|
|
35
|
+
NORMALIZED_stratSUI_COINTYPE,
|
|
36
|
+
NORMALIZED_fpSUI_COINTYPE,
|
|
37
|
+
NORMALIZED_SUI_COINTYPE,
|
|
38
|
+
NORMALIZED_USDC_COINTYPE,
|
|
39
|
+
NORMALIZED_wUSDC_COINTYPE,
|
|
40
|
+
NORMALIZED_suiUSDT_COINTYPE,
|
|
41
|
+
NORMALIZED_wUSDT_COINTYPE,
|
|
42
|
+
NORMALIZED_suiUSDe_COINTYPE,
|
|
43
|
+
NORMALIZED_AUSD_COINTYPE,
|
|
44
|
+
NORMALIZED_LBTC_COINTYPE,
|
|
45
|
+
NORMALIZED_suiWBTC_COINTYPE,
|
|
46
|
+
NORMALIZED_WBTC_COINTYPE,
|
|
47
|
+
NORMALIZED_xBTC_COINTYPE,
|
|
48
|
+
NORMALIZED_suiETH_COINTYPE,
|
|
49
|
+
NORMALIZED_WETH_COINTYPE,
|
|
50
|
+
NORMALIZED_SOL_COINTYPE,
|
|
51
|
+
NORMALIZED_DEEP_COINTYPE,
|
|
52
|
+
NORMALIZED_WAL_COINTYPE,
|
|
91
53
|
// ISOLATED ASSETS
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
54
|
+
NORMALIZED_SEND_COINTYPE,
|
|
55
|
+
NORMALIZED_IKA_COINTYPE,
|
|
56
|
+
NORMALIZED_HAEDAL_COINTYPE,
|
|
57
|
+
NORMALIZED_BLUE_COINTYPE,
|
|
58
|
+
NORMALIZED_NS_COINTYPE,
|
|
59
|
+
NORMALIZED_UP_COINTYPE,
|
|
60
|
+
NORMALIZED_DMC_COINTYPE,
|
|
61
|
+
NORMALIZED_ALKIMI_COINTYPE,
|
|
62
|
+
NORMALIZED_KOBAN_COINTYPE,
|
|
63
|
+
NORMALIZED_mUSD_COINTYPE,
|
|
64
|
+
NORMALIZED_BUCK_COINTYPE,
|
|
65
|
+
NORMALIZED_HIPPO_COINTYPE,
|
|
66
|
+
NORMALIZED_FUD_COINTYPE,
|
|
67
|
+
],
|
|
68
|
+
"0x74d92cb095b618f344486f77bcce87fbffc0fe0b46584bb1828bb291a222dda8": [
|
|
69
|
+
NORMALIZED_eTHIRD_COINTYPE,
|
|
70
|
+
NORMALIZED_USDC_COINTYPE,
|
|
105
71
|
],
|
|
106
72
|
"0x8a8d8e138a28de1c637d0b0955e621b017da7010de388db5a18493eca99c5e82": [
|
|
107
|
-
|
|
108
|
-
|
|
73
|
+
NORMALIZED_XAUm_COINTYPE,
|
|
74
|
+
NORMALIZED_USDC_COINTYPE,
|
|
109
75
|
],
|
|
110
76
|
// "0xc1549fd5db74c3aad37a260c9fd251d93d6f2f3ccfacc277398a57718c275a17": [
|
|
111
77
|
// NORMALIZED_SEND_COINTYPE,
|
|
112
78
|
// NORMALIZED_USDC_COINTYPE,
|
|
113
79
|
// ],
|
|
114
80
|
"0xd12df5fede59f1ac5e1f8413bc86bd6bc77fff2001366878df58ef6a26d58c67": [
|
|
115
|
-
|
|
116
|
-
|
|
81
|
+
NORMALIZED_USDB_COINTYPE,
|
|
82
|
+
NORMALIZED_USDC_COINTYPE,
|
|
117
83
|
],
|
|
118
84
|
"0x0d3a7f758d19d11e8526f66cca43403a99da16862c570c43efe0f8c4a500f7f2": [
|
|
119
|
-
|
|
120
|
-
|
|
85
|
+
NORMALIZED_sdeUSD_COINTYPE,
|
|
86
|
+
NORMALIZED_USDC_COINTYPE,
|
|
121
87
|
],
|
|
122
88
|
};
|
|
123
89
|
const MAYA_COINTYPE = "0x3bf0aeb7b9698b18ec7937290a5701088fcd5d43ad11a2564b074d022a6d71ec::maya::MAYA";
|
|
124
90
|
const mPOINTS_COINTYPE = "0x7bae0b3b7b6c3da899fe3f4af95b7110633499c02b8c6945110d799d99deaa68::mpoints::MPOINTS";
|
|
125
91
|
const TREATS_COINTYPE = "0x0dadb7fa2771c2952f96161fc1f0c105d1f22d53926b9ff2498a8eea2f6eb204::treats::TREATS";
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
const initializeSuilend = (suiClient, suilendClient, lendingMarketMetadata, fallbackPythEndpoint) => __awaiter(void 0, void 0, void 0, function* () {
|
|
92
|
+
export const NORMALIZED_MAYA_COINTYPE = normalizeStructTag(MAYA_COINTYPE);
|
|
93
|
+
export const NORMALIZED_mPOINTS_COINTYPE = normalizeStructTag(mPOINTS_COINTYPE);
|
|
94
|
+
export const NORMALIZED_TREATS_COINTYPE = normalizeStructTag(TREATS_COINTYPE);
|
|
95
|
+
export const initializeSuilend = (suiClient, suilendClient, lendingMarketMetadata, fallbackPythEndpoint) => __awaiter(void 0, void 0, void 0, function* () {
|
|
130
96
|
const nowMs = Date.now();
|
|
131
97
|
const nowS = Math.floor(nowMs / 1000);
|
|
132
98
|
const interestCompoundedRawReserves = suilendClient.lendingMarket.reserves.map((r) => simulate.compoundReserveInterest(r, nowS));
|
|
@@ -134,7 +100,7 @@ const initializeSuilend = (suiClient, suilendClient, lendingMarketMetadata, fall
|
|
|
134
100
|
const reservesWithoutTemporaryPythPriceFeeds = [];
|
|
135
101
|
const reservesWithTemporaryPythPriceFeeds = [];
|
|
136
102
|
for (const reserve of interestCompoundedRawReserves) {
|
|
137
|
-
if (
|
|
103
|
+
if (TEMPORARY_PYTH_PRICE_FEED_COINTYPES.includes(normalizeStructTag(reserve.coinType.name))) {
|
|
138
104
|
reservesWithTemporaryPythPriceFeeds.push(reserve);
|
|
139
105
|
}
|
|
140
106
|
else {
|
|
@@ -142,8 +108,8 @@ const initializeSuilend = (suiClient, suilendClient, lendingMarketMetadata, fall
|
|
|
142
108
|
}
|
|
143
109
|
}
|
|
144
110
|
// Get a working Pyth endpoint (try primary, fallback to fallbackPythEndpoint if provided)
|
|
145
|
-
const pythEndpoint = yield
|
|
146
|
-
const pythConnection = new
|
|
111
|
+
const pythEndpoint = yield getWorkingPythEndpoint(fallbackPythEndpoint);
|
|
112
|
+
const pythConnection = new SuiPriceServiceConnection(pythEndpoint, {
|
|
147
113
|
timeout: 30 * 1000,
|
|
148
114
|
});
|
|
149
115
|
const [refreshedReservesWithoutTemporaryPythPriceFeeds] = yield Promise.all([
|
|
@@ -151,16 +117,16 @@ const initializeSuilend = (suiClient, suilendClient, lendingMarketMetadata, fall
|
|
|
151
117
|
Promise.all(reservesWithTemporaryPythPriceFeeds.map((reserve) => (() => __awaiter(void 0, void 0, void 0, function* () {
|
|
152
118
|
let cachedUsdPrice;
|
|
153
119
|
try {
|
|
154
|
-
cachedUsdPrice = yield
|
|
120
|
+
cachedUsdPrice = yield getPrice(normalizeStructTag(reserve.coinType.name));
|
|
155
121
|
}
|
|
156
122
|
catch (err) {
|
|
157
123
|
console.error(err);
|
|
158
124
|
}
|
|
159
125
|
if (cachedUsdPrice === undefined)
|
|
160
126
|
cachedUsdPrice = 0.0001; // Non-zero price override if no price
|
|
161
|
-
const parsedCachedUsdPrice = BigInt(+new
|
|
162
|
-
.times(
|
|
163
|
-
.integerValue(
|
|
127
|
+
const parsedCachedUsdPrice = BigInt(+new BigNumber(cachedUsdPrice)
|
|
128
|
+
.times(WAD)
|
|
129
|
+
.integerValue(BigNumber.ROUND_DOWN));
|
|
164
130
|
reserve.price.value = parsedCachedUsdPrice;
|
|
165
131
|
reserve.smoothedPrice.value = parsedCachedUsdPrice;
|
|
166
132
|
}))())),
|
|
@@ -171,15 +137,15 @@ const initializeSuilend = (suiClient, suilendClient, lendingMarketMetadata, fall
|
|
|
171
137
|
...reservesWithTemporaryPythPriceFeeds,
|
|
172
138
|
];
|
|
173
139
|
const miscCoinTypes = [
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
140
|
+
NORMALIZED_SEND_POINTS_S1_COINTYPE,
|
|
141
|
+
NORMALIZED_SEND_POINTS_S2_COINTYPE,
|
|
142
|
+
NORMALIZED_SEND_COINTYPE,
|
|
177
143
|
];
|
|
178
144
|
const reserveCoinTypes = [];
|
|
179
145
|
const rewardCoinTypes = [];
|
|
180
146
|
const activeRewardCoinTypes = [];
|
|
181
147
|
refreshedRawReserves.forEach((r) => {
|
|
182
|
-
reserveCoinTypes.push(
|
|
148
|
+
reserveCoinTypes.push(normalizeStructTag(r.coinType.name));
|
|
183
149
|
[
|
|
184
150
|
...r.depositsPoolRewardManager.poolRewards,
|
|
185
151
|
...r.borrowsPoolRewardManager.poolRewards,
|
|
@@ -187,9 +153,9 @@ const initializeSuilend = (suiClient, suilendClient, lendingMarketMetadata, fall
|
|
|
187
153
|
if (!pr)
|
|
188
154
|
return;
|
|
189
155
|
const isActive = nowMs >= Number(pr.startTimeMs) && nowMs < Number(pr.endTimeMs);
|
|
190
|
-
rewardCoinTypes.push(
|
|
156
|
+
rewardCoinTypes.push(normalizeStructTag(pr.coinType.name));
|
|
191
157
|
if (isActive)
|
|
192
|
-
activeRewardCoinTypes.push(
|
|
158
|
+
activeRewardCoinTypes.push(normalizeStructTag(pr.coinType.name));
|
|
193
159
|
});
|
|
194
160
|
});
|
|
195
161
|
const uniqueMiscCoinTypes = Array.from(new Set(miscCoinTypes));
|
|
@@ -197,9 +163,9 @@ const initializeSuilend = (suiClient, suilendClient, lendingMarketMetadata, fall
|
|
|
197
163
|
const uniqueRewardCoinTypes = Array.from(new Set(rewardCoinTypes));
|
|
198
164
|
const uniqueActiveRewardsCoinTypes = Array.from(new Set(activeRewardCoinTypes));
|
|
199
165
|
const [miscCoinMetadataMap, reserveCoinMetadataMap, rewardCoinMetadataMap] = yield Promise.all([
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
166
|
+
getCoinMetadataMap(uniqueMiscCoinTypes),
|
|
167
|
+
getCoinMetadataMap(uniqueReserveCoinTypes),
|
|
168
|
+
getCoinMetadataMap(uniqueRewardCoinTypes),
|
|
203
169
|
]);
|
|
204
170
|
const coinMetadataMap = Object.assign(Object.assign(Object.assign({}, miscCoinMetadataMap), reserveCoinMetadataMap), rewardCoinMetadataMap);
|
|
205
171
|
// const walReserve = refreshedRawReserves.find(
|
|
@@ -212,11 +178,11 @@ const initializeSuilend = (suiClient, suilendClient, lendingMarketMetadata, fall
|
|
|
212
178
|
// (walReserve.price.value as bigint) = walPrice;
|
|
213
179
|
// (walReserve.smoothedPrice.value as bigint) = walPrice;
|
|
214
180
|
// }
|
|
215
|
-
const lendingMarket =
|
|
216
|
-
if (!!
|
|
181
|
+
const lendingMarket = parseLendingMarket(suilendClient.lendingMarket, refreshedRawReserves, coinMetadataMap, nowS, lendingMarketMetadata);
|
|
182
|
+
if (!!RESERVES_CUSTOM_ORDER[lendingMarket.id]) {
|
|
217
183
|
lendingMarket.reserves = lendingMarket.reserves.slice().sort((a, b) => {
|
|
218
|
-
const aCustomOrderIndex =
|
|
219
|
-
const bCustomOrderIndex =
|
|
184
|
+
const aCustomOrderIndex = RESERVES_CUSTOM_ORDER[lendingMarket.id].indexOf(a.coinType);
|
|
185
|
+
const bCustomOrderIndex = RESERVES_CUSTOM_ORDER[lendingMarket.id].indexOf(b.coinType);
|
|
220
186
|
if (aCustomOrderIndex > -1 && bCustomOrderIndex > -1)
|
|
221
187
|
return aCustomOrderIndex - bCustomOrderIndex;
|
|
222
188
|
else if (aCustomOrderIndex === -1 && bCustomOrderIndex === -1)
|
|
@@ -238,25 +204,23 @@ const initializeSuilend = (suiClient, suilendClient, lendingMarketMetadata, fall
|
|
|
238
204
|
rewardCoinMetadataMap,
|
|
239
205
|
};
|
|
240
206
|
});
|
|
241
|
-
|
|
242
|
-
const initializeSuilendRewards = (reserveMap, activeRewardCoinTypes) => __awaiter(void 0, void 0, void 0, function* () {
|
|
207
|
+
export const initializeSuilendRewards = (reserveMap, activeRewardCoinTypes) => __awaiter(void 0, void 0, void 0, function* () {
|
|
243
208
|
const rewardPriceMap = Object.entries(reserveMap).reduce((acc, [coinType, reserve]) => (Object.assign(Object.assign({}, acc), { [coinType]: reserve.price })), {});
|
|
244
|
-
rewardPriceMap[
|
|
245
|
-
const reservelessActiveRewardCoinTypes = activeRewardCoinTypes.filter((coinType) => !(
|
|
246
|
-
|
|
247
|
-
coinType ===
|
|
248
|
-
coinType ===
|
|
249
|
-
const reservelessActiveRewardCachedUsdPrices = yield Promise.all(reservelessActiveRewardCoinTypes.map((coinType) =>
|
|
209
|
+
rewardPriceMap[NORMALIZED_TREATS_COINTYPE] = new BigNumber(0.1);
|
|
210
|
+
const reservelessActiveRewardCoinTypes = activeRewardCoinTypes.filter((coinType) => !(isSendPoints(coinType) ||
|
|
211
|
+
isSteammPoints(coinType) ||
|
|
212
|
+
coinType === NORMALIZED_MAYA_COINTYPE ||
|
|
213
|
+
coinType === NORMALIZED_mPOINTS_COINTYPE) && !rewardPriceMap[coinType]);
|
|
214
|
+
const reservelessActiveRewardCachedUsdPrices = yield Promise.all(reservelessActiveRewardCoinTypes.map((coinType) => getPrice(coinType)));
|
|
250
215
|
for (let i = 0; i < reservelessActiveRewardCoinTypes.length; i++) {
|
|
251
216
|
const cachedUsdPrice = reservelessActiveRewardCachedUsdPrices[i];
|
|
252
217
|
if (cachedUsdPrice === undefined)
|
|
253
218
|
continue;
|
|
254
|
-
rewardPriceMap[reservelessActiveRewardCoinTypes[i]] = new
|
|
219
|
+
rewardPriceMap[reservelessActiveRewardCoinTypes[i]] = new BigNumber(cachedUsdPrice);
|
|
255
220
|
}
|
|
256
221
|
return { rewardPriceMap };
|
|
257
222
|
});
|
|
258
|
-
|
|
259
|
-
const initializeObligations = (suiClient, suilendClient, refreshedRawReserves, reserveMap, address) => __awaiter(void 0, void 0, void 0, function* () {
|
|
223
|
+
export const initializeObligations = (suiClient, suilendClient, refreshedRawReserves, reserveMap, address) => __awaiter(void 0, void 0, void 0, function* () {
|
|
260
224
|
if (!address)
|
|
261
225
|
return {
|
|
262
226
|
strategyOwnerCaps: [],
|
|
@@ -266,10 +230,10 @@ const initializeObligations = (suiClient, suilendClient, refreshedRawReserves, r
|
|
|
266
230
|
};
|
|
267
231
|
const [strategyOwnerCaps, obligationOwnerCaps] = yield Promise.all([
|
|
268
232
|
(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
269
|
-
if (suilendClient.lendingMarket.id !==
|
|
233
|
+
if (suilendClient.lendingMarket.id !== LENDING_MARKET_ID)
|
|
270
234
|
return []; // Only main lending market has strategy owner caps
|
|
271
|
-
const objects = yield
|
|
272
|
-
StructType: `${
|
|
235
|
+
const objects = yield getAllOwnedObjects(suiClient, address, {
|
|
236
|
+
StructType: `${STRATEGY_WRAPPER_PACKAGE_ID_V1}::strategy_wrapper::StrategyOwnerCap<${suilendClient.lendingMarket.$typeArgs[0]}>`,
|
|
273
237
|
});
|
|
274
238
|
return objects.map((obj) => {
|
|
275
239
|
var _a;
|
|
@@ -287,14 +251,14 @@ const initializeObligations = (suiClient, suilendClient, refreshedRawReserves, r
|
|
|
287
251
|
return result;
|
|
288
252
|
});
|
|
289
253
|
}))(),
|
|
290
|
-
|
|
254
|
+
SuilendClient.getObligationOwnerCaps(address, suilendClient.lendingMarket.$typeArgs, suiClient),
|
|
291
255
|
]);
|
|
292
256
|
const obligations = (yield Promise.all([
|
|
293
257
|
...strategyOwnerCaps.map((soc) => soc.obligationId),
|
|
294
258
|
...obligationOwnerCaps.map((ownerCap) => ownerCap.obligationId),
|
|
295
|
-
].map((obligationId) =>
|
|
259
|
+
].map((obligationId) => SuilendClient.getObligation(obligationId, suilendClient.lendingMarket.$typeArgs, suiClient))))
|
|
296
260
|
.map((rawObligation) => simulate.refreshObligation(rawObligation, refreshedRawReserves))
|
|
297
|
-
.map((refreshedObligation) =>
|
|
261
|
+
.map((refreshedObligation) => parseObligation(refreshedObligation, reserveMap, strategyOwnerCaps.some((soc) => soc.obligationId === refreshedObligation.id)))
|
|
298
262
|
.sort((a, b) => +b.netValueUsd.minus(a.netValueUsd));
|
|
299
263
|
// Divide into strategy and non-strategy
|
|
300
264
|
const strategyObligations = obligations.filter((o) => strategyOwnerCaps.some((soc) => soc.obligationId === o.id));
|
|
@@ -306,4 +270,3 @@ const initializeObligations = (suiClient, suilendClient, refreshedRawReserves, r
|
|
|
306
270
|
obligations: nonStrategyObligations,
|
|
307
271
|
};
|
|
308
272
|
});
|
|
309
|
-
exports.initializeObligations = initializeObligations;
|
package/lib/liquidityMining.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CoinMetadata } from "@mysten/sui/
|
|
1
|
+
import { CoinMetadata } from "@mysten/sui/jsonRpc";
|
|
2
2
|
import BigNumber from "bignumber.js";
|
|
3
3
|
import { ParsedObligation, ParsedReserve } from "../parsers";
|
|
4
4
|
import { RewardsMap, Side } from "./types";
|
|
@@ -51,10 +51,10 @@ export declare const getDedupedPerDayRewards: (filteredRewards: RewardSummary[])
|
|
|
51
51
|
export declare const getRewardsAprPercent: (side: Side, filteredRewards: RewardSummary[]) => BigNumber;
|
|
52
52
|
export declare const getStakingYieldAprPercent: (side: Side, coinType: string, lstStatsMap: Record<string, {
|
|
53
53
|
aprPercent: BigNumber;
|
|
54
|
-
}>,
|
|
54
|
+
}>, sdeUsdAprPercent: BigNumber | undefined, eThirdAprPercent: BigNumber | undefined) => BigNumber | undefined;
|
|
55
55
|
export declare const getTotalAprPercent: (side: Side, aprPercent: BigNumber, filteredRewards: RewardSummary[], stakingYieldAprPercent?: BigNumber) => BigNumber;
|
|
56
56
|
export declare const getNetAprPercent: (obligation: ParsedObligation, rewardMap: RewardMap, lstStatsMap: Record<string, {
|
|
57
57
|
aprPercent: BigNumber;
|
|
58
|
-
}>,
|
|
58
|
+
}>, sdeUsdAprPercent: BigNumber | undefined, eThirdAprPercent: BigNumber | undefined, noShares?: boolean) => BigNumber;
|
|
59
59
|
export declare const getRewardsMap: (obligation: ParsedObligation | undefined, rewardMap: RewardMap, coinMetadataMap: Record<string, CoinMetadata>) => RewardsMap;
|
|
60
60
|
export {};
|