@defisaver/positions-sdk 0.0.201-fluid-dev-10 → 0.0.201-fluid-dev-12
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/aaveV2/index.js +1 -1
- package/cjs/config/contracts.d.ts +87 -6
- package/cjs/config/contracts.js +15 -2
- package/cjs/helpers/liquityV2Helpers/index.js +2 -2
- package/cjs/liquityV2/index.d.ts +9 -4
- package/cjs/liquityV2/index.js +69 -10
- package/cjs/markets/fluid/index.js +1 -1
- package/cjs/markets/index.d.ts +1 -1
- package/cjs/markets/index.js +2 -1
- package/cjs/markets/liquityV2/index.d.ts +2 -1
- package/cjs/markets/liquityV2/index.js +12 -1
- package/cjs/markets/spark/marketAssets.js +1 -1
- package/cjs/morphoAaveV2/index.js +1 -1
- package/cjs/morphoAaveV3/index.js +1 -2
- package/cjs/spark/index.js +1 -2
- package/cjs/staking/staking.d.ts +1 -6
- package/cjs/staking/staking.js +20 -23
- package/cjs/types/contracts/generated/LiquityV2StabilityPool.d.ts +223 -0
- package/cjs/types/contracts/generated/LiquityV2StabilityPool.js +5 -0
- package/cjs/types/contracts/generated/LiquityV2View.d.ts +144 -2
- package/cjs/types/contracts/generated/index.d.ts +1 -0
- package/cjs/types/liquityV2.d.ts +1 -0
- package/esm/aaveV2/index.js +2 -2
- package/esm/config/contracts.d.ts +87 -6
- package/esm/config/contracts.js +15 -2
- package/esm/helpers/liquityV2Helpers/index.js +2 -2
- package/esm/liquityV2/index.d.ts +9 -4
- package/esm/liquityV2/index.js +64 -10
- package/esm/markets/fluid/index.js +1 -1
- package/esm/markets/index.d.ts +1 -1
- package/esm/markets/index.js +1 -1
- package/esm/markets/liquityV2/index.d.ts +2 -1
- package/esm/markets/liquityV2/index.js +10 -0
- package/esm/markets/spark/marketAssets.js +1 -1
- package/esm/morphoAaveV2/index.js +2 -2
- package/esm/morphoAaveV3/index.js +1 -2
- package/esm/spark/index.js +1 -2
- package/esm/staking/staking.d.ts +1 -6
- package/esm/staking/staking.js +24 -22
- package/esm/types/contracts/generated/LiquityV2StabilityPool.d.ts +223 -0
- package/esm/types/contracts/generated/LiquityV2StabilityPool.js +4 -0
- package/esm/types/contracts/generated/LiquityV2View.d.ts +144 -2
- package/esm/types/contracts/generated/index.d.ts +1 -0
- package/esm/types/liquityV2.d.ts +1 -0
- package/package.json +2 -1
- package/src/aaveV2/index.ts +2 -2
- package/src/config/contracts.js +15 -2
- package/src/helpers/liquityV2Helpers/index.ts +3 -3
- package/src/liquityV2/index.ts +79 -12
- package/src/markets/fluid/index.ts +1 -1
- package/src/markets/index.ts +1 -1
- package/src/markets/liquityV2/index.ts +13 -2
- package/src/markets/spark/marketAssets.ts +1 -1
- package/src/morphoAaveV2/index.ts +2 -2
- package/src/morphoAaveV3/index.ts +1 -2
- package/src/spark/index.ts +1 -2
- package/src/staking/staking.ts +22 -22
- package/src/types/contracts/generated/LiquityV2StabilityPool.ts +453 -0
- package/src/types/contracts/generated/LiquityV2View.ts +173 -2
- package/src/types/contracts/generated/index.ts +1 -0
- package/src/types/liquityV2.ts +1 -0
- package/cjs/services/dsrService.d.ts +0 -3
- package/cjs/services/dsrService.js +0 -28
- package/esm/services/dsrService.d.ts +0 -3
- package/esm/services/dsrService.js +0 -21
- package/src/services/dsrService.ts +0 -16
package/cjs/markets/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getFTokenAddress = exports.getFluidMarketInfoById = exports.getFluidVersionsDataForNetwork = exports.FluidMarkets = exports.EulerV2Markets = exports.LiquityV2Markets = exports.LlamaLendMarkets = exports.findMorphoBlueMarket = exports.MorphoBlueMarkets = exports.CrvUsdMarkets = exports.SparkMarkets = exports.v3USDTCollAssets = exports.v3USDCeCollAssets = exports.v3USDCCollAssets = exports.v3USDbCCollAssets = exports.v3ETHCollAssets = exports.compoundV2CollateralAssets = exports.CompoundMarkets = exports.getAaveV3MarketByMarketAddress = exports.morphoAaveV3AssetEthMarket = exports.morphoAaveV2AssetDefaultMarket = exports.aaveV3AssetsDefaultMarket = exports.aaveV2AssetsDefaultMarket = exports.aaveV1AssetsDefaultMarket = exports.AaveMarkets = void 0;
|
|
3
|
+
exports.getFTokenAddress = exports.getFluidMarketInfoById = exports.getFluidVersionsDataForNetwork = exports.FluidMarkets = exports.EulerV2Markets = exports.findLiquityV2MarketByAddress = exports.LiquityV2Markets = exports.LlamaLendMarkets = exports.findMorphoBlueMarket = exports.MorphoBlueMarkets = exports.CrvUsdMarkets = exports.SparkMarkets = exports.v3USDTCollAssets = exports.v3USDCeCollAssets = exports.v3USDCCollAssets = exports.v3USDbCCollAssets = exports.v3ETHCollAssets = exports.compoundV2CollateralAssets = exports.CompoundMarkets = exports.getAaveV3MarketByMarketAddress = exports.morphoAaveV3AssetEthMarket = exports.morphoAaveV2AssetDefaultMarket = exports.aaveV3AssetsDefaultMarket = exports.aaveV2AssetsDefaultMarket = exports.aaveV1AssetsDefaultMarket = exports.AaveMarkets = void 0;
|
|
4
4
|
var aave_1 = require("./aave");
|
|
5
5
|
Object.defineProperty(exports, "AaveMarkets", { enumerable: true, get: function () { return aave_1.AaveMarkets; } });
|
|
6
6
|
Object.defineProperty(exports, "aaveV1AssetsDefaultMarket", { enumerable: true, get: function () { return aave_1.aaveV1AssetsDefaultMarket; } });
|
|
@@ -28,6 +28,7 @@ var llamaLend_1 = require("./llamaLend");
|
|
|
28
28
|
Object.defineProperty(exports, "LlamaLendMarkets", { enumerable: true, get: function () { return llamaLend_1.LlamaLendMarkets; } });
|
|
29
29
|
var liquityV2_1 = require("./liquityV2");
|
|
30
30
|
Object.defineProperty(exports, "LiquityV2Markets", { enumerable: true, get: function () { return liquityV2_1.LiquityV2Markets; } });
|
|
31
|
+
Object.defineProperty(exports, "findLiquityV2MarketByAddress", { enumerable: true, get: function () { return liquityV2_1.findLiquityV2MarketByAddress; } });
|
|
31
32
|
var euler_1 = require("./euler");
|
|
32
33
|
Object.defineProperty(exports, "EulerV2Markets", { enumerable: true, get: function () { return euler_1.EulerV2Markets; } });
|
|
33
34
|
var fluid_1 = require("./fluid");
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { NetworkNumber } from '../../types/common';
|
|
1
|
+
import { EthAddress, NetworkNumber } from '../../types/common';
|
|
2
2
|
import { LiquityV2MarketInfo } from '../../types/liquityV2';
|
|
3
3
|
export declare const LIQUITY_V2_ETH_MARKET: (networkId?: NetworkNumber) => LiquityV2MarketInfo;
|
|
4
4
|
export declare const LIQUITY_V2_WSTETH_MARKET: (networkId?: NetworkNumber) => LiquityV2MarketInfo;
|
|
@@ -8,3 +8,4 @@ export declare const LiquityV2Markets: (networkId: NetworkNumber) => {
|
|
|
8
8
|
readonly liquityv2wsteth: LiquityV2MarketInfo;
|
|
9
9
|
readonly liquityv2reth: LiquityV2MarketInfo;
|
|
10
10
|
};
|
|
11
|
+
export declare const findLiquityV2MarketByAddress: (marketAddress: EthAddress) => LiquityV2MarketInfo | null;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LiquityV2Markets = exports.LIQUITY_V2_RETH_MARKET = exports.LIQUITY_V2_WSTETH_MARKET = exports.LIQUITY_V2_ETH_MARKET = void 0;
|
|
3
|
+
exports.findLiquityV2MarketByAddress = exports.LiquityV2Markets = exports.LIQUITY_V2_RETH_MARKET = exports.LIQUITY_V2_WSTETH_MARKET = exports.LIQUITY_V2_ETH_MARKET = void 0;
|
|
4
|
+
const utils_1 = require("../../services/utils");
|
|
4
5
|
const common_1 = require("../../types/common");
|
|
5
6
|
const liquityV2_1 = require("../../types/liquityV2");
|
|
6
7
|
const LIQUITY_V2_ETH_MARKET = (networkId = common_1.NetworkNumber.Eth) => ({
|
|
@@ -45,3 +46,13 @@ const LiquityV2Markets = (networkId) => ({
|
|
|
45
46
|
[liquityV2_1.LiquityV2Versions.LiquityV2REth]: (0, exports.LIQUITY_V2_RETH_MARKET)(networkId),
|
|
46
47
|
});
|
|
47
48
|
exports.LiquityV2Markets = LiquityV2Markets;
|
|
49
|
+
const findLiquityV2MarketByAddress = (marketAddress) => {
|
|
50
|
+
const markets = (0, exports.LiquityV2Markets)(common_1.NetworkNumber.Eth);
|
|
51
|
+
for (const market of Object.values(markets)) {
|
|
52
|
+
if ((0, utils_1.compareAddresses)(market.marketAddress, marketAddress)) {
|
|
53
|
+
return market;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return null;
|
|
57
|
+
};
|
|
58
|
+
exports.findLiquityV2MarketByAddress = findLiquityV2MarketByAddress;
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sparkAssetsDefaultMarket = exports.sparkAssetsDefaultMarketEth = void 0;
|
|
4
4
|
const common_1 = require("../../types/common");
|
|
5
|
-
exports.sparkAssetsDefaultMarketEth = ['DAI', 'sDAI', 'USDC', 'ETH', 'wstETH', 'WBTC', 'GNO', 'rETH', 'USDT', 'weETH', 'cbBTC', 'sUSDS'];
|
|
5
|
+
exports.sparkAssetsDefaultMarketEth = ['DAI', 'sDAI', 'USDC', 'ETH', 'wstETH', 'WBTC', 'GNO', 'rETH', 'USDT', 'weETH', 'cbBTC', 'sUSDS', 'USDS'];
|
|
6
6
|
// @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
|
|
7
7
|
exports.sparkAssetsDefaultMarket = {
|
|
8
8
|
[common_1.NetworkNumber.Eth]: exports.sparkAssetsDefaultMarketEth,
|
|
@@ -93,7 +93,7 @@ const getMorphoAaveV2MarketsData = (web3, network, mainnetWeb3) => __awaiter(voi
|
|
|
93
93
|
});
|
|
94
94
|
const stEthMarket = assetsData.find(({ symbol }) => symbol === 'stETH');
|
|
95
95
|
if (stEthMarket) {
|
|
96
|
-
stEthMarket.incentiveSupplyApy = yield (0, staking_1.
|
|
96
|
+
stEthMarket.incentiveSupplyApy = yield (0, staking_1.getStakingApy)('stETH', mainnetWeb3);
|
|
97
97
|
stEthMarket.incentiveSupplyToken = 'stETH';
|
|
98
98
|
}
|
|
99
99
|
const payload = {};
|
|
@@ -23,7 +23,6 @@ const utils_1 = require("../services/utils");
|
|
|
23
23
|
const contracts_1 = require("../contracts");
|
|
24
24
|
const multicall_1 = require("../multicall");
|
|
25
25
|
const staking_1 = require("../staking");
|
|
26
|
-
const dsrService_1 = require("../services/dsrService");
|
|
27
26
|
const moneymarket_1 = require("../moneymarket");
|
|
28
27
|
const aaveV3_1 = require("../aaveV3");
|
|
29
28
|
const aaveHelpers_1 = require("../helpers/aaveHelpers");
|
|
@@ -239,7 +238,7 @@ const getMorphoAaveV3MarketsData = (web3, network, selectedMarket, mainnetWeb3)
|
|
|
239
238
|
data.incentiveSupplyToken = data.symbol;
|
|
240
239
|
}
|
|
241
240
|
if (data.symbol === 'sDAI') {
|
|
242
|
-
data.incentiveSupplyApy = yield (0,
|
|
241
|
+
data.incentiveSupplyApy = yield (0, staking_1.getStakingApy)('sDAI', mainnetWeb3);
|
|
243
242
|
data.incentiveSupplyToken = 'sDAI';
|
|
244
243
|
}
|
|
245
244
|
return data;
|
package/cjs/spark/index.js
CHANGED
|
@@ -17,7 +17,6 @@ const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
|
17
17
|
const tokens_1 = require("@defisaver/tokens");
|
|
18
18
|
const utils_1 = require("../services/utils");
|
|
19
19
|
const staking_1 = require("../staking");
|
|
20
|
-
const dsrService_1 = require("../services/dsrService");
|
|
21
20
|
const contracts_1 = require("../contracts");
|
|
22
21
|
const multicall_1 = require("../multicall");
|
|
23
22
|
const sparkHelpers_1 = require("../helpers/sparkHelpers");
|
|
@@ -138,7 +137,7 @@ const getSparkMarketsData = (web3, network, selectedMarket, mainnetWeb3) => __aw
|
|
|
138
137
|
});
|
|
139
138
|
}
|
|
140
139
|
if (market.symbol === 'sDAI') {
|
|
141
|
-
market.incentiveSupplyApy = yield (0,
|
|
140
|
+
market.incentiveSupplyApy = yield (0, staking_1.getStakingApy)('sDAI', mainnetWeb3);
|
|
142
141
|
market.incentiveSupplyToken = 'sDAI';
|
|
143
142
|
}
|
|
144
143
|
if (market.canBeBorrowed && market.incentiveSupplyApy) {
|
package/cjs/staking/staking.d.ts
CHANGED
|
@@ -1,12 +1,7 @@
|
|
|
1
1
|
import Web3 from 'web3';
|
|
2
2
|
import { MMAssetsData, MMUsedAssets } from '../types/common';
|
|
3
|
-
export declare const getStETHApy: (web3: Web3, fromBlock?: number, blockNumber?: 'latest' | number) => Promise<string>;
|
|
4
|
-
export declare const getCbETHApy: (web3: Web3, blockNumber?: 'latest' | number) => Promise<string>;
|
|
5
|
-
export declare const getREthApy: (web3: Web3, blockNumber?: 'latest' | number) => Promise<string>;
|
|
6
|
-
export declare const getDsrApy: (web3: Web3, blockNumber?: 'latest' | number) => Promise<string>;
|
|
7
|
-
export declare const getSsrApy: () => Promise<string>;
|
|
8
3
|
export declare const STAKING_ASSETS: string[];
|
|
9
|
-
export declare const getStakingApy: (asset: string, web3: Web3, blockNumber?: 'latest' | number, fromBlock?: number | undefined) =>
|
|
4
|
+
export declare const getStakingApy: (asset: string, web3: Web3, blockNumber?: 'latest' | number, fromBlock?: number | undefined) => Promise<string>;
|
|
10
5
|
export declare const calculateInterestEarned: (principal: string, interest: string, type: string, apy?: boolean) => number;
|
|
11
6
|
export declare const calculateNetApy: ({ usedAssets, assetsData, isMorpho }: {
|
|
12
7
|
usedAssets: MMUsedAssets;
|
package/cjs/staking/staking.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.getStETHByWstETHMultiple = exports.getStETHByWstETH = exports.getWstETHByStETH = exports.calculateNetApy = exports.calculateInterestEarned = exports.getStakingApy = exports.STAKING_ASSETS =
|
|
15
|
+
exports.getStETHByWstETHMultiple = exports.getStETHByWstETH = exports.getWstETHByStETH = exports.calculateNetApy = exports.calculateInterestEarned = exports.getStakingApy = exports.STAKING_ASSETS = void 0;
|
|
16
16
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
17
17
|
const contracts_1 = require("../contracts");
|
|
18
18
|
const common_1 = require("../types/common");
|
|
@@ -40,7 +40,6 @@ const getStETHApy = (web3, fromBlock = 17900000, blockNumber = 'latest') => __aw
|
|
|
40
40
|
return (0, moneymarket_1.aprToApy)(data.data.smaApr);
|
|
41
41
|
}
|
|
42
42
|
});
|
|
43
|
-
exports.getStETHApy = getStETHApy;
|
|
44
43
|
const getCbETHApy = (web3, blockNumber = 'latest') => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
44
|
let currentBlock = blockNumber;
|
|
46
45
|
if (blockNumber === 'latest')
|
|
@@ -58,7 +57,6 @@ const getCbETHApy = (web3, blockNumber = 'latest') => __awaiter(void 0, void 0,
|
|
|
58
57
|
.toString();
|
|
59
58
|
return (0, moneymarket_1.aprToApy)(apr);
|
|
60
59
|
});
|
|
61
|
-
exports.getCbETHApy = getCbETHApy;
|
|
62
60
|
const getREthApy = (web3, blockNumber = 'latest') => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
61
|
let currentBlock = blockNumber;
|
|
64
62
|
if (blockNumber === 'latest')
|
|
@@ -76,7 +74,6 @@ const getREthApy = (web3, blockNumber = 'latest') => __awaiter(void 0, void 0, v
|
|
|
76
74
|
.toString();
|
|
77
75
|
return (0, moneymarket_1.aprToApy)(apr);
|
|
78
76
|
});
|
|
79
|
-
exports.getREthApy = getREthApy;
|
|
80
77
|
const getDsrApy = (web3, blockNumber = 'latest') => __awaiter(void 0, void 0, void 0, function* () {
|
|
81
78
|
const potContract = (0, contracts_1.PotContract)(web3, common_1.NetworkNumber.Eth);
|
|
82
79
|
return new decimal_js_1.default(yield potContract.methods.dsr().call())
|
|
@@ -86,13 +83,11 @@ const getDsrApy = (web3, blockNumber = 'latest') => __awaiter(void 0, void 0, vo
|
|
|
86
83
|
.mul(100)
|
|
87
84
|
.toString();
|
|
88
85
|
});
|
|
89
|
-
exports.getDsrApy = getDsrApy;
|
|
90
86
|
const getSsrApy = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
91
87
|
const res = yield fetch('https://fe.defisaver.com/api/sky/data');
|
|
92
88
|
const data = yield res.json();
|
|
93
89
|
return new decimal_js_1.default(data.data.skyData[0].sky_savings_rate_apy).mul(100).toString();
|
|
94
90
|
});
|
|
95
|
-
exports.getSsrApy = getSsrApy;
|
|
96
91
|
const getSuperOETHApy = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
97
92
|
const res = yield fetch('https://origin.squids.live/origin-squid/graphql', {
|
|
98
93
|
method: 'POST',
|
|
@@ -112,48 +107,50 @@ const getSuperOETHApy = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
112
107
|
});
|
|
113
108
|
const getApyFromDfsApi = (asset) => __awaiter(void 0, void 0, void 0, function* () {
|
|
114
109
|
const res = yield fetch(`https://fe.defisaver.com/api/staking/apy?asset=${asset}`);
|
|
110
|
+
if (!res.ok)
|
|
111
|
+
throw new Error(`Failed to fetch APY for ${asset}`);
|
|
115
112
|
const data = yield res.json();
|
|
116
113
|
// if our server returns apr, transform it into apy
|
|
117
114
|
if (['weETH'].includes(asset)) {
|
|
118
115
|
return (0, moneymarket_1.aprToApy)(data.apy);
|
|
119
116
|
}
|
|
120
|
-
return data.apy;
|
|
117
|
+
return String(data.apy);
|
|
121
118
|
});
|
|
122
119
|
exports.STAKING_ASSETS = ['cbETH', 'wstETH', 'cbETH', 'rETH', 'sDAI', 'weETH', 'sUSDe', 'osETH', 'ezETH', 'ETHx', 'rsETH', 'pufETH', 'wrsETH', 'wsuperOETHb', 'sUSDS'];
|
|
123
|
-
const getStakingApy = (asset, web3, blockNumber = 'latest', fromBlock = undefined) => {
|
|
120
|
+
const getStakingApy = (asset, web3, blockNumber = 'latest', fromBlock = undefined) => __awaiter(void 0, void 0, void 0, function* () {
|
|
124
121
|
try {
|
|
125
122
|
if (asset === 'stETH' || asset === 'wstETH')
|
|
126
|
-
return
|
|
123
|
+
return yield getStETHApy(web3, fromBlock, blockNumber);
|
|
127
124
|
if (asset === 'cbETH')
|
|
128
|
-
return
|
|
125
|
+
return yield getCbETHApy(web3, blockNumber);
|
|
129
126
|
if (asset === 'rETH')
|
|
130
|
-
return
|
|
127
|
+
return yield getREthApy(web3, blockNumber);
|
|
131
128
|
if (asset === 'sDAI')
|
|
132
|
-
return
|
|
129
|
+
return yield getDsrApy(web3);
|
|
133
130
|
if (asset === 'sUSDe')
|
|
134
|
-
return getApyFromDfsApi('sUSDe');
|
|
131
|
+
return yield getApyFromDfsApi('sUSDe');
|
|
135
132
|
if (asset === 'weETH')
|
|
136
|
-
return getApyFromDfsApi('weETH');
|
|
133
|
+
return yield getApyFromDfsApi('weETH');
|
|
137
134
|
if (asset === 'ezETH')
|
|
138
|
-
return getApyFromDfsApi('ezETH');
|
|
135
|
+
return yield getApyFromDfsApi('ezETH');
|
|
139
136
|
if (asset === 'osETH')
|
|
140
|
-
return getApyFromDfsApi('osETH');
|
|
137
|
+
return yield getApyFromDfsApi('osETH');
|
|
141
138
|
if (asset === 'ETHx')
|
|
142
|
-
return getApyFromDfsApi('ETHx');
|
|
139
|
+
return yield getApyFromDfsApi('ETHx');
|
|
143
140
|
if (asset === 'rsETH' || asset === 'wrsETH')
|
|
144
|
-
return getApyFromDfsApi('rsETH');
|
|
141
|
+
return yield getApyFromDfsApi('rsETH');
|
|
145
142
|
if (asset === 'pufETH')
|
|
146
|
-
return getApyFromDfsApi('pufETH');
|
|
143
|
+
return yield getApyFromDfsApi('pufETH');
|
|
147
144
|
if (asset === 'wsuperOETHb')
|
|
148
|
-
return getSuperOETHApy();
|
|
145
|
+
return yield getSuperOETHApy();
|
|
149
146
|
if (asset === 'sUSDS')
|
|
150
|
-
return
|
|
147
|
+
return yield getSsrApy();
|
|
151
148
|
}
|
|
152
149
|
catch (e) {
|
|
153
150
|
console.error(`Failed to fetch APY for ${asset}`);
|
|
154
|
-
return '0';
|
|
155
151
|
}
|
|
156
|
-
|
|
152
|
+
return '0';
|
|
153
|
+
});
|
|
157
154
|
exports.getStakingApy = getStakingApy;
|
|
158
155
|
const calculateInterestEarned = (principal, interest, type, apy = false) => {
|
|
159
156
|
let interval = 1;
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import type BN from "bn.js";
|
|
3
|
+
import type { ContractOptions } from "web3-eth-contract";
|
|
4
|
+
import type { EventLog } from "web3-core";
|
|
5
|
+
import type { EventEmitter } from "events";
|
|
6
|
+
import type { Callback, NonPayableTransactionObject, BlockType, ContractEventLog, BaseContract } from "./types";
|
|
7
|
+
export interface EventOptions {
|
|
8
|
+
filter?: object;
|
|
9
|
+
fromBlock?: BlockType;
|
|
10
|
+
topics?: string[];
|
|
11
|
+
}
|
|
12
|
+
export type ActivePoolAddressChanged = ContractEventLog<{
|
|
13
|
+
_newActivePoolAddress: string;
|
|
14
|
+
0: string;
|
|
15
|
+
}>;
|
|
16
|
+
export type B_Updated = ContractEventLog<{
|
|
17
|
+
_B: string;
|
|
18
|
+
_epoch: string;
|
|
19
|
+
_scale: string;
|
|
20
|
+
0: string;
|
|
21
|
+
1: string;
|
|
22
|
+
2: string;
|
|
23
|
+
}>;
|
|
24
|
+
export type BoldTokenAddressChanged = ContractEventLog<{
|
|
25
|
+
_newBoldTokenAddress: string;
|
|
26
|
+
0: string;
|
|
27
|
+
}>;
|
|
28
|
+
export type DefaultPoolAddressChanged = ContractEventLog<{
|
|
29
|
+
_newDefaultPoolAddress: string;
|
|
30
|
+
0: string;
|
|
31
|
+
}>;
|
|
32
|
+
export type DepositOperation = ContractEventLog<{
|
|
33
|
+
_depositor: string;
|
|
34
|
+
_operation: string;
|
|
35
|
+
_depositLossSinceLastOperation: string;
|
|
36
|
+
_depositChange: string;
|
|
37
|
+
_yieldGainSinceLastOperation: string;
|
|
38
|
+
_yieldGainClaimed: string;
|
|
39
|
+
_ethGainSinceLastOperation: string;
|
|
40
|
+
_ethGainClaimed: string;
|
|
41
|
+
0: string;
|
|
42
|
+
1: string;
|
|
43
|
+
2: string;
|
|
44
|
+
3: string;
|
|
45
|
+
4: string;
|
|
46
|
+
5: string;
|
|
47
|
+
6: string;
|
|
48
|
+
7: string;
|
|
49
|
+
}>;
|
|
50
|
+
export type DepositUpdated = ContractEventLog<{
|
|
51
|
+
_depositor: string;
|
|
52
|
+
_newDeposit: string;
|
|
53
|
+
_stashedColl: string;
|
|
54
|
+
_snapshotP: string;
|
|
55
|
+
_snapshotS: string;
|
|
56
|
+
_snapshotB: string;
|
|
57
|
+
_snapshotScale: string;
|
|
58
|
+
_snapshotEpoch: string;
|
|
59
|
+
0: string;
|
|
60
|
+
1: string;
|
|
61
|
+
2: string;
|
|
62
|
+
3: string;
|
|
63
|
+
4: string;
|
|
64
|
+
5: string;
|
|
65
|
+
6: string;
|
|
66
|
+
7: string;
|
|
67
|
+
}>;
|
|
68
|
+
export type EpochUpdated = ContractEventLog<{
|
|
69
|
+
_currentEpoch: string;
|
|
70
|
+
0: string;
|
|
71
|
+
}>;
|
|
72
|
+
export type EtherSent = ContractEventLog<{
|
|
73
|
+
_to: string;
|
|
74
|
+
_amount: string;
|
|
75
|
+
0: string;
|
|
76
|
+
1: string;
|
|
77
|
+
}>;
|
|
78
|
+
export type P_Updated = ContractEventLog<{
|
|
79
|
+
_P: string;
|
|
80
|
+
0: string;
|
|
81
|
+
}>;
|
|
82
|
+
export type PriceFeedAddressChanged = ContractEventLog<{
|
|
83
|
+
_newPriceFeedAddress: string;
|
|
84
|
+
0: string;
|
|
85
|
+
}>;
|
|
86
|
+
export type S_Updated = ContractEventLog<{
|
|
87
|
+
_S: string;
|
|
88
|
+
_epoch: string;
|
|
89
|
+
_scale: string;
|
|
90
|
+
0: string;
|
|
91
|
+
1: string;
|
|
92
|
+
2: string;
|
|
93
|
+
}>;
|
|
94
|
+
export type ScaleUpdated = ContractEventLog<{
|
|
95
|
+
_currentScale: string;
|
|
96
|
+
0: string;
|
|
97
|
+
}>;
|
|
98
|
+
export type StabilityPoolBoldBalanceUpdated = ContractEventLog<{
|
|
99
|
+
_newBalance: string;
|
|
100
|
+
0: string;
|
|
101
|
+
}>;
|
|
102
|
+
export type StabilityPoolCollBalanceUpdated = ContractEventLog<{
|
|
103
|
+
_newBalance: string;
|
|
104
|
+
0: string;
|
|
105
|
+
}>;
|
|
106
|
+
export type TroveManagerAddressChanged = ContractEventLog<{
|
|
107
|
+
_newTroveManagerAddress: string;
|
|
108
|
+
0: string;
|
|
109
|
+
}>;
|
|
110
|
+
export interface LiquityV2StabilityPool extends BaseContract {
|
|
111
|
+
constructor(jsonInterface: any[], address?: string, options?: ContractOptions): LiquityV2StabilityPool;
|
|
112
|
+
clone(): LiquityV2StabilityPool;
|
|
113
|
+
methods: {
|
|
114
|
+
NAME(): NonPayableTransactionObject<string>;
|
|
115
|
+
P(): NonPayableTransactionObject<string>;
|
|
116
|
+
SCALE_FACTOR(): NonPayableTransactionObject<string>;
|
|
117
|
+
activePool(): NonPayableTransactionObject<string>;
|
|
118
|
+
boldToken(): NonPayableTransactionObject<string>;
|
|
119
|
+
claimAllCollGains(): NonPayableTransactionObject<void>;
|
|
120
|
+
collToken(): NonPayableTransactionObject<string>;
|
|
121
|
+
currentEpoch(): NonPayableTransactionObject<string>;
|
|
122
|
+
currentScale(): NonPayableTransactionObject<string>;
|
|
123
|
+
depositSnapshots(arg0: string): NonPayableTransactionObject<[
|
|
124
|
+
string,
|
|
125
|
+
string,
|
|
126
|
+
string,
|
|
127
|
+
string,
|
|
128
|
+
string
|
|
129
|
+
] & {
|
|
130
|
+
S: string;
|
|
131
|
+
P: string;
|
|
132
|
+
B: string;
|
|
133
|
+
scale: string;
|
|
134
|
+
epoch: string;
|
|
135
|
+
}>;
|
|
136
|
+
deposits(arg0: string): NonPayableTransactionObject<string>;
|
|
137
|
+
epochToScaleToB(arg0: number | string | BN, arg1: number | string | BN): NonPayableTransactionObject<string>;
|
|
138
|
+
epochToScaleToS(arg0: number | string | BN, arg1: number | string | BN): NonPayableTransactionObject<string>;
|
|
139
|
+
getCollBalance(): NonPayableTransactionObject<string>;
|
|
140
|
+
getCompoundedBoldDeposit(_depositor: string): NonPayableTransactionObject<string>;
|
|
141
|
+
getDepositorCollGain(_depositor: string): NonPayableTransactionObject<string>;
|
|
142
|
+
getDepositorYieldGain(_depositor: string): NonPayableTransactionObject<string>;
|
|
143
|
+
getDepositorYieldGainWithPending(_depositor: string): NonPayableTransactionObject<string>;
|
|
144
|
+
getEntireSystemColl(): NonPayableTransactionObject<string>;
|
|
145
|
+
getEntireSystemDebt(): NonPayableTransactionObject<string>;
|
|
146
|
+
getTotalBoldDeposits(): NonPayableTransactionObject<string>;
|
|
147
|
+
getYieldGainsOwed(): NonPayableTransactionObject<string>;
|
|
148
|
+
getYieldGainsPending(): NonPayableTransactionObject<string>;
|
|
149
|
+
lastBoldLossError_Offset(): NonPayableTransactionObject<string>;
|
|
150
|
+
lastBoldLossError_TotalDeposits(): NonPayableTransactionObject<string>;
|
|
151
|
+
lastCollError_Offset(): NonPayableTransactionObject<string>;
|
|
152
|
+
lastYieldError(): NonPayableTransactionObject<string>;
|
|
153
|
+
offset(_debtToOffset: number | string | BN, _collToAdd: number | string | BN): NonPayableTransactionObject<void>;
|
|
154
|
+
provideToSP(_topUp: number | string | BN, _doClaim: boolean): NonPayableTransactionObject<void>;
|
|
155
|
+
stashedColl(arg0: string): NonPayableTransactionObject<string>;
|
|
156
|
+
triggerBoldRewards(_boldYield: number | string | BN): NonPayableTransactionObject<void>;
|
|
157
|
+
troveManager(): NonPayableTransactionObject<string>;
|
|
158
|
+
withdrawFromSP(_amount: number | string | BN, _doClaim: boolean): NonPayableTransactionObject<void>;
|
|
159
|
+
};
|
|
160
|
+
events: {
|
|
161
|
+
ActivePoolAddressChanged(cb?: Callback<ActivePoolAddressChanged>): EventEmitter;
|
|
162
|
+
ActivePoolAddressChanged(options?: EventOptions, cb?: Callback<ActivePoolAddressChanged>): EventEmitter;
|
|
163
|
+
B_Updated(cb?: Callback<B_Updated>): EventEmitter;
|
|
164
|
+
B_Updated(options?: EventOptions, cb?: Callback<B_Updated>): EventEmitter;
|
|
165
|
+
BoldTokenAddressChanged(cb?: Callback<BoldTokenAddressChanged>): EventEmitter;
|
|
166
|
+
BoldTokenAddressChanged(options?: EventOptions, cb?: Callback<BoldTokenAddressChanged>): EventEmitter;
|
|
167
|
+
DefaultPoolAddressChanged(cb?: Callback<DefaultPoolAddressChanged>): EventEmitter;
|
|
168
|
+
DefaultPoolAddressChanged(options?: EventOptions, cb?: Callback<DefaultPoolAddressChanged>): EventEmitter;
|
|
169
|
+
DepositOperation(cb?: Callback<DepositOperation>): EventEmitter;
|
|
170
|
+
DepositOperation(options?: EventOptions, cb?: Callback<DepositOperation>): EventEmitter;
|
|
171
|
+
DepositUpdated(cb?: Callback<DepositUpdated>): EventEmitter;
|
|
172
|
+
DepositUpdated(options?: EventOptions, cb?: Callback<DepositUpdated>): EventEmitter;
|
|
173
|
+
EpochUpdated(cb?: Callback<EpochUpdated>): EventEmitter;
|
|
174
|
+
EpochUpdated(options?: EventOptions, cb?: Callback<EpochUpdated>): EventEmitter;
|
|
175
|
+
EtherSent(cb?: Callback<EtherSent>): EventEmitter;
|
|
176
|
+
EtherSent(options?: EventOptions, cb?: Callback<EtherSent>): EventEmitter;
|
|
177
|
+
P_Updated(cb?: Callback<P_Updated>): EventEmitter;
|
|
178
|
+
P_Updated(options?: EventOptions, cb?: Callback<P_Updated>): EventEmitter;
|
|
179
|
+
PriceFeedAddressChanged(cb?: Callback<PriceFeedAddressChanged>): EventEmitter;
|
|
180
|
+
PriceFeedAddressChanged(options?: EventOptions, cb?: Callback<PriceFeedAddressChanged>): EventEmitter;
|
|
181
|
+
S_Updated(cb?: Callback<S_Updated>): EventEmitter;
|
|
182
|
+
S_Updated(options?: EventOptions, cb?: Callback<S_Updated>): EventEmitter;
|
|
183
|
+
ScaleUpdated(cb?: Callback<ScaleUpdated>): EventEmitter;
|
|
184
|
+
ScaleUpdated(options?: EventOptions, cb?: Callback<ScaleUpdated>): EventEmitter;
|
|
185
|
+
StabilityPoolBoldBalanceUpdated(cb?: Callback<StabilityPoolBoldBalanceUpdated>): EventEmitter;
|
|
186
|
+
StabilityPoolBoldBalanceUpdated(options?: EventOptions, cb?: Callback<StabilityPoolBoldBalanceUpdated>): EventEmitter;
|
|
187
|
+
StabilityPoolCollBalanceUpdated(cb?: Callback<StabilityPoolCollBalanceUpdated>): EventEmitter;
|
|
188
|
+
StabilityPoolCollBalanceUpdated(options?: EventOptions, cb?: Callback<StabilityPoolCollBalanceUpdated>): EventEmitter;
|
|
189
|
+
TroveManagerAddressChanged(cb?: Callback<TroveManagerAddressChanged>): EventEmitter;
|
|
190
|
+
TroveManagerAddressChanged(options?: EventOptions, cb?: Callback<TroveManagerAddressChanged>): EventEmitter;
|
|
191
|
+
allEvents(options?: EventOptions, cb?: Callback<EventLog>): EventEmitter;
|
|
192
|
+
};
|
|
193
|
+
once(event: "ActivePoolAddressChanged", cb: Callback<ActivePoolAddressChanged>): void;
|
|
194
|
+
once(event: "ActivePoolAddressChanged", options: EventOptions, cb: Callback<ActivePoolAddressChanged>): void;
|
|
195
|
+
once(event: "B_Updated", cb: Callback<B_Updated>): void;
|
|
196
|
+
once(event: "B_Updated", options: EventOptions, cb: Callback<B_Updated>): void;
|
|
197
|
+
once(event: "BoldTokenAddressChanged", cb: Callback<BoldTokenAddressChanged>): void;
|
|
198
|
+
once(event: "BoldTokenAddressChanged", options: EventOptions, cb: Callback<BoldTokenAddressChanged>): void;
|
|
199
|
+
once(event: "DefaultPoolAddressChanged", cb: Callback<DefaultPoolAddressChanged>): void;
|
|
200
|
+
once(event: "DefaultPoolAddressChanged", options: EventOptions, cb: Callback<DefaultPoolAddressChanged>): void;
|
|
201
|
+
once(event: "DepositOperation", cb: Callback<DepositOperation>): void;
|
|
202
|
+
once(event: "DepositOperation", options: EventOptions, cb: Callback<DepositOperation>): void;
|
|
203
|
+
once(event: "DepositUpdated", cb: Callback<DepositUpdated>): void;
|
|
204
|
+
once(event: "DepositUpdated", options: EventOptions, cb: Callback<DepositUpdated>): void;
|
|
205
|
+
once(event: "EpochUpdated", cb: Callback<EpochUpdated>): void;
|
|
206
|
+
once(event: "EpochUpdated", options: EventOptions, cb: Callback<EpochUpdated>): void;
|
|
207
|
+
once(event: "EtherSent", cb: Callback<EtherSent>): void;
|
|
208
|
+
once(event: "EtherSent", options: EventOptions, cb: Callback<EtherSent>): void;
|
|
209
|
+
once(event: "P_Updated", cb: Callback<P_Updated>): void;
|
|
210
|
+
once(event: "P_Updated", options: EventOptions, cb: Callback<P_Updated>): void;
|
|
211
|
+
once(event: "PriceFeedAddressChanged", cb: Callback<PriceFeedAddressChanged>): void;
|
|
212
|
+
once(event: "PriceFeedAddressChanged", options: EventOptions, cb: Callback<PriceFeedAddressChanged>): void;
|
|
213
|
+
once(event: "S_Updated", cb: Callback<S_Updated>): void;
|
|
214
|
+
once(event: "S_Updated", options: EventOptions, cb: Callback<S_Updated>): void;
|
|
215
|
+
once(event: "ScaleUpdated", cb: Callback<ScaleUpdated>): void;
|
|
216
|
+
once(event: "ScaleUpdated", options: EventOptions, cb: Callback<ScaleUpdated>): void;
|
|
217
|
+
once(event: "StabilityPoolBoldBalanceUpdated", cb: Callback<StabilityPoolBoldBalanceUpdated>): void;
|
|
218
|
+
once(event: "StabilityPoolBoldBalanceUpdated", options: EventOptions, cb: Callback<StabilityPoolBoldBalanceUpdated>): void;
|
|
219
|
+
once(event: "StabilityPoolCollBalanceUpdated", cb: Callback<StabilityPoolCollBalanceUpdated>): void;
|
|
220
|
+
once(event: "StabilityPoolCollBalanceUpdated", options: EventOptions, cb: Callback<StabilityPoolCollBalanceUpdated>): void;
|
|
221
|
+
once(event: "TroveManagerAddressChanged", cb: Callback<TroveManagerAddressChanged>): void;
|
|
222
|
+
once(event: "TroveManagerAddressChanged", options: EventOptions, cb: Callback<TroveManagerAddressChanged>): void;
|
|
223
|
+
}
|