@1delta/margin-fetcher 0.0.18 → 0.0.19
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/dist/assets/liquidityThresholds.d.ts +10 -0
- package/dist/assets/liquidityThresholds.d.ts.map +1 -1
- package/dist/assets/liquidityThresholds.js +9 -2
- package/dist/flash-liquidity/fetchLiquidity.d.ts +2 -2
- package/dist/flash-liquidity/fetchLiquidity.d.ts.map +1 -1
- package/dist/flash-liquidity/fetchLiquidity.js +85 -54
- package/dist/flash-liquidity/types.d.ts +1 -0
- package/dist/flash-liquidity/types.d.ts.map +1 -1
- package/dist/lending/aave-v3-type/publicCallBuild.d.ts +1 -1
- package/dist/lending/aave-v3-type/publicCallBuild.d.ts.map +1 -1
- package/dist/lending/aave-v3-type/publicCallBuild.js +46 -48
- package/dist/lending/aave-v3-type/publicCallParse.d.ts.map +1 -1
- package/dist/lending/aave-v3-type/publicCallParse.js +8 -2
- package/dist/lending/compound-v3/publicCallParse.d.ts.map +1 -1
- package/dist/lending/compound-v3/publicCallParse.js +8 -3
- package/dist/lending/fetchLender.js +2 -2
- package/dist/lending/morpho/convertPublic.js +1 -1
- package/dist/lending/user-data/types.js +2 -2
- package/dist/lending-pairs/computeLendingPairs.d.ts +10 -1
- package/dist/lending-pairs/computeLendingPairs.d.ts.map +1 -1
- package/dist/lending-pairs/computeLendingPairs.js +26 -22
- package/dist/prices/defillama/index.d.ts.map +1 -1
- package/dist/prices/defillama/index.js +162 -151
- package/dist/prices/index.d.ts +3 -2
- package/dist/prices/index.d.ts.map +1 -1
- package/dist/prices/index.js +3 -2
- package/dist/prices/main-prices/addresses/aaveOracles.d.ts +159 -143
- package/dist/prices/main-prices/addresses/aaveOracles.d.ts.map +1 -1
- package/dist/prices/main-prices/addresses/aaveOracles.js +276 -260
- package/dist/prices/main-prices/addresses/morpho.d.ts.map +1 -1
- package/dist/prices/main-prices/addresses/morpho.js +114 -0
- package/dist/prices/main-prices/fetchOracleData.d.ts.map +1 -1
- package/dist/prices/main-prices/fetchOracleData.js +21 -9
- package/dist/prices/pendle/fetchPendlePrices.d.ts +7 -0
- package/dist/prices/pendle/fetchPendlePrices.d.ts.map +1 -0
- package/dist/prices/pendle/fetchPendlePrices.js +148 -0
- package/dist/prices/pendle/index.d.ts +2 -0
- package/dist/prices/pendle/index.d.ts.map +1 -0
- package/dist/prices/pendle/index.js +1 -0
- package/dist/types/apiReturnType.d.ts +2 -0
- package/dist/types/apiReturnType.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -3
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +10 -16
- package/dist/yields/index.d.ts.map +1 -1
- package/dist/yields/index.js +46 -33
- package/package.json +3 -6
- package/src/assets/liquidityThresholds.ts +22 -3
- package/src/flash-liquidity/fetchLiquidity.ts +298 -261
- package/src/flash-liquidity/types.ts +1 -0
- package/src/lending/aave-v3-type/publicCallBuild.ts +74 -68
- package/src/lending/aave-v3-type/publicCallParse.ts +8 -2
- package/src/lending/compound-v3/publicCallParse.ts +10 -3
- package/src/lending/fetchLender.ts +2 -2
- package/src/lending/morpho/convertPublic.ts +1 -1
- package/src/lending/user-data/types.ts +2 -2
- package/src/lending-pairs/computeLendingPairs.ts +423 -410
- package/src/prices/defillama/index.ts +233 -227
- package/src/prices/index.ts +3 -2
- package/src/prices/main-prices/addresses/aaveOracles.ts +292 -277
- package/src/prices/main-prices/addresses/morpho.ts +114 -0
- package/src/prices/main-prices/fetchOracleData.ts +29 -22
- package/src/prices/pendle/fetchPendlePrices.ts +208 -0
- package/src/prices/pendle/index.ts +1 -0
- package/src/types/apiReturnType.ts +42 -39
- package/src/utils/index.ts +11 -18
- package/src/yields/index.ts +205 -179
- package/test/flashLiquidity.test.ts +40 -0
- package/test/lenderData.test.ts +18 -13254
- package/test/mainPrices.test.ts +24 -19
- package/test/morphoPrice.test.ts +1 -1
- package/test/userDataAave.test.ts +73 -0
|
@@ -26,4 +26,14 @@ export declare function meetsLiquidityThresholds(pool: {
|
|
|
26
26
|
totalDebtUSD: number;
|
|
27
27
|
totalLiquidityUSD: number;
|
|
28
28
|
}, thresholds: LiquidityThresholds): boolean;
|
|
29
|
+
export declare function meetsLiquidityThresholdsLong(pool: {
|
|
30
|
+
totalDepositsUSD: number;
|
|
31
|
+
totalDebtUSD: number;
|
|
32
|
+
totalLiquidityUSD: number;
|
|
33
|
+
}, thresholds: LiquidityThresholds): boolean;
|
|
34
|
+
export declare function meetsLiquidityThresholdsShort(pool: {
|
|
35
|
+
totalDepositsUSD: number;
|
|
36
|
+
totalDebtUSD: number;
|
|
37
|
+
totalLiquidityUSD: number;
|
|
38
|
+
}, thresholds: LiquidityThresholds): boolean;
|
|
29
39
|
//# sourceMappingURL=liquidityThresholds.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"liquidityThresholds.d.ts","sourceRoot":"","sources":["../../src/assets/liquidityThresholds.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,mBAAmB;IAClC,oCAAoC;IACpC,cAAc,EAAE,MAAM,CAAC;IACvB,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,4BAA4B,EAAE,mBAI1C,CAAC;AAEF,eAAO,MAAM,gCAAgC,EAAE;IAAE,CAAC,UAAU,EAAE,MAAM,GAAG,mBAAmB,CAAA;CAMzF,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE;IAAE,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;CAWpE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,mBAAmB,CAAA;CAEhF,CAAC;AAKF,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,UAAU,CAAC,EAAC,MAAM,GACjB,mBAAmB,CAkBrB;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE;IAAE,gBAAgB,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,EACnF,UAAU,EAAE,mBAAmB,GAC9B,OAAO,CAMT"}
|
|
1
|
+
{"version":3,"file":"liquidityThresholds.d.ts","sourceRoot":"","sources":["../../src/assets/liquidityThresholds.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,mBAAmB;IAClC,oCAAoC;IACpC,cAAc,EAAE,MAAM,CAAC;IACvB,wCAAwC;IACxC,UAAU,EAAE,MAAM,CAAC;IACnB,qCAAqC;IACrC,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,eAAO,MAAM,4BAA4B,EAAE,mBAI1C,CAAC;AAEF,eAAO,MAAM,gCAAgC,EAAE;IAAE,CAAC,UAAU,EAAE,MAAM,GAAG,mBAAmB,CAAA;CAMzF,CAAC;AAEF,eAAO,MAAM,2BAA2B,EAAE;IAAE,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;CAWpE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,yBAAyB,EAAE;IAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,mBAAmB,CAAA;CAEhF,CAAC;AAKF,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,YAAY,EAAE,MAAM,EACpB,UAAU,CAAC,EAAC,MAAM,GACjB,mBAAmB,CAkBrB;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE;IAAE,gBAAgB,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,EACnF,UAAU,EAAE,mBAAmB,GAC9B,OAAO,CAMT;AAED,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE;IAAE,gBAAgB,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,EACnF,UAAU,EAAE,mBAAmB,GAC9B,OAAO,CAIT;AAED,wBAAgB,6BAA6B,CAC3C,IAAI,EAAE;IAAE,gBAAgB,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAC;IAAC,iBAAiB,EAAE,MAAM,CAAA;CAAE,EACnF,UAAU,EAAE,mBAAmB,GAC9B,OAAO,CAKT"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Chain } from "@1delta/asset-registry";
|
|
2
2
|
export const DEFAULT_LIQUIDITY_THRESHOLDS = {
|
|
3
|
-
minDepositsUSD:
|
|
3
|
+
minDepositsUSD: 25_000,
|
|
4
4
|
minDebtUSD: 10_000,
|
|
5
|
-
minLiquidityUSD:
|
|
5
|
+
minLiquidityUSD: 15_000,
|
|
6
6
|
};
|
|
7
7
|
export const ASSET_GROUP_LIQUIDITY_THRESHOLDS = {
|
|
8
8
|
'USDC': {
|
|
@@ -49,3 +49,10 @@ export function meetsLiquidityThresholds(pool, thresholds) {
|
|
|
49
49
|
pool.totalDebtUSD >= thresholds.minDebtUSD &&
|
|
50
50
|
pool.totalLiquidityUSD >= thresholds.minLiquidityUSD);
|
|
51
51
|
}
|
|
52
|
+
export function meetsLiquidityThresholdsLong(pool, thresholds) {
|
|
53
|
+
return (pool.totalDepositsUSD >= thresholds.minDepositsUSD);
|
|
54
|
+
}
|
|
55
|
+
export function meetsLiquidityThresholdsShort(pool, thresholds) {
|
|
56
|
+
return (pool.totalDebtUSD >= thresholds.minDebtUSD &&
|
|
57
|
+
pool.totalLiquidityUSD >= thresholds.minLiquidityUSD);
|
|
58
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MulticallRetryFunction } from
|
|
2
|
-
import { FlashLiquiditiesOnChain } from
|
|
1
|
+
import { MulticallRetryFunction } from '../types';
|
|
2
|
+
import { FlashLiquiditiesOnChain } from './types';
|
|
3
3
|
export declare function fetchFlashLiquidityForChain(chain: string, multicallRetry: MulticallRetryFunction): Promise<FlashLiquiditiesOnChain>;
|
|
4
4
|
//# sourceMappingURL=fetchLiquidity.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchLiquidity.d.ts","sourceRoot":"","sources":["../../src/flash-liquidity/fetchLiquidity.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetchLiquidity.d.ts","sourceRoot":"","sources":["../../src/flash-liquidity/fetchLiquidity.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAEjD,OAAO,EAAE,uBAAuB,EAAgB,MAAM,SAAS,CAAA;AAsB/D,wBAAsB,2BAA2B,CAC/C,KAAK,EAAE,MAAM,EACb,cAAc,EAAE,sBAAsB,oCAwSvC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { getAaveStyleProtocolTokenMap, getAaveTypePoolAddress, getAssetMeta } from
|
|
2
|
-
import { AAVES_PER_CHAIN } from
|
|
3
|
-
import { RELEVANT_BALANCER_V2_FORKS, RELEVANT_BALANCER_V3_FORKS, RELEVANT_LENDING_ASSETS, RELEVANT_MORPHOB_FORKS, RELEVANT_UNISWAP_V4_FORKS } from
|
|
4
|
-
import { FlashAbi } from
|
|
5
|
-
import { FlashLoanIds } from
|
|
6
|
-
import { FLASH_LOAN_IDS } from
|
|
7
|
-
import { formatUnits, zeroAddress } from
|
|
8
|
-
import { AAVE_V2_LENDERS, AAVE_V3_LENDERS } from
|
|
9
|
-
import { MULTICALL_ADDRESS } from
|
|
1
|
+
import { getAaveStyleProtocolTokenMap, getAaveTypePoolAddress, getAssetMeta, } from '../assets';
|
|
2
|
+
import { AAVES_PER_CHAIN } from '../utils';
|
|
3
|
+
import { RELEVANT_BALANCER_V2_FORKS, RELEVANT_BALANCER_V3_FORKS, RELEVANT_LENDING_ASSETS, RELEVANT_MORPHOB_FORKS, RELEVANT_UNISWAP_V4_FORKS, } from './assets';
|
|
4
|
+
import { FlashAbi } from '../abis/flashloan-united/flashAbi';
|
|
5
|
+
import { FlashLoanIds } from './types';
|
|
6
|
+
import { FLASH_LOAN_IDS } from '@1delta/dex-registry';
|
|
7
|
+
import { formatUnits, zeroAddress } from 'viem';
|
|
8
|
+
import { AAVE_V2_LENDERS, AAVE_V3_LENDERS } from '@1delta/asset-registry';
|
|
9
|
+
import { MULTICALL_ADDRESS } from '../utils/constants';
|
|
10
10
|
const DEFAULT_BATCH_SIZE = 4096;
|
|
11
11
|
var BalanceFetchCall;
|
|
12
12
|
(function (BalanceFetchCall) {
|
|
@@ -24,21 +24,21 @@ export async function fetchFlashLiquidityForChain(chain, multicallRetry) {
|
|
|
24
24
|
let aaveCalls = [];
|
|
25
25
|
const aaveProtocols = AAVES_PER_CHAIN[chain] ?? [];
|
|
26
26
|
// we only ned to check aave flash liquidity for aave assets
|
|
27
|
-
aaveProtocols.forEach(aaveFork => {
|
|
27
|
+
aaveProtocols.forEach((aaveFork) => {
|
|
28
28
|
const underlyingsAndATokens = Object.entries(getAaveStyleProtocolTokenMap(chain, aaveFork));
|
|
29
29
|
const pool = getAaveTypePoolAddress(chain, aaveFork);
|
|
30
30
|
const tokenCalls = underlyingsAndATokens
|
|
31
31
|
.map(([a, b]) => [
|
|
32
32
|
{ name: BalanceFetchCall.balanceOf, address: a, args: [b.aToken] },
|
|
33
|
-
{ name:
|
|
33
|
+
{ name: 'getConfiguration', address: pool, args: [a] },
|
|
34
34
|
])
|
|
35
35
|
.reduce((acc, b) => [...acc, ...b], []);
|
|
36
|
-
aaveAssets[aaveFork] = underlyingsAndATokens.map(a => a[0]);
|
|
36
|
+
aaveAssets[aaveFork] = underlyingsAndATokens.map((a) => a[0]);
|
|
37
37
|
callLengths[aaveFork] = tokenCalls.length * 2 + 1;
|
|
38
38
|
aaveCalls = [
|
|
39
39
|
...aaveCalls,
|
|
40
40
|
...tokenCalls,
|
|
41
|
-
{ name:
|
|
41
|
+
{ name: 'FLASHLOAN_PREMIUM_TOTAL', address: pool },
|
|
42
42
|
];
|
|
43
43
|
});
|
|
44
44
|
// @ts-ignore
|
|
@@ -46,60 +46,84 @@ export async function fetchFlashLiquidityForChain(chain, multicallRetry) {
|
|
|
46
46
|
const otherAssets = RELEVANT_LENDING_ASSETS[chain] ?? [];
|
|
47
47
|
let morphoCalls = [];
|
|
48
48
|
if (morphoBs && morphoBs.length > 0) {
|
|
49
|
-
morphoBs.forEach(bFork => {
|
|
49
|
+
morphoBs.forEach((bFork) => {
|
|
50
50
|
callLengths[bFork.pool] = otherAssets.length;
|
|
51
51
|
morphoCalls = [
|
|
52
52
|
...morphoCalls,
|
|
53
|
-
...otherAssets.map(address => address === zeroAddress
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
53
|
+
...otherAssets.map((address) => address === zeroAddress
|
|
54
|
+
? {
|
|
55
|
+
name: BalanceFetchCall.getEthBalance,
|
|
56
|
+
address: MULTICALL_ADDRESS[chain],
|
|
57
|
+
args: [bFork.address],
|
|
58
|
+
}
|
|
59
|
+
: {
|
|
60
|
+
name: BalanceFetchCall.balanceOf,
|
|
61
|
+
address,
|
|
62
|
+
args: [bFork.address],
|
|
63
|
+
}),
|
|
58
64
|
];
|
|
59
65
|
});
|
|
60
66
|
}
|
|
61
67
|
const balancerV2s = RELEVANT_BALANCER_V2_FORKS[chain] ?? [];
|
|
62
68
|
let balancerV2Calls = [];
|
|
63
69
|
if (balancerV2s && balancerV2s.length > 0) {
|
|
64
|
-
balancerV2s.forEach(bFork => {
|
|
70
|
+
balancerV2s.forEach((bFork) => {
|
|
65
71
|
callLengths[bFork.pool] = otherAssets.length;
|
|
66
72
|
balancerV2Calls = [
|
|
67
73
|
...balancerV2Calls,
|
|
68
|
-
...otherAssets.map(address => address === zeroAddress
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
74
|
+
...otherAssets.map((address) => address === zeroAddress
|
|
75
|
+
? {
|
|
76
|
+
name: BalanceFetchCall.getEthBalance,
|
|
77
|
+
address: MULTICALL_ADDRESS[chain],
|
|
78
|
+
args: [bFork.address],
|
|
79
|
+
}
|
|
80
|
+
: {
|
|
81
|
+
name: BalanceFetchCall.balanceOf,
|
|
82
|
+
address,
|
|
83
|
+
args: [bFork.address],
|
|
84
|
+
}),
|
|
73
85
|
];
|
|
74
86
|
});
|
|
75
87
|
}
|
|
76
88
|
const balancerV3s = RELEVANT_BALANCER_V3_FORKS[chain] ?? [];
|
|
77
89
|
let balancerV3Calls = [];
|
|
78
90
|
if (balancerV3s && balancerV3s.length > 0) {
|
|
79
|
-
balancerV3s.forEach(bFork => {
|
|
91
|
+
balancerV3s.forEach((bFork) => {
|
|
80
92
|
callLengths[bFork.pool] = otherAssets.length;
|
|
81
93
|
balancerV3Calls = [
|
|
82
94
|
...balancerV3Calls,
|
|
83
|
-
...otherAssets.map(address => address === zeroAddress
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
95
|
+
...otherAssets.map((address) => address === zeroAddress
|
|
96
|
+
? {
|
|
97
|
+
name: BalanceFetchCall.getEthBalance,
|
|
98
|
+
address: MULTICALL_ADDRESS[chain],
|
|
99
|
+
args: [bFork.address],
|
|
100
|
+
}
|
|
101
|
+
: {
|
|
102
|
+
name: BalanceFetchCall.balanceOf,
|
|
103
|
+
address,
|
|
104
|
+
args: [bFork.address],
|
|
105
|
+
}),
|
|
88
106
|
];
|
|
89
107
|
});
|
|
90
108
|
}
|
|
91
109
|
const uniswapV4s = RELEVANT_UNISWAP_V4_FORKS[chain] ?? [];
|
|
92
110
|
let uniswapV4Calls = [];
|
|
93
111
|
if (uniswapV4s && uniswapV4s.length > 0) {
|
|
94
|
-
uniswapV4s.forEach(u4Fork => {
|
|
112
|
+
uniswapV4s.forEach((u4Fork) => {
|
|
95
113
|
callLengths[u4Fork.pool] = otherAssets.length;
|
|
96
114
|
uniswapV4Calls = [
|
|
97
115
|
...uniswapV4Calls,
|
|
98
|
-
...otherAssets.map(address => address === zeroAddress
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
116
|
+
...otherAssets.map((address) => address === zeroAddress
|
|
117
|
+
? {
|
|
118
|
+
name: BalanceFetchCall.getEthBalance,
|
|
119
|
+
address: MULTICALL_ADDRESS[chain],
|
|
120
|
+
args: [u4Fork.address],
|
|
121
|
+
}
|
|
122
|
+
: {
|
|
123
|
+
name: BalanceFetchCall.balanceOf,
|
|
124
|
+
address,
|
|
125
|
+
args: [u4Fork.address],
|
|
126
|
+
}),
|
|
103
127
|
];
|
|
104
128
|
});
|
|
105
129
|
}
|
|
@@ -113,7 +137,7 @@ export async function fetchFlashLiquidityForChain(chain, multicallRetry) {
|
|
|
113
137
|
const rawResults = await multicallRetry(chain, calls, FlashAbi, DEFAULT_BATCH_SIZE, 3, 0, false);
|
|
114
138
|
let liquidity = {};
|
|
115
139
|
let currentOffset = 0;
|
|
116
|
-
aaveProtocols.forEach(aave => {
|
|
140
|
+
aaveProtocols.forEach((aave) => {
|
|
117
141
|
const callLen = aaveAssets[aave].length * 2 + 1;
|
|
118
142
|
const data = rawResults.slice(currentOffset, callLen + currentOffset);
|
|
119
143
|
const fee = data[callLen - 1];
|
|
@@ -124,22 +148,25 @@ export async function fetchFlashLiquidityForChain(chain, multicallRetry) {
|
|
|
124
148
|
const rawAmount = data[2 * i];
|
|
125
149
|
const config = data[2 * i + 1];
|
|
126
150
|
const enabled = !AAVE_V3_LENDERS.includes(aave) || getFlashLoanEnabled(config);
|
|
127
|
-
if (enabled && rawAmount > 0n) {
|
|
151
|
+
if (enabled && rawAmount > 0n && FLASH_LOAN_IDS[aave] !== undefined) {
|
|
128
152
|
if (!liquidity[asset])
|
|
129
153
|
liquidity[asset] = [];
|
|
130
154
|
liquidity[asset].push({
|
|
131
155
|
id: FLASH_LOAN_IDS[aave],
|
|
132
156
|
name: aave,
|
|
133
|
-
type: AAVE_V2_LENDERS.includes(aave)
|
|
157
|
+
type: AAVE_V2_LENDERS.includes(aave)
|
|
158
|
+
? FlashLoanIds.AAVE_V2
|
|
159
|
+
: FlashLoanIds.AAVE_V3,
|
|
134
160
|
source: getAaveTypePoolAddress(chain, aave),
|
|
135
161
|
fee: fee.toString(),
|
|
136
162
|
availableRaw: rawAmount.toString(),
|
|
137
|
-
available: Number(formatUnits(rawAmount, decimals ?? 18))
|
|
163
|
+
available: Number(formatUnits(rawAmount, decimals ?? 18)),
|
|
164
|
+
decimals,
|
|
138
165
|
});
|
|
139
166
|
}
|
|
140
167
|
});
|
|
141
168
|
});
|
|
142
|
-
balancerV2s.forEach(balancer => {
|
|
169
|
+
balancerV2s.forEach((balancer) => {
|
|
143
170
|
const callLen = otherAssets.length;
|
|
144
171
|
const data = rawResults.slice(currentOffset, callLen + currentOffset);
|
|
145
172
|
// update offset
|
|
@@ -155,37 +182,39 @@ export async function fetchFlashLiquidityForChain(chain, multicallRetry) {
|
|
|
155
182
|
name: balancer.pool,
|
|
156
183
|
type: FlashLoanIds.BALANCER_V2,
|
|
157
184
|
source: balancer.address,
|
|
158
|
-
fee:
|
|
185
|
+
fee: '0',
|
|
159
186
|
availableRaw: rawAmount.toString(),
|
|
160
|
-
available: Number(formatUnits(rawAmount, decimals ?? 18))
|
|
187
|
+
available: Number(formatUnits(rawAmount, decimals ?? 18)),
|
|
188
|
+
decimals,
|
|
161
189
|
});
|
|
162
190
|
}
|
|
163
191
|
});
|
|
164
192
|
});
|
|
165
|
-
morphoBs.forEach(morpho => {
|
|
193
|
+
morphoBs.forEach((morpho) => {
|
|
166
194
|
const callLen = otherAssets.length;
|
|
167
195
|
const data = rawResults.slice(currentOffset, callLen + currentOffset);
|
|
168
196
|
// update offset
|
|
169
197
|
currentOffset += callLen;
|
|
170
198
|
otherAssets.forEach((asset, i) => {
|
|
171
|
-
const decimals = getAssetMeta(chain, asset)?.decimals;
|
|
172
199
|
const rawAmount = data[i];
|
|
173
200
|
if (rawAmount > 0n) {
|
|
174
201
|
if (!liquidity[asset])
|
|
175
202
|
liquidity[asset] = [];
|
|
203
|
+
const decimals = getAssetMeta(chain, asset)?.decimals;
|
|
176
204
|
liquidity[asset].push({
|
|
177
205
|
id: FLASH_LOAN_IDS[morpho.pool],
|
|
178
206
|
name: morpho.pool,
|
|
179
207
|
type: FlashLoanIds.MORPHO,
|
|
180
208
|
source: morpho.address,
|
|
181
|
-
fee:
|
|
209
|
+
fee: '0',
|
|
182
210
|
availableRaw: rawAmount.toString(),
|
|
183
|
-
available: Number(formatUnits(rawAmount, decimals ?? 18))
|
|
211
|
+
available: Number(formatUnits(rawAmount, decimals ?? 18)),
|
|
212
|
+
decimals,
|
|
184
213
|
});
|
|
185
214
|
}
|
|
186
215
|
});
|
|
187
216
|
});
|
|
188
|
-
balancerV3s.forEach(balancerV3 => {
|
|
217
|
+
balancerV3s.forEach((balancerV3) => {
|
|
189
218
|
const callLen = otherAssets.length;
|
|
190
219
|
const data = rawResults.slice(currentOffset, callLen + currentOffset);
|
|
191
220
|
// update offset
|
|
@@ -201,14 +230,15 @@ export async function fetchFlashLiquidityForChain(chain, multicallRetry) {
|
|
|
201
230
|
name: balancerV3.pool,
|
|
202
231
|
type: FlashLoanIds.SINGLETON,
|
|
203
232
|
source: balancerV3.address,
|
|
204
|
-
fee:
|
|
233
|
+
fee: '0',
|
|
205
234
|
availableRaw: rawAmount.toString(),
|
|
206
|
-
available: Number(formatUnits(rawAmount, decimals ?? 18))
|
|
235
|
+
available: Number(formatUnits(rawAmount, decimals ?? 18)),
|
|
236
|
+
decimals,
|
|
207
237
|
});
|
|
208
238
|
}
|
|
209
239
|
});
|
|
210
240
|
});
|
|
211
|
-
uniswapV4s.forEach(uniV4 => {
|
|
241
|
+
uniswapV4s.forEach((uniV4) => {
|
|
212
242
|
const callLen = otherAssets.length;
|
|
213
243
|
const data = rawResults.slice(currentOffset, callLen + currentOffset);
|
|
214
244
|
// update offset
|
|
@@ -224,9 +254,10 @@ export async function fetchFlashLiquidityForChain(chain, multicallRetry) {
|
|
|
224
254
|
name: uniV4.pool,
|
|
225
255
|
type: FlashLoanIds.SINGLETON,
|
|
226
256
|
source: uniV4.address,
|
|
227
|
-
fee:
|
|
257
|
+
fee: '0',
|
|
228
258
|
availableRaw: rawAmount.toString(),
|
|
229
|
-
available: Number(formatUnits(rawAmount, decimals ?? 18))
|
|
259
|
+
available: Number(formatUnits(rawAmount, decimals ?? 18)),
|
|
260
|
+
decimals,
|
|
230
261
|
});
|
|
231
262
|
}
|
|
232
263
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/flash-liquidity/types.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACpB,MAAM,IAAI;IACV,WAAW,IAAI;IACf,OAAO,IAAI;IACX,OAAO,IAAI;IACX,SAAS,cAAc;CAC1B;AACD,MAAM,WAAW,0BAA0B;IACvC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,YAAY,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/flash-liquidity/types.ts"],"names":[],"mappings":"AAAA,oBAAY,YAAY;IACpB,MAAM,IAAI;IACV,WAAW,IAAI;IACf,OAAO,IAAI;IACX,OAAO,IAAI;IACX,SAAS,cAAc;CAC1B;AACD,MAAM,WAAW,0BAA0B;IACvC,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,YAAY,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,MAAM,CAAA;IACX,YAAY,EAAE,MAAM,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;IACjB,QAAQ,EAAE,MAAM,CAAA;CACnB;AAED,MAAM,MAAM,uBAAuB,GAAG;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,0BAA0B,EAAE,CAAA;CAAE,CAAA;AAEvF,MAAM,MAAM,cAAc,GAAG;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,uBAAuB,CAAA;CAAE,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Lender } from
|
|
1
|
+
import { Lender } from '@1delta/asset-registry';
|
|
2
2
|
export declare const AAVE_V3_EMODES: number[];
|
|
3
3
|
export declare const buildAaveV3StyleLenderReserveCall: (chainId: string, lender: Lender) => import("../../types").GeneralCall[];
|
|
4
4
|
//# sourceMappingURL=publicCallBuild.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publicCallBuild.d.ts","sourceRoot":"","sources":["../../../src/lending/aave-v3-type/publicCallBuild.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;
|
|
1
|
+
{"version":3,"file":"publicCallBuild.d.ts","sourceRoot":"","sources":["../../../src/lending/aave-v3-type/publicCallBuild.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAS/C,eAAO,MAAM,cAAc,UAAwB,CAAA;AA+EnD,eAAO,MAAM,iCAAiC,GAC5C,SAAS,MAAM,EACf,QAAQ,MAAM,wCA+Df,CAAA"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { Lender } from
|
|
2
|
-
import { getAaveAssets, getAaveTypePoolAddress, getAaveTypePoolDataProviderAddress } from
|
|
1
|
+
import { Lender } from '@1delta/asset-registry';
|
|
2
|
+
import { getAaveAssets, getAaveTypePoolAddress, getAaveTypePoolDataProviderAddress, } from '../../assets';
|
|
3
|
+
import { isAaveV32Type } from '../../utils';
|
|
3
4
|
export const AAVE_V3_EMODES = [0, 1, 2, 3, 4, 5, 6];
|
|
4
5
|
function yldrBaseline(assetsToQuery, providerAddress) {
|
|
5
|
-
return assetsToQuery.flatMap(tk => [
|
|
6
|
+
return assetsToQuery.flatMap((tk) => [
|
|
6
7
|
{
|
|
7
8
|
address: providerAddress,
|
|
8
9
|
name: 'getReserveData',
|
|
@@ -12,7 +13,7 @@ function yldrBaseline(assetsToQuery, providerAddress) {
|
|
|
12
13
|
address: providerAddress,
|
|
13
14
|
name: 'getReserveConfigurationData',
|
|
14
15
|
params: [tk],
|
|
15
|
-
}
|
|
16
|
+
},
|
|
16
17
|
]);
|
|
17
18
|
}
|
|
18
19
|
function aaveV3baseline(assetsToQuery, providerAddress, poolAddress, legacy = false) {
|
|
@@ -26,7 +27,7 @@ function aaveV3baseline(assetsToQuery, providerAddress, poolAddress, legacy = fa
|
|
|
26
27
|
name: 'getReservesList',
|
|
27
28
|
params: [],
|
|
28
29
|
};
|
|
29
|
-
const callsBase = assetsToQuery.flatMap(tk => [
|
|
30
|
+
const callsBase = assetsToQuery.flatMap((tk) => [
|
|
30
31
|
{
|
|
31
32
|
address: providerAddress,
|
|
32
33
|
name: 'getReserveData',
|
|
@@ -52,55 +53,56 @@ function aaveV3baseline(assetsToQuery, providerAddress, poolAddress, legacy = fa
|
|
|
52
53
|
name: 'getDebtCeiling',
|
|
53
54
|
params: [tk],
|
|
54
55
|
},
|
|
55
|
-
...legacy
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
56
|
+
...(legacy
|
|
57
|
+
? [
|
|
58
|
+
{
|
|
59
|
+
address: providerAddress,
|
|
60
|
+
name: 'getReserveEModeCategory',
|
|
61
|
+
params: [tk],
|
|
62
|
+
},
|
|
63
|
+
]
|
|
64
|
+
: []),
|
|
61
65
|
]);
|
|
62
66
|
return {
|
|
63
67
|
callsBase,
|
|
64
68
|
callReservesList,
|
|
65
|
-
callDecimals
|
|
69
|
+
callDecimals,
|
|
66
70
|
};
|
|
67
71
|
}
|
|
68
72
|
export const buildAaveV3StyleLenderReserveCall = (chainId, lender) => {
|
|
69
73
|
const providerAddress = getAaveTypePoolDataProviderAddress(chainId, lender);
|
|
70
74
|
const assetsToQuery = getAaveAssets(chainId, lender);
|
|
71
75
|
const poolAddress = getAaveTypePoolAddress(chainId, lender);
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
name: 'getEModeCategoryCollateralBitmap',
|
|
91
|
-
params: [eMode],
|
|
92
|
-
}
|
|
93
|
-
];
|
|
94
|
-
});
|
|
95
|
-
const { callDecimals, callReservesList, callsBase } = aaveV3baseline(assetsToQuery, providerAddress, poolAddress);
|
|
96
|
-
const calls = [
|
|
97
|
-
...callsBase,
|
|
98
|
-
...getEModeCategoryData,
|
|
99
|
-
callReservesList,
|
|
100
|
-
callDecimals
|
|
76
|
+
if (isAaveV32Type(lender)) {
|
|
77
|
+
const getEModeCategoryData = AAVE_V3_EMODES.flatMap((eMode) => {
|
|
78
|
+
return [
|
|
79
|
+
{
|
|
80
|
+
address: poolAddress,
|
|
81
|
+
name: 'getEModeCategoryData',
|
|
82
|
+
params: [eMode],
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
address: poolAddress,
|
|
86
|
+
name: 'getEModeCategoryBorrowableBitmap',
|
|
87
|
+
params: [eMode],
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
address: poolAddress,
|
|
91
|
+
name: 'getEModeCategoryCollateralBitmap',
|
|
92
|
+
params: [eMode],
|
|
93
|
+
},
|
|
101
94
|
];
|
|
102
|
-
|
|
103
|
-
}
|
|
95
|
+
});
|
|
96
|
+
const { callDecimals, callReservesList, callsBase } = aaveV3baseline(assetsToQuery, providerAddress, poolAddress);
|
|
97
|
+
const calls = [
|
|
98
|
+
...callsBase,
|
|
99
|
+
...getEModeCategoryData,
|
|
100
|
+
callReservesList,
|
|
101
|
+
callDecimals,
|
|
102
|
+
];
|
|
103
|
+
return calls;
|
|
104
|
+
}
|
|
105
|
+
switch (lender) {
|
|
104
106
|
case Lender.YLDR: {
|
|
105
107
|
const calls = yldrBaseline(assetsToQuery, providerAddress);
|
|
106
108
|
return calls;
|
|
@@ -112,11 +114,7 @@ export const buildAaveV3StyleLenderReserveCall = (chainId, lender) => {
|
|
|
112
114
|
params: [eMode],
|
|
113
115
|
}));
|
|
114
116
|
const { callDecimals, callsBase } = aaveV3baseline(assetsToQuery, providerAddress, poolAddress, true);
|
|
115
|
-
const calls = [
|
|
116
|
-
...callsBase,
|
|
117
|
-
...getEModeCategoryData,
|
|
118
|
-
callDecimals
|
|
119
|
-
];
|
|
117
|
+
const calls = [...callsBase, ...getEModeCategoryData, callDecimals];
|
|
120
118
|
return calls;
|
|
121
119
|
}
|
|
122
120
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publicCallParse.d.ts","sourceRoot":"","sources":["../../../src/lending/aave-v3-type/publicCallParse.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAK5B,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAQ/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;
|
|
1
|
+
{"version":3,"file":"publicCallParse.d.ts","sourceRoot":"","sources":["../../../src/lending/aave-v3-type/publicCallParse.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,2BAA2B,EAK5B,MAAM,SAAS,CAAA;AAEhB,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAE9C,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAQ/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAG3C,eAAO,MAAM,8BAA8B,GACzC,QAAQ,MAAM,EACd,SAAS,MAAM,EACf,QAAQ;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EACnC,kBAAkB,gBAAgB,EAClC,YAAW,gBAAqB,KAC/B,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,2BAA2B,GAAG,SAAS,EAAE,MAAM,CA2MnE,CAAA;AA8BD,wBAAgB,aAAa,CAC3B,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,GAAG,EACrB,MAAM,EAAE,GAAG,EACX,SAAS,EAAE,GAAG,GACb,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,GAAG,SAAS,EAAE,MAAM,CAAC,CA0H5C"}
|
|
@@ -3,8 +3,9 @@ import { AAVE_V3_EMODES } from './publicCallBuild';
|
|
|
3
3
|
import { BPS, formatAaveRawApyToApr, parseRawAmount } from '../../utils/parsing';
|
|
4
4
|
import { Lender } from '@1delta/asset-registry';
|
|
5
5
|
import { getAaveAssets, getAssetMeta, LENDER_MODE_NO_MODE, toGenericPriceKey, toOracleKey, } from '../../assets';
|
|
6
|
+
import { isAaveV32Type } from '../../utils';
|
|
6
7
|
export const getAaveV3ReservesDataConverter = (lender, chainId, prices, additionalYields, tokenList = {}) => {
|
|
7
|
-
if (lender
|
|
8
|
+
if (isAaveV32Type(lender))
|
|
8
9
|
return parseAave32(chainId, lender, prices, additionalYields, tokenList);
|
|
9
10
|
switch (lender) {
|
|
10
11
|
/** AAVE V3 style with rewards from state */
|
|
@@ -136,7 +137,12 @@ const populateEModes = (borrowCollateralFactor, collateralFactor) => {
|
|
|
136
137
|
};
|
|
137
138
|
/** Replica of aave's bitmap checker */
|
|
138
139
|
function isReserveEnabledOnBitmap(bitmap, reserveIndex) {
|
|
139
|
-
|
|
140
|
+
try {
|
|
141
|
+
return ((bitmap >> BigInt(reserveIndex)) & 1n) !== 0n;
|
|
142
|
+
}
|
|
143
|
+
catch {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
140
146
|
}
|
|
141
147
|
export function parseYLDRCall(chainId, lender, additionalYields, prices, tokenList) {
|
|
142
148
|
const assetsToQuery = getAaveAssets(chainId, lender);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publicCallParse.d.ts","sourceRoot":"","sources":["../../../src/lending/compound-v3/publicCallParse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAEL,+BAA+B,EAChC,MAAM,SAAS,CAAA;AAUhB,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAM3C,eAAO,MAAM,kCAAkC,GAC7C,QAAQ,MAAM,EACd,SAAS,MAAM,EACf,QAAQ;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EACnC,kBAAkB,gBAAgB,EAClC,YAAW,gBAAqB,KAC/B,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,+BAA+B,GAAG,SAAS,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"publicCallParse.d.ts","sourceRoot":"","sources":["../../../src/lending/compound-v3/publicCallParse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAC/C,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAC9C,OAAO,EAEL,+BAA+B,EAChC,MAAM,SAAS,CAAA;AAUhB,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAM3C,eAAO,MAAM,kCAAkC,GAC7C,QAAQ,MAAM,EACd,SAAS,MAAM,EACf,QAAQ;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EACnC,kBAAkB,gBAAgB,EAClC,YAAW,gBAAqB,KAC/B,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,+BAA+B,GAAG,SAAS,EAAE,MAAM,CAqLvE,CAAA"}
|
|
@@ -29,6 +29,7 @@ export const getCompoundV3ReservesDataConverter = (lender, chainId, prices, addi
|
|
|
29
29
|
const totals = parseRawAmount(resultsTotals[0], decimals);
|
|
30
30
|
const oracleKey = toOracleKey(assetMeta?.assetGroup) ??
|
|
31
31
|
toGenericPriceKey(asset, chainId);
|
|
32
|
+
const totalUsd = Number(totals) * (prices[oracleKey] ?? 1);
|
|
32
33
|
result[asset] = {
|
|
33
34
|
poolId: asset,
|
|
34
35
|
underlying: asset,
|
|
@@ -52,13 +53,15 @@ export const getCompoundV3ReservesDataConverter = (lender, chainId, prices, addi
|
|
|
52
53
|
// debt and liquidity are zero
|
|
53
54
|
totalDebt: 0,
|
|
54
55
|
totalDebtUSD: 0,
|
|
55
|
-
totalLiquidity:
|
|
56
|
-
totalLiquidityUSD:
|
|
56
|
+
totalLiquidity: totals,
|
|
57
|
+
totalLiquidityUSD: totalUsd,
|
|
57
58
|
// deposits are different outputs for base asset and others
|
|
58
59
|
totalDeposits: totals,
|
|
59
|
-
totalDepositsUSD:
|
|
60
|
+
totalDepositsUSD: totalUsd,
|
|
60
61
|
// rewards
|
|
61
62
|
rewards: {},
|
|
63
|
+
isActive: true,
|
|
64
|
+
isFrozen: false,
|
|
62
65
|
borrowingEnabled: false,
|
|
63
66
|
};
|
|
64
67
|
}
|
|
@@ -125,6 +128,8 @@ export const getCompoundV3ReservesDataConverter = (lender, chainId, prices, addi
|
|
|
125
128
|
},
|
|
126
129
|
},
|
|
127
130
|
borrowingEnabled: true,
|
|
131
|
+
isActive: true,
|
|
132
|
+
isFrozen: false,
|
|
128
133
|
stakingYield: additionalYields.intrinsicYields[oracleKeyBase] ?? 0,
|
|
129
134
|
},
|
|
130
135
|
};
|
|
@@ -12,7 +12,7 @@ import { InitLensAbi } from '../abis/init/InitLens';
|
|
|
12
12
|
import { CometAbi } from '../abis/compound-v3/Comet';
|
|
13
13
|
import { CometExtAbi } from '../abis/compound-v3/CometExt';
|
|
14
14
|
import { IrgetterAbi } from '../abis/compound-v3/IrGetter';
|
|
15
|
-
import { isAaveV2Type,
|
|
15
|
+
import { isAaveV2Type, isAaveV32Type, isAaveV3Type, isCompoundV3, isInit, } from '../utils';
|
|
16
16
|
import { buildAaveV2StyleLenderReserveCall } from './aave-v2-type/publicCallBuild';
|
|
17
17
|
import { buildAaveV3StyleLenderReserveCall } from './aave-v3-type/publicCallBuild';
|
|
18
18
|
import { buildInitStyleLenderReserveCall } from './init/publicCallBuild';
|
|
@@ -55,7 +55,7 @@ const getAbi = (lender) => {
|
|
|
55
55
|
...RewarderAbi,
|
|
56
56
|
...IncentivesControllerAbi,
|
|
57
57
|
];
|
|
58
|
-
if (
|
|
58
|
+
if (isAaveV32Type(lender))
|
|
59
59
|
return [...AavePoolV3UpgradedAbi, ...AaveV3ProtocolDataProviderAbi];
|
|
60
60
|
if (lender === Lender.YLDR)
|
|
61
61
|
return [...YLDRProtocolDataProviderAbi];
|
|
@@ -81,7 +81,7 @@ export function convertMarketsToMorphoResponse(response, chainId, additionalYiel
|
|
|
81
81
|
totalDebtStable: 0,
|
|
82
82
|
totalDebt: 0,
|
|
83
83
|
totalLiquidity: 0,
|
|
84
|
-
totalLiquidityUSD:
|
|
84
|
+
totalLiquidityUSD: Number(state.collateralAssetsUsd),
|
|
85
85
|
totalDepositsUSD: Number(state.collateralAssetsUsd),
|
|
86
86
|
totalDebtStableUSD: 0,
|
|
87
87
|
totalDebtUSD: 0,
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Lender } from '@1delta/asset-registry';
|
|
2
2
|
/** Filter all morphos into one for querying */
|
|
3
3
|
export function organizeUserQueries(queries) {
|
|
4
|
-
const morphos = queries.filter((q) => q.lender
|
|
5
|
-
const nonMorphos = queries.filter((q) => !q.lender
|
|
4
|
+
const morphos = queries.filter((q) => q.lender?.startsWith('MORPHO_BLUE'));
|
|
5
|
+
const nonMorphos = queries.filter((q) => !q.lender?.startsWith('MORPHO_BLUE'));
|
|
6
6
|
const morphosCollapsed = {
|
|
7
7
|
lender: Lender.MORPHO_BLUE,
|
|
8
8
|
account: queries[0].account,
|
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { GenericCurrency } from '../lending/types';
|
|
2
|
+
import { LenderData } from '../types';
|
|
3
|
+
interface SimpleAssetInfo {
|
|
4
|
+
asset: GenericCurrency;
|
|
5
|
+
poolId: string;
|
|
6
|
+
}
|
|
2
7
|
export interface LendingPair {
|
|
3
8
|
chainId: string;
|
|
4
9
|
lender: string;
|
|
5
10
|
assetLong: string;
|
|
6
11
|
assetShort: string;
|
|
12
|
+
/** Full asset info */
|
|
13
|
+
infoLong: SimpleAssetInfo;
|
|
14
|
+
infoShort: SimpleAssetInfo;
|
|
7
15
|
assetGroupLong: string;
|
|
8
16
|
assetGroupShort: string;
|
|
9
17
|
price: number;
|
|
@@ -40,4 +48,5 @@ export declare function getTopPairs(pairs: LendingPair[]): {
|
|
|
40
48
|
gainers: LendingPair[];
|
|
41
49
|
};
|
|
42
50
|
export declare function getDistinctPairsByShortAsset(pairs: LendingPair[]): LendingPair[];
|
|
51
|
+
export {};
|
|
43
52
|
//# sourceMappingURL=computeLendingPairs.d.ts.map
|