@defisaver/positions-sdk 2.1.171 → 2.1.173
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 +1 -1
- package/cjs/config/contracts.js +1 -1
- package/cjs/liquityV2/index.js +7 -5
- package/esm/config/contracts.d.ts +1 -1
- package/esm/config/contracts.js +1 -1
- package/esm/liquityV2/index.js +8 -6
- package/package.json +1 -1
- package/src/config/contracts.ts +1 -1
- package/src/liquityV2/index.ts +8 -6
|
@@ -97848,7 +97848,7 @@ export declare const FluidView: {
|
|
|
97848
97848
|
readonly address: "0x27C0BAe2338cE28097122393faF90375B9395dd1";
|
|
97849
97849
|
};
|
|
97850
97850
|
readonly "42161": {
|
|
97851
|
-
readonly address: "
|
|
97851
|
+
readonly address: "0x7d80a45eFA1F9033D5390fC8A3Ccd26eF1C8463e";
|
|
97852
97852
|
};
|
|
97853
97853
|
};
|
|
97854
97854
|
};
|
package/cjs/config/contracts.js
CHANGED
|
@@ -1226,7 +1226,7 @@ exports.FluidView = {
|
|
|
1226
1226
|
"1": { "address": "0x0cBa1CD5F88D40CE1aCFF9927e8Fea1111bC643d" },
|
|
1227
1227
|
"8453": { "address": "0x6cd4D6af4F292817eA2A2311F099dF26cd015028" },
|
|
1228
1228
|
"9745": { "address": "0x27C0BAe2338cE28097122393faF90375B9395dd1" },
|
|
1229
|
-
"42161": { "address": "
|
|
1229
|
+
"42161": { "address": "0x7d80a45eFA1F9033D5390fC8A3Ccd26eF1C8463e" }
|
|
1230
1230
|
}
|
|
1231
1231
|
};
|
|
1232
1232
|
exports.McdGetCdps = {
|
package/cjs/liquityV2/index.js
CHANGED
|
@@ -14,6 +14,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.getLiquitySAndYBold = exports.getLiquityV2Staking = exports.getLiquityV2ClaimableCollateral = exports.getLiquityV2TroveData = exports._getLiquityV2TroveData = exports.getDebtInFrontForInterestRateLiquityV2 = exports.getDebtInFrontForInterestRateIncludingNewDebtLiquityV2 = exports.calculateDebtInFrontLiquityV2 = exports.getLiquityV2UserTroveIds = exports._getLiquityV2UserTroveIds = exports.nftContractCreationBlockMapping = exports.getLiquityV2MarketData = exports._getLiquityV2MarketData = void 0;
|
|
16
16
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
17
|
+
const memoizee_1 = __importDefault(require("memoizee"));
|
|
17
18
|
const tokens_1 = require("@defisaver/tokens");
|
|
18
19
|
const contracts_1 = require("../contracts");
|
|
19
20
|
const common_1 = require("../types/common");
|
|
@@ -392,19 +393,20 @@ const calculateStabilityPoolApy = (spYieldGainParams) => {
|
|
|
392
393
|
.toString();
|
|
393
394
|
return new decimal_js_1.default(annualizedYield).div(totalBoldDeposits).mul(100).toString();
|
|
394
395
|
};
|
|
395
|
-
const getYBoldApyApi = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
396
|
+
const getYBoldApyApi = (0, memoizee_1.default)(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
396
397
|
try {
|
|
397
398
|
const url = 'https://ydaemon.yearn.fi/1/vaults/0x23346B04a7f55b8760E5860AA5A77383D63491cD?strategiesDetails=withDetails&strategiesCondition=inQueue';
|
|
398
|
-
const
|
|
399
|
-
|
|
400
|
-
|
|
399
|
+
const response = yield fetch(url, { signal: AbortSignal.timeout(utils_1.DEFAULT_TIMEOUT) });
|
|
400
|
+
if (!response.ok)
|
|
401
|
+
throw new Error(`Failed to fetch yBold APY: ${response.status}`);
|
|
402
|
+
const yBoldData = yield response.json();
|
|
401
403
|
return new decimal_js_1.default(yBoldData.apr.netAPR).mul(100).toString();
|
|
402
404
|
}
|
|
403
405
|
catch (error) {
|
|
404
406
|
console.error('External API Failure: YBold ', error);
|
|
405
407
|
return '0';
|
|
406
408
|
}
|
|
407
|
-
});
|
|
409
|
+
}), { promise: true, maxAge: 2 * 60 * 1000 });
|
|
408
410
|
const calculateSPApy = (spYieldGainParams, spAPYs) => {
|
|
409
411
|
const { WETH, wsETH, rETH, } = spYieldGainParams;
|
|
410
412
|
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))
|
|
@@ -97848,7 +97848,7 @@ export declare const FluidView: {
|
|
|
97848
97848
|
readonly address: "0x27C0BAe2338cE28097122393faF90375B9395dd1";
|
|
97849
97849
|
};
|
|
97850
97850
|
readonly "42161": {
|
|
97851
|
-
readonly address: "
|
|
97851
|
+
readonly address: "0x7d80a45eFA1F9033D5390fC8A3Ccd26eF1C8463e";
|
|
97852
97852
|
};
|
|
97853
97853
|
};
|
|
97854
97854
|
};
|
package/esm/config/contracts.js
CHANGED
|
@@ -1221,7 +1221,7 @@ export const FluidView = {
|
|
|
1221
1221
|
"1": { "address": "0x0cBa1CD5F88D40CE1aCFF9927e8Fea1111bC643d" },
|
|
1222
1222
|
"8453": { "address": "0x6cd4D6af4F292817eA2A2311F099dF26cd015028" },
|
|
1223
1223
|
"9745": { "address": "0x27C0BAe2338cE28097122393faF90375B9395dd1" },
|
|
1224
|
-
"42161": { "address": "
|
|
1224
|
+
"42161": { "address": "0x7d80a45eFA1F9033D5390fC8A3Ccd26eF1C8463e" }
|
|
1225
1225
|
}
|
|
1226
1226
|
};
|
|
1227
1227
|
export const McdGetCdps = {
|
package/esm/liquityV2/index.js
CHANGED
|
@@ -8,13 +8,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
});
|
|
9
9
|
};
|
|
10
10
|
import Dec from 'decimal.js';
|
|
11
|
+
import memoize from 'memoizee';
|
|
11
12
|
import { assetAmountInEth, getAssetInfo } from '@defisaver/tokens';
|
|
12
13
|
import { createViemContractFromConfigFunc, LiquityV2LegacyViewContractViem, LiquityV2sBoldVaultViem, LiquityV2ViewContractViem, } from '../contracts';
|
|
13
14
|
import { IncentiveKind, NetworkNumber, } from '../types/common';
|
|
14
15
|
import { LIQUITY_V2_TROVE_STATUS_ENUM, LiquityV2Versions, } from '../types';
|
|
15
16
|
import { getStakingApy, STAKING_ASSETS } from '../staking';
|
|
16
17
|
import { getLiquityV2AggregatedPositionData } from '../helpers/liquityV2Helpers';
|
|
17
|
-
import { compareAddresses, ethToWeth, getEthAmountForDecimals, MAXUINT, } from '../services/utils';
|
|
18
|
+
import { compareAddresses, DEFAULT_TIMEOUT, ethToWeth, getEthAmountForDecimals, MAXUINT, } from '../services/utils';
|
|
18
19
|
import { SECONDS_PER_YEAR, ZERO_ADDRESS } from '../constants';
|
|
19
20
|
import { LiquityV2Markets } from '../markets';
|
|
20
21
|
import { getViemProvider } from '../services/viem';
|
|
@@ -376,19 +377,20 @@ const calculateStabilityPoolApy = (spYieldGainParams) => {
|
|
|
376
377
|
.toString();
|
|
377
378
|
return new Dec(annualizedYield).div(totalBoldDeposits).mul(100).toString();
|
|
378
379
|
};
|
|
379
|
-
const getYBoldApyApi = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
380
|
+
const getYBoldApyApi = memoize(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
380
381
|
try {
|
|
381
382
|
const url = 'https://ydaemon.yearn.fi/1/vaults/0x23346B04a7f55b8760E5860AA5A77383D63491cD?strategiesDetails=withDetails&strategiesCondition=inQueue';
|
|
382
|
-
const
|
|
383
|
-
|
|
384
|
-
|
|
383
|
+
const response = yield fetch(url, { signal: AbortSignal.timeout(DEFAULT_TIMEOUT) });
|
|
384
|
+
if (!response.ok)
|
|
385
|
+
throw new Error(`Failed to fetch yBold APY: ${response.status}`);
|
|
386
|
+
const yBoldData = yield response.json();
|
|
385
387
|
return new Dec(yBoldData.apr.netAPR).mul(100).toString();
|
|
386
388
|
}
|
|
387
389
|
catch (error) {
|
|
388
390
|
console.error('External API Failure: YBold ', error);
|
|
389
391
|
return '0';
|
|
390
392
|
}
|
|
391
|
-
});
|
|
393
|
+
}), { promise: true, maxAge: 2 * 60 * 1000 });
|
|
392
394
|
const calculateSPApy = (spYieldGainParams, spAPYs) => {
|
|
393
395
|
const { WETH, wsETH, rETH, } = spYieldGainParams;
|
|
394
396
|
const apy = new Dec(WETH).mul(spAPYs.apyEth).add(new Dec(wsETH).mul(spAPYs.apyWstEth)).add(new Dec(rETH).mul(spAPYs.apyREth))
|
package/package.json
CHANGED
package/src/config/contracts.ts
CHANGED
|
@@ -1223,7 +1223,7 @@ export const FluidView = {
|
|
|
1223
1223
|
"1": { "address": "0x0cBa1CD5F88D40CE1aCFF9927e8Fea1111bC643d" },
|
|
1224
1224
|
"8453": { "address": "0x6cd4D6af4F292817eA2A2311F099dF26cd015028" },
|
|
1225
1225
|
"9745": { "address": "0x27C0BAe2338cE28097122393faF90375B9395dd1" },
|
|
1226
|
-
"42161": { "address": "
|
|
1226
|
+
"42161": { "address": "0x7d80a45eFA1F9033D5390fC8A3Ccd26eF1C8463e" }
|
|
1227
1227
|
}
|
|
1228
1228
|
} as const;
|
|
1229
1229
|
export const McdGetCdps = {
|
package/src/liquityV2/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Dec from 'decimal.js';
|
|
2
|
+
import memoize from 'memoizee';
|
|
2
3
|
import { assetAmountInEth, getAssetInfo } from '@defisaver/tokens';
|
|
3
4
|
import { Client, PublicClient } from 'viem';
|
|
4
5
|
import {
|
|
@@ -19,6 +20,7 @@ import { getStakingApy, STAKING_ASSETS } from '../staking';
|
|
|
19
20
|
import { getLiquityV2AggregatedPositionData } from '../helpers/liquityV2Helpers';
|
|
20
21
|
import {
|
|
21
22
|
compareAddresses,
|
|
23
|
+
DEFAULT_TIMEOUT,
|
|
22
24
|
ethToWeth,
|
|
23
25
|
getEthAmountForDecimals,
|
|
24
26
|
MAXUINT,
|
|
@@ -546,20 +548,20 @@ const calculateStabilityPoolApy = (
|
|
|
546
548
|
return new Dec(annualizedYield).div(totalBoldDeposits).mul(100).toString();
|
|
547
549
|
};
|
|
548
550
|
|
|
549
|
-
const getYBoldApyApi = async () => {
|
|
551
|
+
const getYBoldApyApi = memoize(async () => {
|
|
550
552
|
try {
|
|
551
553
|
const url = 'https://ydaemon.yearn.fi/1/vaults/0x23346B04a7f55b8760E5860AA5A77383D63491cD?strategiesDetails=withDetails&strategiesCondition=inQueue';
|
|
552
554
|
|
|
553
|
-
const
|
|
554
|
-
|
|
555
|
-
|
|
555
|
+
const response = await fetch(url, { signal: AbortSignal.timeout(DEFAULT_TIMEOUT) });
|
|
556
|
+
if (!response.ok) throw new Error(`Failed to fetch yBold APY: ${response.status}`);
|
|
557
|
+
const yBoldData = await response.json();
|
|
556
558
|
|
|
557
559
|
return new Dec(yBoldData.apr.netAPR).mul(100).toString();
|
|
558
560
|
} catch (error) {
|
|
559
561
|
console.error('External API Failure: YBold ', error);
|
|
560
562
|
return '0';
|
|
561
563
|
}
|
|
562
|
-
};
|
|
564
|
+
}, { promise: true, maxAge: 2 * 60 * 1000 });
|
|
563
565
|
|
|
564
566
|
export type sBoldYieldParameters = {
|
|
565
567
|
WETH: string;
|
|
@@ -707,4 +709,4 @@ export const getLiquitySAndYBold = async (provider: Client, network: NetworkNumb
|
|
|
707
709
|
yBoldBalance: assetAmountInEth(yBoldBalance.toString(), 'yBOLD'),
|
|
708
710
|
stYBoldBalance: assetAmountInEth(stYBoldBalance.toString(), 'yBOLD'),
|
|
709
711
|
};
|
|
710
|
-
};
|
|
712
|
+
};
|