@defisaver/positions-sdk 0.0.64 → 0.0.66
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/.yarn/releases/yarn-1.22.1.cjs +147386 -0
- package/.yarn/releases/yarn-1.22.1.js +147386 -0
- package/.yarnrc.yml +1 -0
- package/cjs/aaveV3/index.js +1 -1
- package/cjs/config/contracts.d.ts +9 -0
- package/cjs/config/contracts.js +9 -0
- package/cjs/markets/compound/index.js +3 -2
- package/cjs/markets/compound/marketsAssets.d.ts +2 -1
- package/cjs/markets/compound/marketsAssets.js +3 -2
- package/cjs/morphoBlue/index.js +1 -1
- package/cjs/staking/staking.d.ts +2 -1
- package/cjs/staking/staking.js +26 -11
- package/esm/aaveV3/index.js +2 -2
- package/esm/config/contracts.d.ts +9 -0
- package/esm/config/contracts.js +9 -0
- package/esm/markets/compound/index.js +3 -2
- package/esm/markets/compound/marketsAssets.d.ts +2 -1
- package/esm/markets/compound/marketsAssets.js +2 -1
- package/esm/morphoBlue/index.js +2 -2
- package/esm/staking/staking.d.ts +2 -1
- package/esm/staking/staking.js +25 -10
- package/package.json +1 -1
- package/src/aaveV3/index.ts +2 -2
- package/src/config/contracts.js +9 -0
- package/src/markets/compound/index.ts +4 -3
- package/src/markets/compound/marketsAssets.ts +2 -1
- package/src/morphoBlue/index.ts +3 -3
- package/src/staking/staking.ts +21 -6
package/.yarnrc.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
yarnPath: .yarn/releases/yarn-1.22.1.cjs
|
package/cjs/aaveV3/index.js
CHANGED
|
@@ -175,7 +175,7 @@ function getAaveV3MarketData(web3, network, market, defaultWeb3) {
|
|
|
175
175
|
yield Promise.all(assetsData.map((_market) => __awaiter(this, void 0, void 0, function* () {
|
|
176
176
|
/* eslint-disable no-param-reassign */
|
|
177
177
|
const rewardForMarket = rewardInfo === null || rewardInfo === void 0 ? void 0 : rewardInfo[_market.underlyingTokenAddress];
|
|
178
|
-
if (
|
|
178
|
+
if (staking_1.STAKING_ASSETS.includes(_market.symbol)) {
|
|
179
179
|
_market.incentiveSupplyApy = yield (0, staking_1.getStakingApy)(_market.symbol, defaultWeb3);
|
|
180
180
|
_market.incentiveSupplyToken = _market.symbol;
|
|
181
181
|
}
|
|
@@ -1126,6 +1126,9 @@ export namespace cUSDCv3 {
|
|
|
1126
1126
|
"1": {
|
|
1127
1127
|
address: string;
|
|
1128
1128
|
};
|
|
1129
|
+
"10": {
|
|
1130
|
+
address: string;
|
|
1131
|
+
};
|
|
1129
1132
|
"8453": {
|
|
1130
1133
|
address: string;
|
|
1131
1134
|
};
|
|
@@ -1495,6 +1498,9 @@ export namespace CompV3View {
|
|
|
1495
1498
|
};
|
|
1496
1499
|
};
|
|
1497
1500
|
};
|
|
1501
|
+
"10": {
|
|
1502
|
+
address: string;
|
|
1503
|
+
};
|
|
1498
1504
|
"8453": {
|
|
1499
1505
|
address: string;
|
|
1500
1506
|
};
|
|
@@ -1688,6 +1694,9 @@ export namespace CompV3BulkerL2 {
|
|
|
1688
1694
|
})[];
|
|
1689
1695
|
export { abi_20 as abi };
|
|
1690
1696
|
let networks_20: {
|
|
1697
|
+
"10": {
|
|
1698
|
+
address: string;
|
|
1699
|
+
};
|
|
1691
1700
|
"8453": {
|
|
1692
1701
|
address: string;
|
|
1693
1702
|
};
|
package/cjs/config/contracts.js
CHANGED
|
@@ -246,6 +246,9 @@ module.exports = {
|
|
|
246
246
|
"1": {
|
|
247
247
|
"address": "0xc3d688B66703497DAA19211EEdff47f25384cdc3"
|
|
248
248
|
},
|
|
249
|
+
"10": {
|
|
250
|
+
"address": "0x2e44e174f7D53F0212823acC11C01A11d58c5bCB"
|
|
251
|
+
},
|
|
249
252
|
"8453": {
|
|
250
253
|
"address": "0xb125E6687d4313864e53df431d5425969c15Eb2F"
|
|
251
254
|
},
|
|
@@ -294,6 +297,9 @@ module.exports = {
|
|
|
294
297
|
}
|
|
295
298
|
}
|
|
296
299
|
},
|
|
300
|
+
"10": {
|
|
301
|
+
"address": "0x969d845618596787DBc64687Ee90b16931BBBCBC"
|
|
302
|
+
},
|
|
297
303
|
"8453": {
|
|
298
304
|
"address": "0x22591183c0eb7B2Fe07F6F44fd360d1117D07b4f"
|
|
299
305
|
},
|
|
@@ -321,6 +327,9 @@ module.exports = {
|
|
|
321
327
|
"CompV3BulkerL2": {
|
|
322
328
|
"abi": [{ "inputs": [{ "internalType": "address", "name": "admin_", "type": "address" }, { "internalType": "address payable", "name": "wrappedNativeToken_", "type": "address" }], "stateMutability": "nonpayable", "type": "constructor" }, { "inputs": [], "name": "FailedToSendNativeToken", "type": "error" }, { "inputs": [], "name": "InvalidAddress", "type": "error" }, { "inputs": [], "name": "InvalidArgument", "type": "error" }, { "inputs": [], "name": "TransferInFailed", "type": "error" }, { "inputs": [], "name": "TransferOutFailed", "type": "error" }, { "inputs": [], "name": "Unauthorized", "type": "error" }, { "inputs": [], "name": "UnhandledAction", "type": "error" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "oldAdmin", "type": "address" }, { "indexed": true, "internalType": "address", "name": "newAdmin", "type": "address" }], "name": "AdminTransferred", "type": "event" }, { "inputs": [], "name": "ACTION_CLAIM_REWARD", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "ACTION_SUPPLY_ASSET", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "ACTION_SUPPLY_NATIVE_TOKEN", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "ACTION_TRANSFER_ASSET", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "ACTION_WITHDRAW_ASSET", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "ACTION_WITHDRAW_NATIVE_TOKEN", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "admin", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32[]", "name": "actions", "type": "bytes32[]" }, { "internalType": "bytes[]", "name": "data", "type": "bytes[]" }], "name": "invoke", "outputs": [], "stateMutability": "payable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "recipient", "type": "address" }], "name": "sweepNativeToken", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "recipient", "type": "address" }, { "internalType": "address", "name": "asset", "type": "address" }], "name": "sweepToken", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "newAdmin", "type": "address" }], "name": "transferAdmin", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "wrappedNativeToken", "outputs": [{ "internalType": "address payable", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "stateMutability": "payable", "type": "receive" }],
|
|
323
329
|
"networks": {
|
|
330
|
+
"10": {
|
|
331
|
+
"address": "0xcb3643CC8294B23171272845473dEc49739d4Ba3"
|
|
332
|
+
},
|
|
324
333
|
"8453": {
|
|
325
334
|
"address": "0x78D0677032A35c63D142a48A2037048871212a8C"
|
|
326
335
|
},
|
|
@@ -36,10 +36,11 @@ const BULKER_OPTIONS = {
|
|
|
36
36
|
[types_1.CompoundVersions.CompoundV3USDCe]: EMPTY_BULKER_OPTIONS,
|
|
37
37
|
},
|
|
38
38
|
[common_1.NetworkNumber.Opt]: {
|
|
39
|
+
[types_1.CompoundVersions.CompoundV3USDC]: STANDARD_BULKER_OPTIONS,
|
|
40
|
+
// Non-existing markets, keeping it because of typescript
|
|
39
41
|
[types_1.CompoundVersions.CompoundV3ETH]: EMPTY_BULKER_OPTIONS,
|
|
40
42
|
[types_1.CompoundVersions.CompoundV3USDbC]: EMPTY_BULKER_OPTIONS,
|
|
41
43
|
[types_1.CompoundVersions.CompoundV2]: EMPTY_BULKER_OPTIONS,
|
|
42
|
-
[types_1.CompoundVersions.CompoundV3USDC]: EMPTY_BULKER_OPTIONS,
|
|
43
44
|
[types_1.CompoundVersions.CompoundV3USDCe]: EMPTY_BULKER_OPTIONS,
|
|
44
45
|
},
|
|
45
46
|
};
|
|
@@ -59,7 +60,7 @@ exports.COMPOUND_V2 = {
|
|
|
59
60
|
// icon: SvgAdapter(protocolIcons.compound),
|
|
60
61
|
};
|
|
61
62
|
const COMPOUND_V3_USDC = (networkId) => ({
|
|
62
|
-
chainIds: [common_1.NetworkNumber.Eth, common_1.NetworkNumber.Arb, common_1.NetworkNumber.Base],
|
|
63
|
+
chainIds: [common_1.NetworkNumber.Eth, common_1.NetworkNumber.Arb, common_1.NetworkNumber.Base, common_1.NetworkNumber.Opt],
|
|
63
64
|
label: 'Compound V3 - USDC',
|
|
64
65
|
shortLabel: 'v3',
|
|
65
66
|
value: types_1.CompoundVersions.CompoundV3USDC,
|
|
@@ -2,9 +2,10 @@ export declare const compoundV2CollateralAssets: import("@defisaver/tokens/esm/t
|
|
|
2
2
|
export declare const v3USDCCollAssetsEth: string[];
|
|
3
3
|
export declare const v3USDCCollAssetsArb: string[];
|
|
4
4
|
export declare const v3USDCCollAssetsBase: string[];
|
|
5
|
+
export declare const v3USDCCollAssetsOpt: string[];
|
|
5
6
|
export declare const v3USDCCollAssets: {
|
|
6
7
|
readonly 1: string[];
|
|
7
|
-
readonly 10:
|
|
8
|
+
readonly 10: string[];
|
|
8
9
|
readonly 42161: string[];
|
|
9
10
|
readonly 8453: string[];
|
|
10
11
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.v3USDbCCollAssets = exports.v3USDbCCollAssetsBase = exports.v3ETHCollAssets = exports.v3ETHCollAssetsBase = exports.v3ETHCollAssetsEth = exports.v3USDCeCollAssets = exports.v3USDCeCollAssetsArb = exports.v3USDCCollAssets = exports.v3USDCCollAssetsBase = exports.v3USDCCollAssetsArb = exports.v3USDCCollAssetsEth = exports.compoundV2CollateralAssets = void 0;
|
|
3
|
+
exports.v3USDbCCollAssets = exports.v3USDbCCollAssetsBase = exports.v3ETHCollAssets = exports.v3ETHCollAssetsBase = exports.v3ETHCollAssetsEth = exports.v3USDCeCollAssets = exports.v3USDCeCollAssetsArb = exports.v3USDCCollAssets = exports.v3USDCCollAssetsOpt = exports.v3USDCCollAssetsBase = exports.v3USDCCollAssetsArb = exports.v3USDCCollAssetsEth = exports.compoundV2CollateralAssets = void 0;
|
|
4
4
|
const tokens_1 = require("@defisaver/tokens");
|
|
5
5
|
const common_1 = require("../../types/common");
|
|
6
6
|
exports.compoundV2CollateralAssets = [
|
|
@@ -10,10 +10,11 @@ exports.compoundV2CollateralAssets = [
|
|
|
10
10
|
exports.v3USDCCollAssetsEth = ['ETH', 'COMP', 'WBTC', 'UNI', 'LINK'];
|
|
11
11
|
exports.v3USDCCollAssetsArb = ['ARB', 'ETH', 'GMX', 'WBTC'];
|
|
12
12
|
exports.v3USDCCollAssetsBase = ['ETH', 'cbETH'];
|
|
13
|
+
exports.v3USDCCollAssetsOpt = ['ETH', 'OP', 'WBTC'];
|
|
13
14
|
// @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
|
|
14
15
|
exports.v3USDCCollAssets = {
|
|
15
16
|
[common_1.NetworkNumber.Eth]: exports.v3USDCCollAssetsEth,
|
|
16
|
-
[common_1.NetworkNumber.Opt]:
|
|
17
|
+
[common_1.NetworkNumber.Opt]: exports.v3USDCCollAssetsOpt,
|
|
17
18
|
[common_1.NetworkNumber.Arb]: exports.v3USDCCollAssetsArb,
|
|
18
19
|
[common_1.NetworkNumber.Base]: exports.v3USDCCollAssetsBase,
|
|
19
20
|
};
|
package/cjs/morphoBlue/index.js
CHANGED
|
@@ -102,7 +102,7 @@ function getMorphoBlueMarketData(web3, network, selectedMarket, mainnetWeb3) {
|
|
|
102
102
|
canBeSupplied: true,
|
|
103
103
|
canBeBorrowed: false,
|
|
104
104
|
};
|
|
105
|
-
if (
|
|
105
|
+
if (staking_1.STAKING_ASSETS.includes(collateralTokenInfo.symbol)) {
|
|
106
106
|
assetsData[collateralTokenInfo.symbol].incentiveSupplyApy = yield (0, staking_1.getStakingApy)(collateralTokenInfo.symbol, mainnetWeb3);
|
|
107
107
|
assetsData[collateralTokenInfo.symbol].incentiveSupplyToken = collateralTokenInfo.symbol;
|
|
108
108
|
}
|
package/cjs/staking/staking.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ export declare const getCbETHApr: (web3: Web3, blockNumber?: 'latest' | number)
|
|
|
5
5
|
export declare const getREthApr: (web3: Web3, blockNumber?: 'latest' | number) => Promise<string>;
|
|
6
6
|
export declare const getDsrApy: (web3: Web3, blockNumber?: 'latest' | number) => Promise<string>;
|
|
7
7
|
export declare const getSUSDeApy: () => Promise<any>;
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const STAKING_ASSETS: string[];
|
|
9
|
+
export declare const getStakingApy: (asset: string, web3: Web3, blockNumber?: 'latest' | number, fromBlock?: number | undefined) => Promise<any> | "0" | undefined;
|
|
9
10
|
export declare const calculateInterestEarned: (principal: string, interest: string, type: string, apy?: boolean) => number;
|
|
10
11
|
export declare const calculateNetApy: (usedAssets: MMUsedAssets, assetsData: MMAssetsData, isMorpho?: boolean) => {
|
|
11
12
|
netApy: string;
|
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.getSUSDeApy = exports.getDsrApy = exports.getREthApr = exports.getCbETHApr = exports.getStETHApr = void 0;
|
|
15
|
+
exports.getStETHByWstETHMultiple = exports.getStETHByWstETH = exports.getWstETHByStETH = exports.calculateNetApy = exports.calculateInterestEarned = exports.getStakingApy = exports.STAKING_ASSETS = exports.getSUSDeApy = exports.getDsrApy = exports.getREthApr = exports.getCbETHApr = exports.getStETHApr = 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");
|
|
@@ -92,17 +92,32 @@ const getSUSDeApy = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
92
92
|
return data.apy;
|
|
93
93
|
});
|
|
94
94
|
exports.getSUSDeApy = getSUSDeApy;
|
|
95
|
+
const getWeEthApr = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
|
+
const res = yield fetch('https://www.etherfi.bid/api/etherfi/apr');
|
|
97
|
+
const data = yield res.json();
|
|
98
|
+
const total = data.latest_aprs.reduce((acc, apr) => new decimal_js_1.default(acc).add(apr).toString());
|
|
99
|
+
return new decimal_js_1.default(total).div(data.latest_aprs.length).div(100).toString();
|
|
100
|
+
});
|
|
101
|
+
exports.STAKING_ASSETS = ['cbETH', 'wstETH', 'cbETH', 'rETH', 'sDAI', 'weETH'];
|
|
95
102
|
const getStakingApy = (asset, web3, blockNumber = 'latest', fromBlock = undefined) => {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
try {
|
|
104
|
+
if (asset === 'stETH' || asset === 'wstETH')
|
|
105
|
+
return (0, exports.getStETHApr)(web3, fromBlock, blockNumber);
|
|
106
|
+
if (asset === 'cbETH')
|
|
107
|
+
return (0, exports.getCbETHApr)(web3, blockNumber);
|
|
108
|
+
if (asset === 'rETH')
|
|
109
|
+
return (0, exports.getREthApr)(web3, blockNumber);
|
|
110
|
+
if (asset === 'sDAI')
|
|
111
|
+
return (0, exports.getDsrApy)(web3);
|
|
112
|
+
if (asset === 'sUSDe')
|
|
113
|
+
return (0, exports.getSUSDeApy)();
|
|
114
|
+
if (asset === 'weETH')
|
|
115
|
+
return getWeEthApr();
|
|
116
|
+
}
|
|
117
|
+
catch (e) {
|
|
118
|
+
console.error(`Failed to fetch APY for ${asset}`);
|
|
119
|
+
return '0';
|
|
120
|
+
}
|
|
106
121
|
};
|
|
107
122
|
exports.getStakingApy = getStakingApy;
|
|
108
123
|
const calculateInterestEarned = (principal, interest, type, apy = false) => {
|
package/esm/aaveV3/index.js
CHANGED
|
@@ -12,7 +12,7 @@ import { assetAmountInEth, assetAmountInWei, getAssetInfo } from '@defisaver/tok
|
|
|
12
12
|
import { AaveIncentiveDataProviderV3Contract, AaveV3ViewContract, createContractWrapper, getConfigContractAbi, getConfigContractAddress, GhoTokenContract, } from '../contracts';
|
|
13
13
|
import { addToObjectIf, ethToWeth, getAbiItem, isLayer2Network, wethToEth, wethToEthByAddress, } from '../services/utils';
|
|
14
14
|
import { NetworkNumber, } from '../types/common';
|
|
15
|
-
import { getStakingApy } from '../staking';
|
|
15
|
+
import { getStakingApy, STAKING_ASSETS } from '../staking';
|
|
16
16
|
import { multicall } from '../multicall';
|
|
17
17
|
import { getAssetsBalances } from '../assets';
|
|
18
18
|
import { calculateBorrowingAssetLimit } from '../moneymarket';
|
|
@@ -166,7 +166,7 @@ export function getAaveV3MarketData(web3, network, market, defaultWeb3) {
|
|
|
166
166
|
yield Promise.all(assetsData.map((_market) => __awaiter(this, void 0, void 0, function* () {
|
|
167
167
|
/* eslint-disable no-param-reassign */
|
|
168
168
|
const rewardForMarket = rewardInfo === null || rewardInfo === void 0 ? void 0 : rewardInfo[_market.underlyingTokenAddress];
|
|
169
|
-
if (
|
|
169
|
+
if (STAKING_ASSETS.includes(_market.symbol)) {
|
|
170
170
|
_market.incentiveSupplyApy = yield getStakingApy(_market.symbol, defaultWeb3);
|
|
171
171
|
_market.incentiveSupplyToken = _market.symbol;
|
|
172
172
|
}
|
|
@@ -1126,6 +1126,9 @@ export namespace cUSDCv3 {
|
|
|
1126
1126
|
"1": {
|
|
1127
1127
|
address: string;
|
|
1128
1128
|
};
|
|
1129
|
+
"10": {
|
|
1130
|
+
address: string;
|
|
1131
|
+
};
|
|
1129
1132
|
"8453": {
|
|
1130
1133
|
address: string;
|
|
1131
1134
|
};
|
|
@@ -1495,6 +1498,9 @@ export namespace CompV3View {
|
|
|
1495
1498
|
};
|
|
1496
1499
|
};
|
|
1497
1500
|
};
|
|
1501
|
+
"10": {
|
|
1502
|
+
address: string;
|
|
1503
|
+
};
|
|
1498
1504
|
"8453": {
|
|
1499
1505
|
address: string;
|
|
1500
1506
|
};
|
|
@@ -1688,6 +1694,9 @@ export namespace CompV3BulkerL2 {
|
|
|
1688
1694
|
})[];
|
|
1689
1695
|
export { abi_20 as abi };
|
|
1690
1696
|
let networks_20: {
|
|
1697
|
+
"10": {
|
|
1698
|
+
address: string;
|
|
1699
|
+
};
|
|
1691
1700
|
"8453": {
|
|
1692
1701
|
address: string;
|
|
1693
1702
|
};
|
package/esm/config/contracts.js
CHANGED
|
@@ -245,6 +245,9 @@ module.exports = {
|
|
|
245
245
|
"1": {
|
|
246
246
|
"address": "0xc3d688B66703497DAA19211EEdff47f25384cdc3"
|
|
247
247
|
},
|
|
248
|
+
"10": {
|
|
249
|
+
"address": "0x2e44e174f7D53F0212823acC11C01A11d58c5bCB"
|
|
250
|
+
},
|
|
248
251
|
"8453": {
|
|
249
252
|
"address": "0xb125E6687d4313864e53df431d5425969c15Eb2F"
|
|
250
253
|
},
|
|
@@ -293,6 +296,9 @@ module.exports = {
|
|
|
293
296
|
}
|
|
294
297
|
}
|
|
295
298
|
},
|
|
299
|
+
"10": {
|
|
300
|
+
"address": "0x969d845618596787DBc64687Ee90b16931BBBCBC"
|
|
301
|
+
},
|
|
296
302
|
"8453": {
|
|
297
303
|
"address": "0x22591183c0eb7B2Fe07F6F44fd360d1117D07b4f"
|
|
298
304
|
},
|
|
@@ -320,6 +326,9 @@ module.exports = {
|
|
|
320
326
|
"CompV3BulkerL2": {
|
|
321
327
|
"abi": [{ "inputs": [{ "internalType": "address", "name": "admin_", "type": "address" }, { "internalType": "address payable", "name": "wrappedNativeToken_", "type": "address" }], "stateMutability": "nonpayable", "type": "constructor" }, { "inputs": [], "name": "FailedToSendNativeToken", "type": "error" }, { "inputs": [], "name": "InvalidAddress", "type": "error" }, { "inputs": [], "name": "InvalidArgument", "type": "error" }, { "inputs": [], "name": "TransferInFailed", "type": "error" }, { "inputs": [], "name": "TransferOutFailed", "type": "error" }, { "inputs": [], "name": "Unauthorized", "type": "error" }, { "inputs": [], "name": "UnhandledAction", "type": "error" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "oldAdmin", "type": "address" }, { "indexed": true, "internalType": "address", "name": "newAdmin", "type": "address" }], "name": "AdminTransferred", "type": "event" }, { "inputs": [], "name": "ACTION_CLAIM_REWARD", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "ACTION_SUPPLY_ASSET", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "ACTION_SUPPLY_NATIVE_TOKEN", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "ACTION_TRANSFER_ASSET", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "ACTION_WITHDRAW_ASSET", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "ACTION_WITHDRAW_NATIVE_TOKEN", "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], "stateMutability": "view", "type": "function" }, { "inputs": [], "name": "admin", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "inputs": [{ "internalType": "bytes32[]", "name": "actions", "type": "bytes32[]" }, { "internalType": "bytes[]", "name": "data", "type": "bytes[]" }], "name": "invoke", "outputs": [], "stateMutability": "payable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "recipient", "type": "address" }], "name": "sweepNativeToken", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "recipient", "type": "address" }, { "internalType": "address", "name": "asset", "type": "address" }], "name": "sweepToken", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [{ "internalType": "address", "name": "newAdmin", "type": "address" }], "name": "transferAdmin", "outputs": [], "stateMutability": "nonpayable", "type": "function" }, { "inputs": [], "name": "wrappedNativeToken", "outputs": [{ "internalType": "address payable", "name": "", "type": "address" }], "stateMutability": "view", "type": "function" }, { "stateMutability": "payable", "type": "receive" }],
|
|
322
328
|
"networks": {
|
|
329
|
+
"10": {
|
|
330
|
+
"address": "0xcb3643CC8294B23171272845473dEc49739d4Ba3"
|
|
331
|
+
},
|
|
323
332
|
"8453": {
|
|
324
333
|
"address": "0x78D0677032A35c63D142a48A2037048871212a8C"
|
|
325
334
|
},
|
|
@@ -33,10 +33,11 @@ const BULKER_OPTIONS = {
|
|
|
33
33
|
[CompoundVersions.CompoundV3USDCe]: EMPTY_BULKER_OPTIONS,
|
|
34
34
|
},
|
|
35
35
|
[NetworkNumber.Opt]: {
|
|
36
|
+
[CompoundVersions.CompoundV3USDC]: STANDARD_BULKER_OPTIONS,
|
|
37
|
+
// Non-existing markets, keeping it because of typescript
|
|
36
38
|
[CompoundVersions.CompoundV3ETH]: EMPTY_BULKER_OPTIONS,
|
|
37
39
|
[CompoundVersions.CompoundV3USDbC]: EMPTY_BULKER_OPTIONS,
|
|
38
40
|
[CompoundVersions.CompoundV2]: EMPTY_BULKER_OPTIONS,
|
|
39
|
-
[CompoundVersions.CompoundV3USDC]: EMPTY_BULKER_OPTIONS,
|
|
40
41
|
[CompoundVersions.CompoundV3USDCe]: EMPTY_BULKER_OPTIONS,
|
|
41
42
|
},
|
|
42
43
|
};
|
|
@@ -56,7 +57,7 @@ export const COMPOUND_V2 = {
|
|
|
56
57
|
// icon: SvgAdapter(protocolIcons.compound),
|
|
57
58
|
};
|
|
58
59
|
export const COMPOUND_V3_USDC = (networkId) => ({
|
|
59
|
-
chainIds: [NetworkNumber.Eth, NetworkNumber.Arb, NetworkNumber.Base],
|
|
60
|
+
chainIds: [NetworkNumber.Eth, NetworkNumber.Arb, NetworkNumber.Base, NetworkNumber.Opt],
|
|
60
61
|
label: 'Compound V3 - USDC',
|
|
61
62
|
shortLabel: 'v3',
|
|
62
63
|
value: CompoundVersions.CompoundV3USDC,
|
|
@@ -2,9 +2,10 @@ export declare const compoundV2CollateralAssets: import("@defisaver/tokens/esm/t
|
|
|
2
2
|
export declare const v3USDCCollAssetsEth: string[];
|
|
3
3
|
export declare const v3USDCCollAssetsArb: string[];
|
|
4
4
|
export declare const v3USDCCollAssetsBase: string[];
|
|
5
|
+
export declare const v3USDCCollAssetsOpt: string[];
|
|
5
6
|
export declare const v3USDCCollAssets: {
|
|
6
7
|
readonly 1: string[];
|
|
7
|
-
readonly 10:
|
|
8
|
+
readonly 10: string[];
|
|
8
9
|
readonly 42161: string[];
|
|
9
10
|
readonly 8453: string[];
|
|
10
11
|
};
|
|
@@ -7,10 +7,11 @@ export const compoundV2CollateralAssets = [
|
|
|
7
7
|
export const v3USDCCollAssetsEth = ['ETH', 'COMP', 'WBTC', 'UNI', 'LINK'];
|
|
8
8
|
export const v3USDCCollAssetsArb = ['ARB', 'ETH', 'GMX', 'WBTC'];
|
|
9
9
|
export const v3USDCCollAssetsBase = ['ETH', 'cbETH'];
|
|
10
|
+
export const v3USDCCollAssetsOpt = ['ETH', 'OP', 'WBTC'];
|
|
10
11
|
// @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
|
|
11
12
|
export const v3USDCCollAssets = {
|
|
12
13
|
[NetworkNumber.Eth]: v3USDCCollAssetsEth,
|
|
13
|
-
[NetworkNumber.Opt]:
|
|
14
|
+
[NetworkNumber.Opt]: v3USDCCollAssetsOpt,
|
|
14
15
|
[NetworkNumber.Arb]: v3USDCCollAssetsArb,
|
|
15
16
|
[NetworkNumber.Base]: v3USDCCollAssetsBase,
|
|
16
17
|
};
|
package/esm/morphoBlue/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import Dec from 'decimal.js';
|
|
|
11
11
|
import { assetAmountInEth, getAssetInfo, getAssetInfoByAddress } from '@defisaver/tokens';
|
|
12
12
|
import { MorphoBlueViewContract, getConfigContractAbi, getConfigContractAddress, } from '../contracts';
|
|
13
13
|
import { WAD, SECONDS_PER_YEAR, USD_QUOTE } from '../constants';
|
|
14
|
-
import { getStakingApy } from '../staking';
|
|
14
|
+
import { getStakingApy, STAKING_ASSETS } from '../staking';
|
|
15
15
|
import { getAbiItem, wethToEth } from '../services/utils';
|
|
16
16
|
import { multicall } from '../multicall';
|
|
17
17
|
import { getMorphoBlueAggregatedPositionData } from '../helpers/morphoBlueHelpers';
|
|
@@ -96,7 +96,7 @@ export function getMorphoBlueMarketData(web3, network, selectedMarket, mainnetWe
|
|
|
96
96
|
canBeSupplied: true,
|
|
97
97
|
canBeBorrowed: false,
|
|
98
98
|
};
|
|
99
|
-
if (
|
|
99
|
+
if (STAKING_ASSETS.includes(collateralTokenInfo.symbol)) {
|
|
100
100
|
assetsData[collateralTokenInfo.symbol].incentiveSupplyApy = yield getStakingApy(collateralTokenInfo.symbol, mainnetWeb3);
|
|
101
101
|
assetsData[collateralTokenInfo.symbol].incentiveSupplyToken = collateralTokenInfo.symbol;
|
|
102
102
|
}
|
package/esm/staking/staking.d.ts
CHANGED
|
@@ -5,7 +5,8 @@ export declare const getCbETHApr: (web3: Web3, blockNumber?: 'latest' | number)
|
|
|
5
5
|
export declare const getREthApr: (web3: Web3, blockNumber?: 'latest' | number) => Promise<string>;
|
|
6
6
|
export declare const getDsrApy: (web3: Web3, blockNumber?: 'latest' | number) => Promise<string>;
|
|
7
7
|
export declare const getSUSDeApy: () => Promise<any>;
|
|
8
|
-
export declare const
|
|
8
|
+
export declare const STAKING_ASSETS: string[];
|
|
9
|
+
export declare const getStakingApy: (asset: string, web3: Web3, blockNumber?: 'latest' | number, fromBlock?: number | undefined) => Promise<any> | "0" | undefined;
|
|
9
10
|
export declare const calculateInterestEarned: (principal: string, interest: string, type: string, apy?: boolean) => number;
|
|
10
11
|
export declare const calculateNetApy: (usedAssets: MMUsedAssets, assetsData: MMAssetsData, isMorpho?: boolean) => {
|
|
11
12
|
netApy: string;
|
package/esm/staking/staking.js
CHANGED
|
@@ -81,17 +81,32 @@ export const getSUSDeApy = () => __awaiter(void 0, void 0, void 0, function* ()
|
|
|
81
81
|
const data = yield res.json();
|
|
82
82
|
return data.apy;
|
|
83
83
|
});
|
|
84
|
+
const getWeEthApr = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
85
|
+
const res = yield fetch('https://www.etherfi.bid/api/etherfi/apr');
|
|
86
|
+
const data = yield res.json();
|
|
87
|
+
const total = data.latest_aprs.reduce((acc, apr) => new Dec(acc).add(apr).toString());
|
|
88
|
+
return new Dec(total).div(data.latest_aprs.length).div(100).toString();
|
|
89
|
+
});
|
|
90
|
+
export const STAKING_ASSETS = ['cbETH', 'wstETH', 'cbETH', 'rETH', 'sDAI', 'weETH'];
|
|
84
91
|
export const getStakingApy = (asset, web3, blockNumber = 'latest', fromBlock = undefined) => {
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
92
|
+
try {
|
|
93
|
+
if (asset === 'stETH' || asset === 'wstETH')
|
|
94
|
+
return getStETHApr(web3, fromBlock, blockNumber);
|
|
95
|
+
if (asset === 'cbETH')
|
|
96
|
+
return getCbETHApr(web3, blockNumber);
|
|
97
|
+
if (asset === 'rETH')
|
|
98
|
+
return getREthApr(web3, blockNumber);
|
|
99
|
+
if (asset === 'sDAI')
|
|
100
|
+
return getDsrApy(web3);
|
|
101
|
+
if (asset === 'sUSDe')
|
|
102
|
+
return getSUSDeApy();
|
|
103
|
+
if (asset === 'weETH')
|
|
104
|
+
return getWeEthApr();
|
|
105
|
+
}
|
|
106
|
+
catch (e) {
|
|
107
|
+
console.error(`Failed to fetch APY for ${asset}`);
|
|
108
|
+
return '0';
|
|
109
|
+
}
|
|
95
110
|
};
|
|
96
111
|
export const calculateInterestEarned = (principal, interest, type, apy = false) => {
|
|
97
112
|
let interval = 1;
|
package/package.json
CHANGED
package/src/aaveV3/index.ts
CHANGED
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
import {
|
|
27
27
|
Blockish, EthAddress, NetworkNumber, PositionBalances,
|
|
28
28
|
} from '../types/common';
|
|
29
|
-
import {
|
|
29
|
+
import {calculateNetApy, getStakingApy, STAKING_ASSETS} from '../staking';
|
|
30
30
|
import { multicall } from '../multicall';
|
|
31
31
|
import { IUiIncentiveDataProviderV3 } from '../types/contracts/generated/AaveUiIncentiveDataProviderV3';
|
|
32
32
|
import { getAssetsBalances } from '../assets';
|
|
@@ -268,7 +268,7 @@ export async function getAaveV3MarketData(web3: Web3, network: NetworkNumber, ma
|
|
|
268
268
|
await Promise.all(assetsData.map(async (_market: AaveV3AssetData) => {
|
|
269
269
|
/* eslint-disable no-param-reassign */
|
|
270
270
|
const rewardForMarket: IUiIncentiveDataProviderV3.AggregatedReserveIncentiveDataStructOutput | undefined = rewardInfo?.[_market.underlyingTokenAddress as any];
|
|
271
|
-
if (
|
|
271
|
+
if (STAKING_ASSETS.includes(_market.symbol)) {
|
|
272
272
|
_market.incentiveSupplyApy = await getStakingApy(_market.symbol, defaultWeb3);
|
|
273
273
|
_market.incentiveSupplyToken = _market.symbol;
|
|
274
274
|
}
|
package/src/config/contracts.js
CHANGED
|
@@ -245,6 +245,9 @@ module.exports = {
|
|
|
245
245
|
"1": {
|
|
246
246
|
"address": "0xc3d688B66703497DAA19211EEdff47f25384cdc3"
|
|
247
247
|
},
|
|
248
|
+
"10": {
|
|
249
|
+
"address": "0x2e44e174f7D53F0212823acC11C01A11d58c5bCB"
|
|
250
|
+
},
|
|
248
251
|
"8453": {
|
|
249
252
|
"address": "0xb125E6687d4313864e53df431d5425969c15Eb2F"
|
|
250
253
|
},
|
|
@@ -293,6 +296,9 @@ module.exports = {
|
|
|
293
296
|
}
|
|
294
297
|
}
|
|
295
298
|
},
|
|
299
|
+
"10": {
|
|
300
|
+
"address": "0x969d845618596787DBc64687Ee90b16931BBBCBC"
|
|
301
|
+
},
|
|
296
302
|
"8453": {
|
|
297
303
|
"address": "0x22591183c0eb7B2Fe07F6F44fd360d1117D07b4f"
|
|
298
304
|
},
|
|
@@ -320,6 +326,9 @@ module.exports = {
|
|
|
320
326
|
"CompV3BulkerL2": {
|
|
321
327
|
"abi": [{"inputs":[{"internalType":"address","name":"admin_","type":"address"},{"internalType":"address payable","name":"wrappedNativeToken_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"FailedToSendNativeToken","type":"error"},{"inputs":[],"name":"InvalidAddress","type":"error"},{"inputs":[],"name":"InvalidArgument","type":"error"},{"inputs":[],"name":"TransferInFailed","type":"error"},{"inputs":[],"name":"TransferOutFailed","type":"error"},{"inputs":[],"name":"Unauthorized","type":"error"},{"inputs":[],"name":"UnhandledAction","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldAdmin","type":"address"},{"indexed":true,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminTransferred","type":"event"},{"inputs":[],"name":"ACTION_CLAIM_REWARD","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ACTION_SUPPLY_ASSET","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ACTION_SUPPLY_NATIVE_TOKEN","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ACTION_TRANSFER_ASSET","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ACTION_WITHDRAW_ASSET","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"ACTION_WITHDRAW_NATIVE_TOKEN","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"admin","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32[]","name":"actions","type":"bytes32[]"},{"internalType":"bytes[]","name":"data","type":"bytes[]"}],"name":"invoke","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"}],"name":"sweepNativeToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"asset","type":"address"}],"name":"sweepToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAdmin","type":"address"}],"name":"transferAdmin","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"wrappedNativeToken","outputs":[{"internalType":"address payable","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"stateMutability":"payable","type":"receive"}],
|
|
322
328
|
"networks": {
|
|
329
|
+
"10": {
|
|
330
|
+
"address": "0xcb3643CC8294B23171272845473dEc49739d4Ba3"
|
|
331
|
+
},
|
|
323
332
|
"8453": {
|
|
324
333
|
"address": "0x78D0677032A35c63D142a48A2037048871212a8C"
|
|
325
334
|
},
|
|
@@ -44,11 +44,12 @@ const BULKER_OPTIONS: Record<NetworkNumber, Record<CompoundVersions, CompoundBul
|
|
|
44
44
|
[CompoundVersions.CompoundV2]: EMPTY_BULKER_OPTIONS,
|
|
45
45
|
[CompoundVersions.CompoundV3USDCe]: EMPTY_BULKER_OPTIONS,
|
|
46
46
|
},
|
|
47
|
-
[NetworkNumber.Opt]: {
|
|
47
|
+
[NetworkNumber.Opt]: {
|
|
48
|
+
[CompoundVersions.CompoundV3USDC]: STANDARD_BULKER_OPTIONS,
|
|
49
|
+
// Non-existing markets, keeping it because of typescript
|
|
48
50
|
[CompoundVersions.CompoundV3ETH]: EMPTY_BULKER_OPTIONS,
|
|
49
51
|
[CompoundVersions.CompoundV3USDbC]: EMPTY_BULKER_OPTIONS,
|
|
50
52
|
[CompoundVersions.CompoundV2]: EMPTY_BULKER_OPTIONS,
|
|
51
|
-
[CompoundVersions.CompoundV3USDC]: EMPTY_BULKER_OPTIONS,
|
|
52
53
|
[CompoundVersions.CompoundV3USDCe]: EMPTY_BULKER_OPTIONS,
|
|
53
54
|
},
|
|
54
55
|
};
|
|
@@ -70,7 +71,7 @@ export const COMPOUND_V2: CompoundMarketData = {
|
|
|
70
71
|
};
|
|
71
72
|
|
|
72
73
|
export const COMPOUND_V3_USDC = (networkId: NetworkNumber): CompoundMarketData => ({
|
|
73
|
-
chainIds: [NetworkNumber.Eth, NetworkNumber.Arb, NetworkNumber.Base],
|
|
74
|
+
chainIds: [NetworkNumber.Eth, NetworkNumber.Arb, NetworkNumber.Base, NetworkNumber.Opt],
|
|
74
75
|
label: 'Compound V3 - USDC',
|
|
75
76
|
shortLabel: 'v3',
|
|
76
77
|
value: CompoundVersions.CompoundV3USDC,
|
|
@@ -9,11 +9,12 @@ export const compoundV2CollateralAssets = [
|
|
|
9
9
|
export const v3USDCCollAssetsEth = ['ETH', 'COMP', 'WBTC', 'UNI', 'LINK'];
|
|
10
10
|
export const v3USDCCollAssetsArb = ['ARB', 'ETH', 'GMX', 'WBTC'];
|
|
11
11
|
export const v3USDCCollAssetsBase = ['ETH', 'cbETH'];
|
|
12
|
+
export const v3USDCCollAssetsOpt = ['ETH', 'OP', 'WBTC'];
|
|
12
13
|
|
|
13
14
|
// @dev Keep assets in array, do not assign directly, so we can parse it and edit it programmatically with `scripts/updateMarkets`
|
|
14
15
|
export const v3USDCCollAssets = {
|
|
15
16
|
[NetworkNumber.Eth]: v3USDCCollAssetsEth,
|
|
16
|
-
[NetworkNumber.Opt]:
|
|
17
|
+
[NetworkNumber.Opt]: v3USDCCollAssetsOpt,
|
|
17
18
|
[NetworkNumber.Arb]: v3USDCCollAssetsArb,
|
|
18
19
|
[NetworkNumber.Base]: v3USDCCollAssetsBase,
|
|
19
20
|
} as const;
|
package/src/morphoBlue/index.ts
CHANGED
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
MorphoBlueAssetsData, MorphoBlueMarketData, MorphoBlueMarketInfo, MorphoBluePositionData,
|
|
11
11
|
} from '../types';
|
|
12
12
|
import { WAD, SECONDS_PER_YEAR, USD_QUOTE } from '../constants';
|
|
13
|
-
import {
|
|
13
|
+
import {getStakingApy, STAKING_ASSETS} from '../staking';
|
|
14
14
|
import { getAbiItem, wethToEth } from '../services/utils';
|
|
15
15
|
import { multicall } from '../multicall';
|
|
16
16
|
import { getMorphoBlueAggregatedPositionData } from '../helpers/morphoBlueHelpers';
|
|
@@ -112,7 +112,7 @@ export async function getMorphoBlueMarketData(web3: Web3, network: NetworkNumber
|
|
|
112
112
|
canBeBorrowed: false,
|
|
113
113
|
};
|
|
114
114
|
|
|
115
|
-
if (
|
|
115
|
+
if (STAKING_ASSETS.includes(collateralTokenInfo.symbol)) {
|
|
116
116
|
assetsData[collateralTokenInfo.symbol].incentiveSupplyApy = await getStakingApy(collateralTokenInfo.symbol, mainnetWeb3);
|
|
117
117
|
assetsData[collateralTokenInfo.symbol].incentiveSupplyToken = collateralTokenInfo.symbol;
|
|
118
118
|
}
|
|
@@ -175,4 +175,4 @@ export async function getMorphoBlueAccountData(web3: Web3, network: NetworkNumbe
|
|
|
175
175
|
usedAssets,
|
|
176
176
|
...getMorphoBlueAggregatedPositionData({ usedAssets, assetsData: marketInfo.assetsData, marketInfo }),
|
|
177
177
|
};
|
|
178
|
-
}
|
|
178
|
+
}
|
package/src/staking/staking.ts
CHANGED
|
@@ -82,12 +82,27 @@ export const getSUSDeApy = async () => {
|
|
|
82
82
|
return data.apy;
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
+
const getWeEthApr = async () => {
|
|
86
|
+
const res = await fetch('https://www.etherfi.bid/api/etherfi/apr');
|
|
87
|
+
const data = await res.json();
|
|
88
|
+
const total = (data.latest_aprs as string[]).reduce((acc,apr) => new Dec(acc).add(apr).toString());
|
|
89
|
+
return new Dec(total).div(data.latest_aprs.length).div(100).toString();
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export const STAKING_ASSETS = ['cbETH', 'wstETH', 'cbETH', 'rETH', 'sDAI','weETH'];
|
|
93
|
+
|
|
85
94
|
export const getStakingApy = (asset: string, web3: Web3, blockNumber: 'latest' | number = 'latest', fromBlock: number | undefined = undefined) => {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
95
|
+
try {
|
|
96
|
+
if (asset === 'stETH' || asset === 'wstETH') return getStETHApr(web3, fromBlock, blockNumber);
|
|
97
|
+
if (asset === 'cbETH') return getCbETHApr(web3, blockNumber);
|
|
98
|
+
if (asset === 'rETH') return getREthApr(web3, blockNumber);
|
|
99
|
+
if (asset === 'sDAI') return getDsrApy(web3);
|
|
100
|
+
if (asset === 'sUSDe') return getSUSDeApy();
|
|
101
|
+
if (asset === 'weETH') return getWeEthApr();
|
|
102
|
+
} catch (e) {
|
|
103
|
+
console.error(`Failed to fetch APY for ${asset}`);
|
|
104
|
+
return '0';
|
|
105
|
+
}
|
|
91
106
|
};
|
|
92
107
|
|
|
93
108
|
export const calculateInterestEarned = (principal: string, interest: string, type: string, apy = false) => {
|
|
@@ -172,4 +187,4 @@ export const getStETHByWstETHMultiple = async (wstEthAmounts: string[] | number[
|
|
|
172
187
|
}));
|
|
173
188
|
const stEthAmounts = await multicall(calls, web3);
|
|
174
189
|
return stEthAmounts.map((arr) => arr[0]);
|
|
175
|
-
};
|
|
190
|
+
};
|