@defisaver/positions-sdk 1.0.10 → 1.0.11-fluid-dev
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/.mocharc.json +4 -4
- package/.nvmrc +1 -1
- package/README.md +69 -69
- package/cjs/config/contracts.d.ts +113 -49
- package/cjs/config/contracts.js +10 -2
- package/cjs/contracts.d.ts +1 -0
- package/cjs/contracts.js +2 -1
- package/cjs/fluid/index.d.ts +2 -0
- package/cjs/fluid/index.js +636 -13
- package/cjs/helpers/fluidHelpers/index.d.ts +59 -2
- package/cjs/helpers/fluidHelpers/index.js +142 -4
- package/cjs/helpers/morphoBlueHelpers/index.js +66 -66
- package/cjs/markets/aave/marketAssets.js +3 -1
- package/cjs/markets/fluid/index.js +276 -245
- package/cjs/services/priceService.d.ts +23 -0
- package/cjs/services/priceService.js +44 -5
- package/cjs/types/contracts/generated/FluidView.d.ts +220 -3
- package/cjs/types/contracts/generated/WeETHPriceFeed.d.ts +135 -0
- package/cjs/types/contracts/generated/WeETHPriceFeed.js +5 -0
- package/cjs/types/contracts/generated/index.d.ts +1 -0
- package/cjs/types/fluid.d.ts +39 -10
- package/esm/config/contracts.d.ts +113 -49
- package/esm/config/contracts.js +10 -2
- package/esm/contracts.d.ts +1 -0
- package/esm/contracts.js +1 -0
- package/esm/fluid/index.d.ts +2 -0
- package/esm/fluid/index.js +639 -16
- package/esm/helpers/fluidHelpers/index.d.ts +59 -2
- package/esm/helpers/fluidHelpers/index.js +137 -3
- package/esm/helpers/morphoBlueHelpers/index.js +66 -66
- package/esm/markets/aave/marketAssets.js +3 -1
- package/esm/markets/fluid/index.js +276 -245
- package/esm/services/priceService.d.ts +23 -0
- package/esm/services/priceService.js +40 -5
- package/esm/types/contracts/generated/FluidView.d.ts +220 -3
- package/esm/types/contracts/generated/WeETHPriceFeed.d.ts +135 -0
- package/esm/types/contracts/generated/WeETHPriceFeed.js +4 -0
- package/esm/types/contracts/generated/index.d.ts +1 -0
- package/esm/types/fluid.d.ts +39 -10
- package/package.json +54 -54
- package/src/aaveV2/index.ts +227 -227
- package/src/aaveV3/index.ts +624 -624
- package/src/assets/index.ts +60 -60
- package/src/chickenBonds/index.ts +123 -123
- package/src/compoundV2/index.ts +220 -220
- package/src/compoundV3/index.ts +291 -291
- package/src/config/contracts.js +1155 -1147
- package/src/constants/index.ts +6 -6
- package/src/contracts.ts +135 -134
- package/src/curveUsd/index.ts +239 -239
- package/src/eulerV2/index.ts +303 -303
- package/src/exchange/index.ts +17 -17
- package/src/fluid/index.ts +1216 -354
- package/src/helpers/aaveHelpers/index.ts +203 -203
- package/src/helpers/chickenBondsHelpers/index.ts +23 -23
- package/src/helpers/compoundHelpers/index.ts +248 -248
- package/src/helpers/curveUsdHelpers/index.ts +40 -40
- package/src/helpers/eulerHelpers/index.ts +234 -234
- package/src/helpers/fluidHelpers/index.ts +295 -57
- package/src/helpers/index.ts +11 -11
- package/src/helpers/liquityV2Helpers/index.ts +80 -80
- package/src/helpers/llamaLendHelpers/index.ts +53 -53
- package/src/helpers/makerHelpers/index.ts +94 -94
- package/src/helpers/morphoBlueHelpers/index.ts +367 -367
- package/src/helpers/sparkHelpers/index.ts +154 -154
- package/src/index.ts +52 -52
- package/src/liquity/index.ts +116 -116
- package/src/liquityV2/index.ts +295 -295
- package/src/llamaLend/index.ts +275 -275
- package/src/maker/index.ts +117 -117
- package/src/markets/aave/index.ts +152 -152
- package/src/markets/aave/marketAssets.ts +46 -44
- package/src/markets/compound/index.ts +213 -213
- package/src/markets/compound/marketsAssets.ts +82 -82
- package/src/markets/curveUsd/index.ts +69 -69
- package/src/markets/euler/index.ts +26 -26
- package/src/markets/fluid/index.ts +2043 -2012
- package/src/markets/index.ts +27 -27
- package/src/markets/liquityV2/index.ts +54 -54
- package/src/markets/llamaLend/contractAddresses.ts +141 -141
- package/src/markets/llamaLend/index.ts +235 -235
- package/src/markets/morphoBlue/index.ts +895 -895
- package/src/markets/spark/index.ts +29 -29
- package/src/markets/spark/marketAssets.ts +10 -10
- package/src/moneymarket/moneymarketCommonService.ts +80 -80
- package/src/morphoAaveV2/index.ts +256 -256
- package/src/morphoAaveV3/index.ts +630 -630
- package/src/morphoBlue/index.ts +202 -202
- package/src/multicall/index.ts +33 -33
- package/src/services/priceService.ts +130 -91
- package/src/services/utils.ts +59 -59
- package/src/setup.ts +8 -8
- package/src/spark/index.ts +460 -460
- package/src/staking/staking.ts +217 -217
- package/src/types/aave.ts +275 -275
- package/src/types/chickenBonds.ts +45 -45
- package/src/types/common.ts +84 -84
- package/src/types/compound.ts +133 -133
- package/src/types/contracts/generated/FluidView.ts +263 -2
- package/src/types/contracts/generated/WeETHPriceFeed.ts +202 -0
- package/src/types/contracts/generated/index.ts +1 -0
- package/src/types/curveUsd.ts +119 -119
- package/src/types/euler.ts +173 -173
- package/src/types/fluid.ts +299 -268
- package/src/types/index.ts +11 -11
- package/src/types/liquity.ts +30 -30
- package/src/types/liquityV2.ts +119 -119
- package/src/types/llamaLend.ts +155 -155
- package/src/types/maker.ts +50 -50
- package/src/types/morphoBlue.ts +194 -194
- package/src/types/spark.ts +135 -135
|
@@ -1,6 +1,63 @@
|
|
|
1
|
-
import { FluidAggregatedVaultData, FluidAssetsData, FluidUsedAssets, InnerFluidMarketData } from '../../types';
|
|
1
|
+
import { FluidAggregatedVaultData, FluidAssetData, FluidAssetsData, FluidUsedAsset, FluidUsedAssets, InnerFluidMarketData } from '../../types';
|
|
2
|
+
import { FluidView } from '../../types/contracts/generated';
|
|
2
3
|
export declare const getFluidAggregatedData: ({ usedAssets, assetsData, marketData, }: {
|
|
3
4
|
usedAssets: FluidUsedAssets;
|
|
4
5
|
marketData: InnerFluidMarketData;
|
|
5
6
|
assetsData: FluidAssetsData;
|
|
6
|
-
}) => FluidAggregatedVaultData;
|
|
7
|
+
}, supplyShares?: string, borrowShares?: string) => FluidAggregatedVaultData;
|
|
8
|
+
interface DexSupplyData {
|
|
9
|
+
maxSupplyShares: string;
|
|
10
|
+
supplyDexFee: string;
|
|
11
|
+
token0PerSupplyShare: string;
|
|
12
|
+
token1PerSupplyShare: string;
|
|
13
|
+
withdrawable0: string;
|
|
14
|
+
withdrawable1: string;
|
|
15
|
+
withdrawableShares: string;
|
|
16
|
+
utilizationSupply0: string;
|
|
17
|
+
utilizationSupply1: string;
|
|
18
|
+
supplyRate0: string;
|
|
19
|
+
supplyRate1: string;
|
|
20
|
+
totalSupplyShares: string;
|
|
21
|
+
withdrawableToken0: string;
|
|
22
|
+
withdrawableToken1: string;
|
|
23
|
+
totalSupplyToken0: string;
|
|
24
|
+
totalSupplyToken1: string;
|
|
25
|
+
reservesSupplyToken0: string;
|
|
26
|
+
reservesSupplyToken1: string;
|
|
27
|
+
}
|
|
28
|
+
export declare const parseDexSupplyData: (dexSupplyData: FluidView.DexSupplyDataStructOutput, collAsset0: string, collAsset1: string) => DexSupplyData;
|
|
29
|
+
interface DexBorrowData {
|
|
30
|
+
maxBorrowShares: string;
|
|
31
|
+
borrowDexFee: string;
|
|
32
|
+
token0PerBorrowShare: string;
|
|
33
|
+
token1PerBorrowShare: string;
|
|
34
|
+
borrowable0: string;
|
|
35
|
+
borrowable1: string;
|
|
36
|
+
utilizationBorrow0: string;
|
|
37
|
+
utilizationBorrow1: string;
|
|
38
|
+
borrowRate0: string;
|
|
39
|
+
borrowRate1: string;
|
|
40
|
+
totalBorrowShares: string;
|
|
41
|
+
borrowableToken0: string;
|
|
42
|
+
borrowableToken1: string;
|
|
43
|
+
totalBorrowToken0: string;
|
|
44
|
+
totalBorrowToken1: string;
|
|
45
|
+
borrowableShares: string;
|
|
46
|
+
quoteTokensPerShare: string;
|
|
47
|
+
reservesBorrowToken0: string;
|
|
48
|
+
reservesBorrowToken1: string;
|
|
49
|
+
}
|
|
50
|
+
export declare const parseDexBorrowData: (dexBorrowData: FluidView.DexBorrowDataStructOutput, debtAsset0: string, debtAsset1: string) => DexBorrowData;
|
|
51
|
+
export declare const mergeAssetData: (existing: Partial<FluidAssetData> | undefined, additional: Partial<FluidAssetData>) => FluidAssetData;
|
|
52
|
+
export declare const EMPTY_USED_ASSET: {
|
|
53
|
+
isSupplied: boolean;
|
|
54
|
+
isBorrowed: boolean;
|
|
55
|
+
supplied: string;
|
|
56
|
+
suppliedUsd: string;
|
|
57
|
+
borrowed: string;
|
|
58
|
+
borrowedUsd: string;
|
|
59
|
+
symbol: string;
|
|
60
|
+
collateral: boolean;
|
|
61
|
+
};
|
|
62
|
+
export declare const mergeUsedAssets: (existing: Partial<FluidUsedAsset> | undefined, additional: Partial<FluidUsedAsset>) => FluidUsedAsset;
|
|
63
|
+
export {};
|
|
@@ -3,14 +3,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.getFluidAggregatedData = void 0;
|
|
6
|
+
exports.mergeUsedAssets = exports.EMPTY_USED_ASSET = exports.mergeAssetData = exports.parseDexBorrowData = exports.parseDexSupplyData = exports.getFluidAggregatedData = void 0;
|
|
7
7
|
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
8
|
+
const tokens_1 = require("@defisaver/tokens");
|
|
9
|
+
const types_1 = require("../../types");
|
|
8
10
|
const moneymarket_1 = require("../../moneymarket");
|
|
9
11
|
const staking_1 = require("../../staking");
|
|
10
|
-
const
|
|
12
|
+
const utils_1 = require("../../services/utils");
|
|
13
|
+
const getFluidAggregatedData = ({ usedAssets, assetsData, marketData, }, supplyShares, borrowShares) => {
|
|
11
14
|
const payload = {};
|
|
12
|
-
payload.suppliedUsd =
|
|
13
|
-
|
|
15
|
+
payload.suppliedUsd = [types_1.FluidVaultType.T1, types_1.FluidVaultType.T3].includes(marketData.vaultType)
|
|
16
|
+
? (0, moneymarket_1.getAssetsTotal)(usedAssets, ({ isSupplied }) => isSupplied, ({ suppliedUsd }) => suppliedUsd)
|
|
17
|
+
: new decimal_js_1.default(marketData.collSharePrice).mul(supplyShares).toString();
|
|
18
|
+
payload.borrowedUsd = [types_1.FluidVaultType.T1, types_1.FluidVaultType.T2].includes(marketData.vaultType)
|
|
19
|
+
? (0, moneymarket_1.getAssetsTotal)(usedAssets, ({ isBorrowed }) => isBorrowed, ({ borrowedUsd }) => borrowedUsd)
|
|
20
|
+
: new decimal_js_1.default(marketData.debtSharePrice).mul(borrowShares).toString();
|
|
14
21
|
const { netApy, incentiveUsd, totalInterestUsd } = (0, staking_1.calculateNetApy)({ usedAssets, assetsData: assetsData });
|
|
15
22
|
payload.netApy = netApy;
|
|
16
23
|
payload.incentiveUsd = incentiveUsd;
|
|
@@ -41,3 +48,134 @@ const getFluidAggregatedData = ({ usedAssets, assetsData, marketData, }) => {
|
|
|
41
48
|
return payload;
|
|
42
49
|
};
|
|
43
50
|
exports.getFluidAggregatedData = getFluidAggregatedData;
|
|
51
|
+
const parseDexSupplyData = (dexSupplyData, collAsset0, collAsset1) => {
|
|
52
|
+
const { dexPool, // address of the dex pool
|
|
53
|
+
dexId, // id of the dex pool
|
|
54
|
+
fee: _fee, // fee of the dex pool TODO videti sa Rajkom
|
|
55
|
+
lastStoredPrice, // last stored price of the dex pool
|
|
56
|
+
centerPrice, // center price of the dex pool
|
|
57
|
+
token0Utilization, // token0 utilization
|
|
58
|
+
token1Utilization, // token1 utilization
|
|
59
|
+
// ONLY FOR SUPPLY
|
|
60
|
+
totalSupplyShares: totalSupplySharesWei, // total supply shares, in 1e18
|
|
61
|
+
maxSupplyShares: maxSupplySharesWei, // max supply shares, in 1e18
|
|
62
|
+
token0Supplied, // token0 supplied, in token0 decimals
|
|
63
|
+
token1Supplied, // token1 supplied, in token1 decimals
|
|
64
|
+
sharesWithdrawable, // shares withdrawable, in 1e18
|
|
65
|
+
token0Withdrawable, // token0 withdrawable, in token0 decimals
|
|
66
|
+
token1Withdrawable, // token1 withdrawable, in token1 decimals
|
|
67
|
+
token0PerSupplyShare: token0PerSupplyShareWei, // token0 amount per 1e18 supply shares
|
|
68
|
+
token1PerSupplyShare: token1PerSupplyShareWei, // token1 amount per 1e18 supply shares
|
|
69
|
+
token0SupplyRate, // token0 supply rate. E.g 320 = 3.2% APR
|
|
70
|
+
token1SupplyRate, // token1 supply rate. E.g 320 = 3.2% APR
|
|
71
|
+
supplyToken0Reserves, // token0 reserves in the dex pool
|
|
72
|
+
supplyToken1Reserves, // token1 reserves in the dex pool
|
|
73
|
+
} = dexSupplyData;
|
|
74
|
+
const maxSupplyShares = (0, utils_1.getEthAmountForDecimals)(maxSupplySharesWei, 18);
|
|
75
|
+
const fee = new decimal_js_1.default(_fee).div(100).toString();
|
|
76
|
+
const token0PerSupplyShare = (0, tokens_1.assetAmountInEth)(token0PerSupplyShareWei, collAsset0);
|
|
77
|
+
const token1PerSupplyShare = (0, tokens_1.assetAmountInEth)(token1PerSupplyShareWei, collAsset1);
|
|
78
|
+
const withdrawable0 = (0, tokens_1.assetAmountInEth)(token0Withdrawable, collAsset0);
|
|
79
|
+
const withdrawable1 = (0, tokens_1.assetAmountInEth)(token1Withdrawable, collAsset1);
|
|
80
|
+
const utilizationSupply0 = (0, tokens_1.assetAmountInEth)(token0Utilization, collAsset0);
|
|
81
|
+
const utilizationSupply1 = (0, tokens_1.assetAmountInEth)(token1Utilization, collAsset1);
|
|
82
|
+
const supplyRate0 = new decimal_js_1.default(token0SupplyRate).div(100).toString();
|
|
83
|
+
const supplyRate1 = new decimal_js_1.default(token1SupplyRate).div(100).toString();
|
|
84
|
+
const totalSupplyShares = (0, utils_1.getEthAmountForDecimals)(totalSupplySharesWei, 18); // in shares
|
|
85
|
+
const withdrawableShares = (0, utils_1.getEthAmountForDecimals)(sharesWithdrawable, 18);
|
|
86
|
+
const withdrawableToken0 = new decimal_js_1.default(withdrawableShares).mul(token0PerSupplyShare).div(1e18).toString();
|
|
87
|
+
const withdrawableToken1 = new decimal_js_1.default(withdrawableShares).mul(token1PerSupplyShare).div(1e18).toString();
|
|
88
|
+
const totalSupplyToken0 = (0, tokens_1.assetAmountInEth)(token0Supplied, collAsset0);
|
|
89
|
+
const totalSupplyToken1 = (0, tokens_1.assetAmountInEth)(token1Supplied, collAsset1);
|
|
90
|
+
const reservesSupplyToken0 = (0, tokens_1.assetAmountInEth)(supplyToken0Reserves, collAsset0);
|
|
91
|
+
const reservesSupplyToken1 = (0, tokens_1.assetAmountInEth)(supplyToken1Reserves, collAsset1);
|
|
92
|
+
return {
|
|
93
|
+
maxSupplyShares,
|
|
94
|
+
withdrawableShares,
|
|
95
|
+
supplyDexFee: fee,
|
|
96
|
+
token0PerSupplyShare,
|
|
97
|
+
token1PerSupplyShare,
|
|
98
|
+
withdrawable0,
|
|
99
|
+
withdrawable1,
|
|
100
|
+
utilizationSupply0,
|
|
101
|
+
utilizationSupply1,
|
|
102
|
+
supplyRate0,
|
|
103
|
+
supplyRate1,
|
|
104
|
+
totalSupplyShares,
|
|
105
|
+
withdrawableToken0,
|
|
106
|
+
withdrawableToken1,
|
|
107
|
+
totalSupplyToken0,
|
|
108
|
+
totalSupplyToken1,
|
|
109
|
+
reservesSupplyToken0,
|
|
110
|
+
reservesSupplyToken1,
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
exports.parseDexSupplyData = parseDexSupplyData;
|
|
114
|
+
const parseDexBorrowData = (dexBorrowData, debtAsset0, debtAsset1) => {
|
|
115
|
+
const { dexPool, dexId, fee: _fee, lastStoredPrice, centerPrice, token0Utilization, token1Utilization, totalBorrowShares: totalBorrowSharesWei, maxBorrowShares: maxBorrowSharesWei, token0Borrowed, token1Borrowed, sharesBorrowable, token0Borrowable, token1Borrowable, token0PerBorrowShare: token0PerBorrowShareWei, token1PerBorrowShare: token1PerBorrowShareWei, token0BorrowRate, token1BorrowRate, quoteTokensPerShare, borrowToken0Reserves, borrowToken1Reserves, } = dexBorrowData;
|
|
116
|
+
const maxBorrowShares = (0, utils_1.getEthAmountForDecimals)(maxBorrowSharesWei, 18);
|
|
117
|
+
const fee = new decimal_js_1.default(_fee).div(100).toString();
|
|
118
|
+
const token0PerBorrowShare = (0, tokens_1.assetAmountInEth)(token0PerBorrowShareWei, debtAsset0);
|
|
119
|
+
const token1PerBorrowShare = (0, tokens_1.assetAmountInEth)(token1PerBorrowShareWei, debtAsset1);
|
|
120
|
+
const borrowable0 = (0, tokens_1.assetAmountInEth)(token0Borrowable, debtAsset0);
|
|
121
|
+
const borrowable1 = (0, tokens_1.assetAmountInEth)(token1Borrowable, debtAsset1);
|
|
122
|
+
const utilizationBorrow0 = (0, tokens_1.assetAmountInEth)(token0Utilization, debtAsset0);
|
|
123
|
+
const utilizationBorrow1 = (0, tokens_1.assetAmountInEth)(token1Utilization, debtAsset1);
|
|
124
|
+
const borrowRate0 = new decimal_js_1.default(token0BorrowRate).div(100).toString();
|
|
125
|
+
const borrowRate1 = new decimal_js_1.default(token1BorrowRate).div(100).toString();
|
|
126
|
+
const totalBorrowShares = (0, utils_1.getEthAmountForDecimals)(totalBorrowSharesWei, 18); // in shares
|
|
127
|
+
const borrowableShares = (0, utils_1.getEthAmountForDecimals)(sharesBorrowable, 18);
|
|
128
|
+
const borrowableToken0 = new decimal_js_1.default(borrowableShares).mul(token0PerBorrowShare).div(1e18).toString();
|
|
129
|
+
const borrowableToken1 = new decimal_js_1.default(borrowableShares).mul(token1PerBorrowShare).div(1e18).toString();
|
|
130
|
+
const totalBorrowToken0 = (0, tokens_1.assetAmountInEth)(token0Borrowed, debtAsset0);
|
|
131
|
+
const totalBorrowToken1 = (0, tokens_1.assetAmountInEth)(token1Borrowed, debtAsset1);
|
|
132
|
+
const reservesBorrowToken0 = (0, tokens_1.assetAmountInEth)(borrowToken0Reserves, debtAsset0);
|
|
133
|
+
const reservesBorrowToken1 = (0, tokens_1.assetAmountInEth)(borrowToken1Reserves, debtAsset1);
|
|
134
|
+
return {
|
|
135
|
+
borrowableShares,
|
|
136
|
+
maxBorrowShares,
|
|
137
|
+
borrowDexFee: fee,
|
|
138
|
+
token0PerBorrowShare,
|
|
139
|
+
token1PerBorrowShare,
|
|
140
|
+
borrowable0,
|
|
141
|
+
borrowable1,
|
|
142
|
+
utilizationBorrow0,
|
|
143
|
+
utilizationBorrow1,
|
|
144
|
+
borrowRate0,
|
|
145
|
+
borrowRate1,
|
|
146
|
+
totalBorrowShares,
|
|
147
|
+
borrowableToken0,
|
|
148
|
+
borrowableToken1,
|
|
149
|
+
totalBorrowToken0,
|
|
150
|
+
totalBorrowToken1,
|
|
151
|
+
quoteTokensPerShare: (0, utils_1.getEthAmountForDecimals)(quoteTokensPerShare, 27),
|
|
152
|
+
reservesBorrowToken0,
|
|
153
|
+
reservesBorrowToken1,
|
|
154
|
+
};
|
|
155
|
+
};
|
|
156
|
+
exports.parseDexBorrowData = parseDexBorrowData;
|
|
157
|
+
const EMPTY_ASSET_DATA = {
|
|
158
|
+
symbol: '',
|
|
159
|
+
address: '',
|
|
160
|
+
price: '0',
|
|
161
|
+
totalSupply: '',
|
|
162
|
+
totalBorrow: '0',
|
|
163
|
+
canBeSupplied: false,
|
|
164
|
+
canBeBorrowed: false,
|
|
165
|
+
supplyRate: '0',
|
|
166
|
+
borrowRate: '0',
|
|
167
|
+
};
|
|
168
|
+
const mergeAssetData = (existing = {}, additional) => (Object.assign(Object.assign(Object.assign({}, EMPTY_ASSET_DATA), existing), additional));
|
|
169
|
+
exports.mergeAssetData = mergeAssetData;
|
|
170
|
+
exports.EMPTY_USED_ASSET = {
|
|
171
|
+
isSupplied: false,
|
|
172
|
+
isBorrowed: false,
|
|
173
|
+
supplied: '0',
|
|
174
|
+
suppliedUsd: '0',
|
|
175
|
+
borrowed: '0',
|
|
176
|
+
borrowedUsd: '0',
|
|
177
|
+
symbol: '',
|
|
178
|
+
collateral: false,
|
|
179
|
+
};
|
|
180
|
+
const mergeUsedAssets = (existing = {}, additional) => (Object.assign(Object.assign(Object.assign({}, exports.EMPTY_USED_ASSET), existing), additional));
|
|
181
|
+
exports.mergeUsedAssets = mergeUsedAssets;
|
|
@@ -117,73 +117,73 @@ const getApyAfterValuesEstimation = (selectedMarket, actions, web3, network) =>
|
|
|
117
117
|
});
|
|
118
118
|
exports.getApyAfterValuesEstimation = getApyAfterValuesEstimation;
|
|
119
119
|
const API_URL = 'https://blue-api.morpho.org/graphql';
|
|
120
|
-
const MARKET_QUERY = `
|
|
121
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
122
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
123
|
-
reallocatableLiquidityAssets
|
|
124
|
-
targetBorrowUtilization
|
|
125
|
-
loanAsset {
|
|
126
|
-
address
|
|
127
|
-
decimals
|
|
128
|
-
priceUsd
|
|
129
|
-
}
|
|
130
|
-
state {
|
|
131
|
-
liquidityAssets
|
|
132
|
-
borrowAssets
|
|
133
|
-
supplyAssets
|
|
134
|
-
}
|
|
135
|
-
publicAllocatorSharedLiquidity {
|
|
136
|
-
assets
|
|
137
|
-
vault {
|
|
138
|
-
address
|
|
139
|
-
name
|
|
140
|
-
}
|
|
141
|
-
allocationMarket {
|
|
142
|
-
uniqueKey
|
|
143
|
-
loanAsset {
|
|
144
|
-
address
|
|
145
|
-
}
|
|
146
|
-
collateralAsset {
|
|
147
|
-
address
|
|
148
|
-
}
|
|
149
|
-
irmAddress
|
|
150
|
-
oracle {
|
|
151
|
-
address
|
|
152
|
-
}
|
|
153
|
-
lltv
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
loanAsset {
|
|
157
|
-
address
|
|
158
|
-
}
|
|
159
|
-
collateralAsset {
|
|
160
|
-
address
|
|
161
|
-
}
|
|
162
|
-
oracle {
|
|
163
|
-
address
|
|
164
|
-
}
|
|
165
|
-
irmAddress
|
|
166
|
-
lltv
|
|
167
|
-
}
|
|
168
|
-
}
|
|
120
|
+
const MARKET_QUERY = `
|
|
121
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
122
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
123
|
+
reallocatableLiquidityAssets
|
|
124
|
+
targetBorrowUtilization
|
|
125
|
+
loanAsset {
|
|
126
|
+
address
|
|
127
|
+
decimals
|
|
128
|
+
priceUsd
|
|
129
|
+
}
|
|
130
|
+
state {
|
|
131
|
+
liquidityAssets
|
|
132
|
+
borrowAssets
|
|
133
|
+
supplyAssets
|
|
134
|
+
}
|
|
135
|
+
publicAllocatorSharedLiquidity {
|
|
136
|
+
assets
|
|
137
|
+
vault {
|
|
138
|
+
address
|
|
139
|
+
name
|
|
140
|
+
}
|
|
141
|
+
allocationMarket {
|
|
142
|
+
uniqueKey
|
|
143
|
+
loanAsset {
|
|
144
|
+
address
|
|
145
|
+
}
|
|
146
|
+
collateralAsset {
|
|
147
|
+
address
|
|
148
|
+
}
|
|
149
|
+
irmAddress
|
|
150
|
+
oracle {
|
|
151
|
+
address
|
|
152
|
+
}
|
|
153
|
+
lltv
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
loanAsset {
|
|
157
|
+
address
|
|
158
|
+
}
|
|
159
|
+
collateralAsset {
|
|
160
|
+
address
|
|
161
|
+
}
|
|
162
|
+
oracle {
|
|
163
|
+
address
|
|
164
|
+
}
|
|
165
|
+
irmAddress
|
|
166
|
+
lltv
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
169
|
`;
|
|
170
|
-
const REWARDS_QUERY = `
|
|
171
|
-
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
172
|
-
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
173
|
-
uniqueKey
|
|
174
|
-
state {
|
|
175
|
-
rewards {
|
|
176
|
-
amountPerSuppliedToken
|
|
177
|
-
supplyApr
|
|
178
|
-
amountPerBorrowedToken
|
|
179
|
-
borrowApr
|
|
180
|
-
asset {
|
|
181
|
-
address
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
170
|
+
const REWARDS_QUERY = `
|
|
171
|
+
query MarketByUniqueKey($uniqueKey: String!, $chainId: Int!) {
|
|
172
|
+
marketByUniqueKey(uniqueKey: $uniqueKey, chainId: $chainId) {
|
|
173
|
+
uniqueKey
|
|
174
|
+
state {
|
|
175
|
+
rewards {
|
|
176
|
+
amountPerSuppliedToken
|
|
177
|
+
supplyApr
|
|
178
|
+
amountPerBorrowedToken
|
|
179
|
+
borrowApr
|
|
180
|
+
asset {
|
|
181
|
+
address
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
187
|
`;
|
|
188
188
|
/**
|
|
189
189
|
* Get reallocatable liquidity to a given market and target borrow utilization
|
|
@@ -10,7 +10,9 @@ exports.aaveV1AssetsDefaultMarket = [
|
|
|
10
10
|
exports.aaveV2AssetsDefaultMarket = ['USDT', 'WBTC', 'ETH', 'YFI', 'ZRX', 'UNI', 'AAVE', 'BAT', 'BUSD', 'DAI', 'ENJ', 'KNCL', 'LINK', 'MANA', 'MKR', 'REN', 'SNX', 'SUSD', 'TUSD', 'USDC', 'CRV', 'GUSD', 'BAL', 'xSUSHI', 'RENFIL', 'RAI', 'AMPL', 'USDP', 'DPI', 'FRAX', 'FEI', 'stETH', 'ENS', 'UST', 'CVX', '1INCH', 'LUSD'];
|
|
11
11
|
exports.morphoAaveV2AssetDefaultMarket = ['DAI', 'ETH', 'USDC', 'USDT', 'WBTC', 'stETH', 'CRV'];
|
|
12
12
|
exports.morphoAaveV3AssetEthMarket = ['ETH', 'wstETH', 'DAI', 'USDC', 'WBTC', 'rETH', 'cbETH', 'sDAI', 'USDT'];
|
|
13
|
-
exports.aaveV3AssetsDefaultMarketEth = [
|
|
13
|
+
exports.aaveV3AssetsDefaultMarketEth = [
|
|
14
|
+
'ETH', 'wstETH', 'WBTC', 'USDC', 'DAI', 'LINK', 'AAVE', 'cbETH', 'USDT', 'rETH', 'LUSD', 'CRV', 'MKR', 'SNX', 'BAL', 'UNI', 'LDO', 'ENS', '1INCH', 'FRAX', 'GHO', 'RPL', 'sDAI', 'STG', 'KNC', 'FXS', 'crvUSD', 'PYUSD', 'weETH', 'osETH', 'USDe', 'ETHx', 'sUSDe', 'tBTC', 'cbBTC', 'USDS', 'rsETH', 'LBTC', 'eBTC', 'RLUSD', 'PT eUSDe May', 'PT sUSDe July',
|
|
15
|
+
];
|
|
14
16
|
exports.aaveV3AssetsDefaultMarketOpt = [
|
|
15
17
|
'DAI', 'USDC.e', 'USDT', 'SUSD', 'AAVE', 'LINK', 'WBTC', 'ETH', 'OP', 'wstETH', 'LUSD', 'MAI', 'rETH', 'USDC',
|
|
16
18
|
];
|