@defisaver/positions-sdk 2.0.14-dev-portfolio → 2.0.14-dev-portfolio2
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/cjs/config/contracts.d.ts +14 -0
- package/cjs/config/contracts.js +1 -1
- package/cjs/contracts.d.ts +145 -0
- package/cjs/liquityV2/index.d.ts +27 -0
- package/cjs/liquityV2/index.js +136 -162
- package/cjs/morphoBlue/index.js +4 -3
- package/cjs/portfolio/index.js +39 -0
- package/esm/config/contracts.d.ts +14 -0
- package/esm/config/contracts.js +1 -1
- package/esm/contracts.d.ts +145 -0
- package/esm/liquityV2/index.d.ts +27 -0
- package/esm/liquityV2/index.js +137 -165
- package/esm/morphoBlue/index.js +4 -3
- package/esm/portfolio/index.js +40 -1
- package/package.json +1 -1
- package/src/config/contracts.ts +1 -1
- package/src/liquityV2/index.ts +226 -164
- package/src/morphoBlue/index.ts +4 -3
- package/src/portfolio/index.ts +39 -0
|
@@ -80330,6 +80330,20 @@ export declare const LiquityV2ActivePool: {
|
|
|
80330
80330
|
};
|
|
80331
80331
|
export declare const LiquityV2sBoldVault: {
|
|
80332
80332
|
readonly abi: readonly [{
|
|
80333
|
+
readonly inputs: readonly [{
|
|
80334
|
+
readonly internalType: "address";
|
|
80335
|
+
readonly name: "account";
|
|
80336
|
+
readonly type: "address";
|
|
80337
|
+
}];
|
|
80338
|
+
readonly name: "balanceOf";
|
|
80339
|
+
readonly outputs: readonly [{
|
|
80340
|
+
readonly internalType: "uint256";
|
|
80341
|
+
readonly name: "";
|
|
80342
|
+
readonly type: "uint256";
|
|
80343
|
+
}];
|
|
80344
|
+
readonly stateMutability: "view";
|
|
80345
|
+
readonly type: "function";
|
|
80346
|
+
}, {
|
|
80333
80347
|
readonly inputs: readonly [{
|
|
80334
80348
|
readonly internalType: "uint256";
|
|
80335
80349
|
readonly name: "assets";
|
package/cjs/config/contracts.js
CHANGED
|
@@ -1193,7 +1193,7 @@ exports.LiquityV2ActivePool = {
|
|
|
1193
1193
|
"networks": {}
|
|
1194
1194
|
};
|
|
1195
1195
|
exports.LiquityV2sBoldVault = {
|
|
1196
|
-
"abi": [{ "inputs": [{ "internalType": "uint256", "name": "assets", "type": "uint256" }], "name": "convertToShares", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "owner", "type": "address" }], "name": "maxWithdraw", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "name": "sps", "outputs": [{ "internalType": "address", "name": "sp", "type": "address" }, { "internalType": "uint96", "name": "weight", "type": "uint96" }, { "internalType": "address", "name": "coll", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "totalAssets", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }],
|
|
1196
|
+
"abi": [{ "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], "name": "balanceOf", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "assets", "type": "uint256" }], "name": "convertToShares", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "owner", "type": "address" }], "name": "maxWithdraw", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "name": "sps", "outputs": [{ "internalType": "address", "name": "sp", "type": "address" }, { "internalType": "uint96", "name": "weight", "type": "uint96" }, { "internalType": "address", "name": "coll", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "totalAssets", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "stateMutability": "view", "type": "function" }],
|
|
1197
1197
|
"networks": {
|
|
1198
1198
|
"1": {
|
|
1199
1199
|
"address": "0x50bd66d59911f5e086ec87ae43c811e0d059dd11"
|
package/cjs/contracts.d.ts
CHANGED
|
@@ -528167,7 +528167,96 @@ export declare const AaveRewardsControllerViem: (client: Client, network: Networ
|
|
|
528167
528167
|
};
|
|
528168
528168
|
export declare const LiquityV2sBoldVaultViem: (client: Client, network: NetworkNumber, block?: Blockish) => {
|
|
528169
528169
|
read: {
|
|
528170
|
+
balanceOf: (args: readonly [`0x${string}`], options?: import("viem").Prettify<import("viem").UnionOmit<import("viem").ReadContractParameters<readonly [{
|
|
528171
|
+
readonly inputs: readonly [{
|
|
528172
|
+
readonly internalType: "address";
|
|
528173
|
+
readonly name: "account";
|
|
528174
|
+
readonly type: "address";
|
|
528175
|
+
}];
|
|
528176
|
+
readonly name: "balanceOf";
|
|
528177
|
+
readonly outputs: readonly [{
|
|
528178
|
+
readonly internalType: "uint256";
|
|
528179
|
+
readonly name: "";
|
|
528180
|
+
readonly type: "uint256";
|
|
528181
|
+
}];
|
|
528182
|
+
readonly stateMutability: "view";
|
|
528183
|
+
readonly type: "function";
|
|
528184
|
+
}, {
|
|
528185
|
+
readonly inputs: readonly [{
|
|
528186
|
+
readonly internalType: "uint256";
|
|
528187
|
+
readonly name: "assets";
|
|
528188
|
+
readonly type: "uint256";
|
|
528189
|
+
}];
|
|
528190
|
+
readonly name: "convertToShares";
|
|
528191
|
+
readonly outputs: readonly [{
|
|
528192
|
+
readonly internalType: "uint256";
|
|
528193
|
+
readonly name: "";
|
|
528194
|
+
readonly type: "uint256";
|
|
528195
|
+
}];
|
|
528196
|
+
readonly stateMutability: "view";
|
|
528197
|
+
readonly type: "function";
|
|
528198
|
+
}, {
|
|
528199
|
+
readonly inputs: readonly [{
|
|
528200
|
+
readonly internalType: "address";
|
|
528201
|
+
readonly name: "owner";
|
|
528202
|
+
readonly type: "address";
|
|
528203
|
+
}];
|
|
528204
|
+
readonly name: "maxWithdraw";
|
|
528205
|
+
readonly outputs: readonly [{
|
|
528206
|
+
readonly internalType: "uint256";
|
|
528207
|
+
readonly name: "";
|
|
528208
|
+
readonly type: "uint256";
|
|
528209
|
+
}];
|
|
528210
|
+
readonly stateMutability: "view";
|
|
528211
|
+
readonly type: "function";
|
|
528212
|
+
}, {
|
|
528213
|
+
readonly inputs: readonly [{
|
|
528214
|
+
readonly internalType: "uint256";
|
|
528215
|
+
readonly name: "";
|
|
528216
|
+
readonly type: "uint256";
|
|
528217
|
+
}];
|
|
528218
|
+
readonly name: "sps";
|
|
528219
|
+
readonly outputs: readonly [{
|
|
528220
|
+
readonly internalType: "address";
|
|
528221
|
+
readonly name: "sp";
|
|
528222
|
+
readonly type: "address";
|
|
528223
|
+
}, {
|
|
528224
|
+
readonly internalType: "uint96";
|
|
528225
|
+
readonly name: "weight";
|
|
528226
|
+
readonly type: "uint96";
|
|
528227
|
+
}, {
|
|
528228
|
+
readonly internalType: "address";
|
|
528229
|
+
readonly name: "coll";
|
|
528230
|
+
readonly type: "address";
|
|
528231
|
+
}];
|
|
528232
|
+
readonly stateMutability: "view";
|
|
528233
|
+
readonly type: "function";
|
|
528234
|
+
}, {
|
|
528235
|
+
readonly inputs: readonly [];
|
|
528236
|
+
readonly name: "totalAssets";
|
|
528237
|
+
readonly outputs: readonly [{
|
|
528238
|
+
readonly internalType: "uint256";
|
|
528239
|
+
readonly name: "";
|
|
528240
|
+
readonly type: "uint256";
|
|
528241
|
+
}];
|
|
528242
|
+
readonly stateMutability: "view";
|
|
528243
|
+
readonly type: "function";
|
|
528244
|
+
}], "balanceOf", readonly [`0x${string}`]>, "address" | "args" | "abi" | "functionName">> | undefined) => Promise<bigint>;
|
|
528170
528245
|
maxWithdraw: (args: readonly [`0x${string}`], options?: import("viem").Prettify<import("viem").UnionOmit<import("viem").ReadContractParameters<readonly [{
|
|
528246
|
+
readonly inputs: readonly [{
|
|
528247
|
+
readonly internalType: "address";
|
|
528248
|
+
readonly name: "account";
|
|
528249
|
+
readonly type: "address";
|
|
528250
|
+
}];
|
|
528251
|
+
readonly name: "balanceOf";
|
|
528252
|
+
readonly outputs: readonly [{
|
|
528253
|
+
readonly internalType: "uint256";
|
|
528254
|
+
readonly name: "";
|
|
528255
|
+
readonly type: "uint256";
|
|
528256
|
+
}];
|
|
528257
|
+
readonly stateMutability: "view";
|
|
528258
|
+
readonly type: "function";
|
|
528259
|
+
}, {
|
|
528171
528260
|
readonly inputs: readonly [{
|
|
528172
528261
|
readonly internalType: "uint256";
|
|
528173
528262
|
readonly name: "assets";
|
|
@@ -528229,6 +528318,20 @@ export declare const LiquityV2sBoldVaultViem: (client: Client, network: NetworkN
|
|
|
528229
528318
|
readonly type: "function";
|
|
528230
528319
|
}], "maxWithdraw", readonly [`0x${string}`]>, "address" | "args" | "abi" | "functionName">> | undefined) => Promise<bigint>;
|
|
528231
528320
|
totalAssets: (options?: import("viem").Prettify<import("viem").UnionOmit<import("viem").ReadContractParameters<readonly [{
|
|
528321
|
+
readonly inputs: readonly [{
|
|
528322
|
+
readonly internalType: "address";
|
|
528323
|
+
readonly name: "account";
|
|
528324
|
+
readonly type: "address";
|
|
528325
|
+
}];
|
|
528326
|
+
readonly name: "balanceOf";
|
|
528327
|
+
readonly outputs: readonly [{
|
|
528328
|
+
readonly internalType: "uint256";
|
|
528329
|
+
readonly name: "";
|
|
528330
|
+
readonly type: "uint256";
|
|
528331
|
+
}];
|
|
528332
|
+
readonly stateMutability: "view";
|
|
528333
|
+
readonly type: "function";
|
|
528334
|
+
}, {
|
|
528232
528335
|
readonly inputs: readonly [{
|
|
528233
528336
|
readonly internalType: "uint256";
|
|
528234
528337
|
readonly name: "assets";
|
|
@@ -528290,6 +528393,20 @@ export declare const LiquityV2sBoldVaultViem: (client: Client, network: NetworkN
|
|
|
528290
528393
|
readonly type: "function";
|
|
528291
528394
|
}], "totalAssets", readonly []>, "address" | "args" | "abi" | "functionName">> | undefined) => Promise<bigint>;
|
|
528292
528395
|
convertToShares: (args: readonly [bigint], options?: import("viem").Prettify<import("viem").UnionOmit<import("viem").ReadContractParameters<readonly [{
|
|
528396
|
+
readonly inputs: readonly [{
|
|
528397
|
+
readonly internalType: "address";
|
|
528398
|
+
readonly name: "account";
|
|
528399
|
+
readonly type: "address";
|
|
528400
|
+
}];
|
|
528401
|
+
readonly name: "balanceOf";
|
|
528402
|
+
readonly outputs: readonly [{
|
|
528403
|
+
readonly internalType: "uint256";
|
|
528404
|
+
readonly name: "";
|
|
528405
|
+
readonly type: "uint256";
|
|
528406
|
+
}];
|
|
528407
|
+
readonly stateMutability: "view";
|
|
528408
|
+
readonly type: "function";
|
|
528409
|
+
}, {
|
|
528293
528410
|
readonly inputs: readonly [{
|
|
528294
528411
|
readonly internalType: "uint256";
|
|
528295
528412
|
readonly name: "assets";
|
|
@@ -528351,6 +528468,20 @@ export declare const LiquityV2sBoldVaultViem: (client: Client, network: NetworkN
|
|
|
528351
528468
|
readonly type: "function";
|
|
528352
528469
|
}], "convertToShares", readonly [bigint]>, "address" | "args" | "abi" | "functionName">> | undefined) => Promise<bigint>;
|
|
528353
528470
|
sps: (args: readonly [bigint], options?: import("viem").Prettify<import("viem").UnionOmit<import("viem").ReadContractParameters<readonly [{
|
|
528471
|
+
readonly inputs: readonly [{
|
|
528472
|
+
readonly internalType: "address";
|
|
528473
|
+
readonly name: "account";
|
|
528474
|
+
readonly type: "address";
|
|
528475
|
+
}];
|
|
528476
|
+
readonly name: "balanceOf";
|
|
528477
|
+
readonly outputs: readonly [{
|
|
528478
|
+
readonly internalType: "uint256";
|
|
528479
|
+
readonly name: "";
|
|
528480
|
+
readonly type: "uint256";
|
|
528481
|
+
}];
|
|
528482
|
+
readonly stateMutability: "view";
|
|
528483
|
+
readonly type: "function";
|
|
528484
|
+
}, {
|
|
528354
528485
|
readonly inputs: readonly [{
|
|
528355
528486
|
readonly internalType: "uint256";
|
|
528356
528487
|
readonly name: "assets";
|
|
@@ -528414,6 +528545,20 @@ export declare const LiquityV2sBoldVaultViem: (client: Client, network: NetworkN
|
|
|
528414
528545
|
};
|
|
528415
528546
|
address: `0x${string}`;
|
|
528416
528547
|
abi: readonly [{
|
|
528548
|
+
readonly inputs: readonly [{
|
|
528549
|
+
readonly internalType: "address";
|
|
528550
|
+
readonly name: "account";
|
|
528551
|
+
readonly type: "address";
|
|
528552
|
+
}];
|
|
528553
|
+
readonly name: "balanceOf";
|
|
528554
|
+
readonly outputs: readonly [{
|
|
528555
|
+
readonly internalType: "uint256";
|
|
528556
|
+
readonly name: "";
|
|
528557
|
+
readonly type: "uint256";
|
|
528558
|
+
}];
|
|
528559
|
+
readonly stateMutability: "view";
|
|
528560
|
+
readonly type: "function";
|
|
528561
|
+
}, {
|
|
528417
528562
|
readonly inputs: readonly [{
|
|
528418
528563
|
readonly internalType: "uint256";
|
|
528419
528564
|
readonly name: "assets";
|
package/cjs/liquityV2/index.d.ts
CHANGED
|
@@ -37,3 +37,30 @@ export declare const getLiquityV2TroveData: (provider: EthereumProvider, network
|
|
|
37
37
|
allMarketsData: Record<LiquityV2Versions, LiquityV2MarketData>;
|
|
38
38
|
}, fetchDebtInFront?: boolean) => Promise<LiquityV2TroveData>;
|
|
39
39
|
export declare const getLiquityV2ClaimableCollateral: (collSurplusPoolAddress: EthAddress, account: EthAddress, provider: EthereumProvider, network: NetworkNumber) => Promise<string>;
|
|
40
|
+
export type sBoldYieldParameters = {
|
|
41
|
+
WETH: string;
|
|
42
|
+
wsETH: string;
|
|
43
|
+
rETH: string;
|
|
44
|
+
};
|
|
45
|
+
export declare const getLiquityV2Staking: (provider: Client, network: NetworkNumber, market: LiquityV2Versions, user: EthAddress) => Promise<{
|
|
46
|
+
totalBOLDDeposited: string;
|
|
47
|
+
stakedBOLDBalance: string;
|
|
48
|
+
stabilityRewardColl: string;
|
|
49
|
+
stabilityRewardYield: string;
|
|
50
|
+
showStakingBalances: boolean;
|
|
51
|
+
debtTokenBalance: string;
|
|
52
|
+
stabilityPoolApy: string;
|
|
53
|
+
}>;
|
|
54
|
+
export declare const getLiquitySAndYBold: (provider: Client, network: NetworkNumber, markets: any, user: EthAddress) => Promise<{
|
|
55
|
+
spApy: string;
|
|
56
|
+
yBoldApy: string;
|
|
57
|
+
totalBoldDepositedSBold: string;
|
|
58
|
+
boldRateSBold: string;
|
|
59
|
+
maxWithdrawSBold: string;
|
|
60
|
+
totalBoldDepositedYBold: string;
|
|
61
|
+
boldRateYBold: string;
|
|
62
|
+
maxWithdrawYBold: string;
|
|
63
|
+
sBoldBalance: string;
|
|
64
|
+
yBoldBalance: string;
|
|
65
|
+
stYBoldBalance: string;
|
|
66
|
+
}>;
|
package/cjs/liquityV2/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.getLiquityV2ClaimableCollateral = exports.getLiquityV2TroveData = exports._getLiquityV2TroveData = exports.getDebtInFrontForInterestRateLiquityV2 = exports.getLiquityV2UserTroveIds = exports._getLiquityV2UserTroveIds = exports.getLiquityV2MarketData = exports._getLiquityV2MarketData = void 0;
|
|
15
|
+
exports.getLiquitySAndYBold = exports.getLiquityV2Staking = exports.getLiquityV2ClaimableCollateral = exports.getLiquityV2TroveData = exports._getLiquityV2TroveData = exports.getDebtInFrontForInterestRateLiquityV2 = exports.getLiquityV2UserTroveIds = exports._getLiquityV2UserTroveIds = exports.getLiquityV2MarketData = exports._getLiquityV2MarketData = void 0;
|
|
16
16
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
17
17
|
const tokens_1 = require("@defisaver/tokens");
|
|
18
18
|
const contracts_1 = require("../contracts");
|
|
@@ -300,164 +300,138 @@ const getLiquityV2ClaimableCollateral = (collSurplusPoolAddress, account, provid
|
|
|
300
300
|
return claimableCollateral.toString();
|
|
301
301
|
});
|
|
302
302
|
exports.getLiquityV2ClaimableCollateral = getLiquityV2ClaimableCollateral;
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
//
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
// P: P.toString(),
|
|
439
|
-
// currentScale: currentScale.toString(),
|
|
440
|
-
// yieldGainsPending: yieldGainsPending.toString(),
|
|
441
|
-
// totalBoldDeposits: totalBoldDeposits.toString(),
|
|
442
|
-
// };
|
|
443
|
-
//
|
|
444
|
-
// const stabilityPoolApy = calculateStabilityPoolApy(stabilityPoolYieldParams);
|
|
445
|
-
//
|
|
446
|
-
// const stakedBOLDBalanceForUser = getEthAmountForDecimals(compoundedBoldDeposit.toString(), 18);
|
|
447
|
-
// const stabilityRewardCollForUser = getEthAmountForDecimals(stabilityRewardColl.toString(), 18);
|
|
448
|
-
// const stabilityRewardYieldForUser = getEthAmountForDecimals(stabilityRewardYield.toString(), 18);
|
|
449
|
-
//
|
|
450
|
-
// const accountData = {
|
|
451
|
-
// totalBOLDDeposited: getEthAmountForDecimals(totalBoldDeposits.toString(), 18),
|
|
452
|
-
// stakedBOLDBalance: stakedBOLDBalanceForUser,
|
|
453
|
-
// stabilityRewardColl: stabilityRewardCollForUser,
|
|
454
|
-
// stabilityRewardYield: stabilityRewardYieldForUser,
|
|
455
|
-
// showStakingBalances: !!(+stakedBOLDBalanceForUser || +stabilityRewardCollForUser || +stabilityRewardYieldForUser),
|
|
456
|
-
// debtTokenBalance: getEthAmountForDecimals(debtTokenBalance.toString(), debtTokenInfo.decimals),
|
|
457
|
-
// };
|
|
458
|
-
//
|
|
459
|
-
//
|
|
460
|
-
// const yBoldApy = await getYBoldApyApi();
|
|
461
|
-
//
|
|
462
|
-
// return yBoldApy;
|
|
463
|
-
// };
|
|
303
|
+
const stabilityPoolAddrForMarket = {
|
|
304
|
+
[types_1.LiquityV2Versions.LiquityV2Eth]: '0x5721cbbd64fc7Ae3Ef44A0A3F9a790A9264Cf9BF',
|
|
305
|
+
[types_1.LiquityV2Versions.LiquityV2WstEth]: '0x9502b7c397e9aa22fe9db7ef7daf21cd2aebe56b',
|
|
306
|
+
[types_1.LiquityV2Versions.LiquityV2REth]: '0xd442e41019b7f5c4dd78f50dc03726c446148695',
|
|
307
|
+
[types_1.LiquityV2Versions.LiquityV2EthLegacy]: '0x',
|
|
308
|
+
[types_1.LiquityV2Versions.LiquityV2REthLegacy]: '0x',
|
|
309
|
+
[types_1.LiquityV2Versions.LiquityV2WstEthLegacy]: '0x',
|
|
310
|
+
};
|
|
311
|
+
const activePoolAddrForMarket = {
|
|
312
|
+
[types_1.LiquityV2Versions.LiquityV2Eth]: '0xeB5A8C825582965f1d84606E078620a84ab16AfE',
|
|
313
|
+
[types_1.LiquityV2Versions.LiquityV2WstEth]: '0x531a8f99c70d6a56a7cee02d6b4281650d7919a0',
|
|
314
|
+
[types_1.LiquityV2Versions.LiquityV2REth]: '0x9074d72cc82dad1e13e454755aa8f144c479532f',
|
|
315
|
+
[types_1.LiquityV2Versions.LiquityV2EthLegacy]: '0x',
|
|
316
|
+
[types_1.LiquityV2Versions.LiquityV2WstEthLegacy]: '0x',
|
|
317
|
+
[types_1.LiquityV2Versions.LiquityV2REthLegacy]: '0x',
|
|
318
|
+
};
|
|
319
|
+
function ceilDiv(a, b) {
|
|
320
|
+
return new decimal_js_1.default(a).add(new decimal_js_1.default(b).sub(1)).div(b).toString();
|
|
321
|
+
}
|
|
322
|
+
const SP_YIELD_SPLIT = new decimal_js_1.default(75).mul(Math.pow(10, 16)).toString(); // 75%
|
|
323
|
+
const calcPendingSPYield = (aggWeightedDebtSum, lastAggUpdateTime, currentTime) => {
|
|
324
|
+
const a = new decimal_js_1.default(aggWeightedDebtSum).mul(new decimal_js_1.default(currentTime).sub(new decimal_js_1.default(lastAggUpdateTime))).toString();
|
|
325
|
+
const b = new decimal_js_1.default(constants_1.SECONDS_PER_YEAR).mul(1000).mul(1e18).toString();
|
|
326
|
+
return new decimal_js_1.default(ceilDiv(a, b)).mul(SP_YIELD_SPLIT).div(1e18).toString();
|
|
327
|
+
};
|
|
328
|
+
const calculateStabilityPoolApy = (spYieldGainParams) => {
|
|
329
|
+
const { aggWeightedDebtSum, totalBoldDeposits, lastAggUpdateTime, yieldGainsPending, } = spYieldGainParams;
|
|
330
|
+
if (new decimal_js_1.default(totalBoldDeposits).eq(0)) {
|
|
331
|
+
return '0';
|
|
332
|
+
}
|
|
333
|
+
const now = Date.now().toString();
|
|
334
|
+
const lastAggUpdateTimeScaled = new decimal_js_1.default(lastAggUpdateTime).mul(1000).toString();
|
|
335
|
+
const pendingSPYield = new decimal_js_1.default(calcPendingSPYield(aggWeightedDebtSum, lastAggUpdateTimeScaled, now)).add(yieldGainsPending).toString();
|
|
336
|
+
const annualizedYield = new decimal_js_1.default(pendingSPYield).mul(constants_1.SECONDS_PER_YEAR).mul(1000).div(new decimal_js_1.default(now).minus(lastAggUpdateTimeScaled))
|
|
337
|
+
.toString();
|
|
338
|
+
return new decimal_js_1.default(annualizedYield).div(totalBoldDeposits).mul(100).toString();
|
|
339
|
+
};
|
|
340
|
+
const getYBoldApyApi = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
341
|
+
const url = 'https://ydaemon.yearn.fi/1/vaults/0x23346B04a7f55b8760E5860AA5A77383D63491cD?strategiesDetails=withDetails&strategiesCondition=inQueue';
|
|
342
|
+
const yBoldData = yield fetch(url)
|
|
343
|
+
.then(res => res.json())
|
|
344
|
+
.catch(console.error);
|
|
345
|
+
return new decimal_js_1.default(yBoldData.apr.netAPR).mul(100).toString();
|
|
346
|
+
});
|
|
347
|
+
const calculateSPApy = (spYieldGainParams, spAPYs) => {
|
|
348
|
+
const { WETH, wsETH, rETH, } = spYieldGainParams;
|
|
349
|
+
const apy = new decimal_js_1.default(WETH).mul(spAPYs.apyEth).add(new decimal_js_1.default(wsETH).mul(spAPYs.apyWstEth)).add(new decimal_js_1.default(rETH).mul(spAPYs.apyREth))
|
|
350
|
+
.toString();
|
|
351
|
+
return apy;
|
|
352
|
+
};
|
|
353
|
+
const getLiquityV2Staking = (provider, network, market, user) => __awaiter(void 0, void 0, void 0, function* () {
|
|
354
|
+
const stabilityPoolView = (0, contracts_1.createViemContractFromConfigFunc)('LiquityV2StabilityPool', stabilityPoolAddrForMarket[market])(provider, network);
|
|
355
|
+
const activePoolView = (0, contracts_1.createViemContractFromConfigFunc)('LiquityV2ActivePool', activePoolAddrForMarket[market])(provider, network);
|
|
356
|
+
const debtTokenInfo = (0, tokens_1.getAssetInfo)((0, markets_1.LiquityV2Markets)(network)[market].debtToken, network);
|
|
357
|
+
const debtTokenContract = (0, contracts_1.createViemContractFromConfigFunc)('Erc20', debtTokenInfo.address)(provider, network);
|
|
358
|
+
const [stabilityRewardColl, stabilityRewardYield, compoundedBoldDeposit, totalBoldDeposits, P, currentScale, yieldGainsPending, debtTokenBalance, aggWeightedDebtSum, lastAggUpdateTime,] = yield Promise.all([
|
|
359
|
+
stabilityPoolView.read.getDepositorCollGain([user]),
|
|
360
|
+
stabilityPoolView.read.getDepositorYieldGain([user]),
|
|
361
|
+
stabilityPoolView.read.getCompoundedBoldDeposit([user]),
|
|
362
|
+
stabilityPoolView.read.getTotalBoldDeposits(),
|
|
363
|
+
stabilityPoolView.read.P(),
|
|
364
|
+
stabilityPoolView.read.currentScale(),
|
|
365
|
+
stabilityPoolView.read.getYieldGainsPending(),
|
|
366
|
+
debtTokenContract.read.balanceOf([user]),
|
|
367
|
+
activePoolView.read.aggWeightedDebtSum(),
|
|
368
|
+
activePoolView.read.lastAggUpdateTime(),
|
|
369
|
+
]);
|
|
370
|
+
const stabilityPoolYieldParams = {
|
|
371
|
+
aggWeightedDebtSum: aggWeightedDebtSum.toString(),
|
|
372
|
+
lastAggUpdateTime: lastAggUpdateTime.toString(),
|
|
373
|
+
P: P.toString(),
|
|
374
|
+
currentScale: currentScale.toString(),
|
|
375
|
+
yieldGainsPending: yieldGainsPending.toString(),
|
|
376
|
+
totalBoldDeposits: totalBoldDeposits.toString(),
|
|
377
|
+
};
|
|
378
|
+
const stabilityPoolApy = calculateStabilityPoolApy(stabilityPoolYieldParams);
|
|
379
|
+
const stakedBOLDBalanceForUser = (0, utils_1.getEthAmountForDecimals)(compoundedBoldDeposit.toString(), 18);
|
|
380
|
+
const stabilityRewardCollForUser = (0, utils_1.getEthAmountForDecimals)(stabilityRewardColl.toString(), 18);
|
|
381
|
+
const stabilityRewardYieldForUser = (0, utils_1.getEthAmountForDecimals)(stabilityRewardYield.toString(), 18);
|
|
382
|
+
return {
|
|
383
|
+
totalBOLDDeposited: (0, utils_1.getEthAmountForDecimals)(totalBoldDeposits.toString(), 18),
|
|
384
|
+
stakedBOLDBalance: stakedBOLDBalanceForUser,
|
|
385
|
+
stabilityRewardColl: stabilityRewardCollForUser,
|
|
386
|
+
stabilityRewardYield: stabilityRewardYieldForUser,
|
|
387
|
+
showStakingBalances: !!(+stakedBOLDBalanceForUser || +stabilityRewardCollForUser || +stabilityRewardYieldForUser),
|
|
388
|
+
debtTokenBalance: (0, utils_1.getEthAmountForDecimals)(debtTokenBalance.toString(), debtTokenInfo.decimals),
|
|
389
|
+
stabilityPoolApy,
|
|
390
|
+
};
|
|
391
|
+
});
|
|
392
|
+
exports.getLiquityV2Staking = getLiquityV2Staking;
|
|
393
|
+
const getLiquitySAndYBold = (provider, network, markets, user) => __awaiter(void 0, void 0, void 0, function* () {
|
|
394
|
+
const sBold = (0, contracts_1.LiquityV2sBoldVaultViem)(provider, network);
|
|
395
|
+
const yBold = (0, contracts_1.createViemContractFromConfigFunc)('Erc4626', '0x9F4330700a36B29952869fac9b33f45EEdd8A3d8')(provider, network);
|
|
396
|
+
const stYBold = (0, contracts_1.createViemContractFromConfigFunc)('Erc4626', '0x23346B04a7f55b8760E5860AA5A77383D63491cD')(provider, network);
|
|
397
|
+
const spAPYs = {
|
|
398
|
+
apyEth: markets[types_1.LiquityV2Versions.LiquityV2Eth].data.stabilityPoolApy,
|
|
399
|
+
apyWstEth: markets[types_1.LiquityV2Versions.LiquityV2WstEth].data.stabilityPoolApy,
|
|
400
|
+
apyREth: markets[types_1.LiquityV2Versions.LiquityV2REth].data.stabilityPoolApy,
|
|
401
|
+
};
|
|
402
|
+
const [sBoldTotalAssets, sBoldConvertToShares, sBoldMaxWithdraw, wethApy, wsETHApy, rETHApy, yBoldTotalAssets, yBoldMaxWithdraw, stYBoldConvertToShares, yBoldApy, sBoldBalance, yBoldBalance, stYBoldBalance,] = yield Promise.all([
|
|
403
|
+
sBold.read.totalAssets(),
|
|
404
|
+
sBold.read.convertToShares([BigInt(1e18)]),
|
|
405
|
+
sBold.read.maxWithdraw([user]),
|
|
406
|
+
sBold.read.sps([BigInt(0)]),
|
|
407
|
+
sBold.read.sps([BigInt(1)]),
|
|
408
|
+
sBold.read.sps([BigInt(2)]),
|
|
409
|
+
yBold.read.totalAssets(),
|
|
410
|
+
yBold.read.maxWithdraw([user]),
|
|
411
|
+
stYBold.read.convertToShares([BigInt(1e18)]),
|
|
412
|
+
getYBoldApyApi(),
|
|
413
|
+
sBold.read.balanceOf([user]),
|
|
414
|
+
yBold.read.balanceOf([user]),
|
|
415
|
+
stYBold.read.balanceOf([user]),
|
|
416
|
+
]);
|
|
417
|
+
const spMarketRes = {
|
|
418
|
+
WETH: new decimal_js_1.default(wethApy[1]).div(10000).toString(),
|
|
419
|
+
wsETH: new decimal_js_1.default(wsETHApy[1]).div(10000).toString(),
|
|
420
|
+
rETH: new decimal_js_1.default(rETHApy[1]).div(10000).toString(),
|
|
421
|
+
};
|
|
422
|
+
const spApy = calculateSPApy(spMarketRes, spAPYs);
|
|
423
|
+
return {
|
|
424
|
+
spApy,
|
|
425
|
+
yBoldApy,
|
|
426
|
+
totalBoldDepositedSBold: (0, tokens_1.assetAmountInEth)(sBoldTotalAssets.toString(), 'sBOLD'),
|
|
427
|
+
boldRateSBold: (0, tokens_1.assetAmountInEth)(sBoldConvertToShares.toString(), 'sBOLD'),
|
|
428
|
+
maxWithdrawSBold: (0, tokens_1.assetAmountInEth)(sBoldMaxWithdraw.toString(), 'sBOLD'),
|
|
429
|
+
totalBoldDepositedYBold: (0, tokens_1.assetAmountInEth)(yBoldTotalAssets.toString(), 'yBOLD'),
|
|
430
|
+
boldRateYBold: (0, tokens_1.assetAmountInEth)(stYBoldConvertToShares.toString(), 'yBOLD'),
|
|
431
|
+
maxWithdrawYBold: (0, tokens_1.assetAmountInEth)(yBoldMaxWithdraw.toString(), 'yBOLD'),
|
|
432
|
+
sBoldBalance: (0, tokens_1.assetAmountInEth)(sBoldBalance.toString(), 'sBOLD'),
|
|
433
|
+
yBoldBalance: (0, tokens_1.assetAmountInEth)(yBoldBalance.toString(), 'yBOLD'),
|
|
434
|
+
stYBoldBalance: (0, tokens_1.assetAmountInEth)(stYBoldBalance.toString(), 'yBOLD'),
|
|
435
|
+
};
|
|
436
|
+
});
|
|
437
|
+
exports.getLiquitySAndYBold = getLiquitySAndYBold;
|
package/cjs/morphoBlue/index.js
CHANGED
|
@@ -168,15 +168,16 @@ function _getMorphoBlueAccountData(provider, network, account, selectedMarket, m
|
|
|
168
168
|
]));
|
|
169
169
|
const usedAssets = {};
|
|
170
170
|
const loanTokenInfo = marketInfo.assetsData[marketInfo.loanToken];
|
|
171
|
+
const loanTokenSupplied = (0, tokens_1.assetAmountInEth)(loanInfo.suppliedInAssets.toString(), marketInfo.loanToken);
|
|
171
172
|
const loanTokenBorrowed = (0, tokens_1.assetAmountInEth)(loanInfo.borrowedInAssets.toString(), marketInfo.loanToken);
|
|
172
173
|
usedAssets[marketInfo.loanToken] = {
|
|
173
174
|
symbol: loanTokenInfo.symbol,
|
|
174
|
-
supplied:
|
|
175
|
+
supplied: loanTokenSupplied,
|
|
175
176
|
borrowed: loanTokenBorrowed,
|
|
176
|
-
isSupplied:
|
|
177
|
+
isSupplied: new decimal_js_1.default(loanInfo.suppliedInAssets.toString()).gt(0),
|
|
177
178
|
isBorrowed: new decimal_js_1.default(loanInfo.borrowedInAssets.toString()).gt(0),
|
|
178
179
|
collateral: false,
|
|
179
|
-
suppliedUsd:
|
|
180
|
+
suppliedUsd: new decimal_js_1.default(loanTokenSupplied).mul(loanTokenInfo.price).toString(),
|
|
180
181
|
borrowedUsd: new decimal_js_1.default(loanTokenBorrowed).mul(loanTokenInfo.price).toString(),
|
|
181
182
|
};
|
|
182
183
|
const collateralTokenInfo = marketInfo.assetsData[marketInfo.collateralToken];
|