@1delta/margin-fetcher 0.0.34 → 0.0.36
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/abis/morpho/lens.d.ts +38 -15
- package/dist/abis/morpho/lens.d.ts.map +1 -1
- package/dist/abis/morpho/lens.js +30 -20
- package/dist/flash-liquidity/assets.d.ts +2 -2
- package/dist/flash-liquidity/assets.d.ts.map +1 -1
- package/dist/flash-liquidity/assets.js +2 -2
- package/dist/flash-liquidity/fetchLiquidity.d.ts.map +1 -1
- package/dist/flash-liquidity/fetchLiquidity.js +2 -2
- package/dist/lending/fetchLender.d.ts.map +1 -1
- package/dist/lending/fetchLender.js +24 -5
- package/dist/lending/fetchLenderAll.d.ts.map +1 -1
- package/dist/lending/fetchLenderAll.js +15 -3
- package/dist/lending/morpho/chainsConfigs.d.ts +21 -0
- package/dist/lending/morpho/chainsConfigs.d.ts.map +1 -0
- package/dist/lending/morpho/chainsConfigs.js +234 -0
- package/dist/lending/morpho/constants/markets.d.ts +4 -0
- package/dist/lending/morpho/constants/markets.d.ts.map +1 -0
- package/dist/lending/morpho/constants/markets.js +63 -0
- package/dist/lending/morpho/convertPublic.d.ts.map +1 -1
- package/dist/lending/morpho/convertPublic.js +2 -13
- package/dist/lending/morpho/getMarketsFromChain.d.ts +8 -0
- package/dist/lending/morpho/getMarketsFromChain.d.ts.map +1 -0
- package/dist/lending/morpho/getMarketsFromChain.js +318 -0
- package/dist/lending/morpho/publicCallBuild.d.ts +5 -0
- package/dist/lending/morpho/publicCallBuild.d.ts.map +1 -1
- package/dist/lending/morpho/publicCallBuild.js +16 -0
- package/dist/lending/morpho/utils/evmParser.d.ts +22 -0
- package/dist/lending/morpho/utils/evmParser.d.ts.map +1 -0
- package/dist/lending/morpho/utils/evmParser.js +103 -0
- package/dist/lending/morpho/utils/mathLib.d.ts +125 -0
- package/dist/lending/morpho/utils/mathLib.d.ts.map +1 -0
- package/dist/lending/morpho/utils/mathLib.js +334 -0
- package/dist/lending/morpho/utils/parsers.d.ts +10 -0
- package/dist/lending/morpho/utils/parsers.d.ts.map +1 -0
- package/dist/lending/morpho/utils/parsers.js +37 -0
- package/dist/lending/user-data/aave-v2-type/userCallParse.js +2 -2
- package/dist/lending/user-data/aave-v3-type/userCallParse.js +2 -2
- package/dist/lending/user-data/aave-v3-type/userCallParseYldr.js +2 -2
- package/dist/lending/user-data/abis.d.ts +37 -14
- package/dist/lending/user-data/abis.d.ts.map +1 -1
- package/dist/lending/user-data/morpho/userCallBuild.d.ts +3 -0
- package/dist/lending/user-data/morpho/userCallBuild.d.ts.map +1 -1
- package/dist/lending/user-data/morpho/userCallBuild.js +9 -8
- package/dist/lending-pairs/computeLendingPairs.d.ts.map +1 -1
- package/dist/lending-pairs/computeLendingPairs.js +11 -7
- package/dist/prices/main-prices/fetchOracleData.d.ts +0 -2
- package/dist/prices/main-prices/fetchOracleData.d.ts.map +1 -1
- package/dist/prices/main-prices/fetchOracleData.js +2 -22
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -5
- package/dist/utils/parsing.d.ts +2 -0
- package/dist/utils/parsing.d.ts.map +1 -1
- package/dist/utils/parsing.js +20 -0
- package/package.json +1 -1
- package/src/abis/morpho/lens.ts +40 -30
- package/src/flash-liquidity/assets.ts +3 -2
- package/src/flash-liquidity/fetchLiquidity.ts +3 -2
- package/src/lending/fetchLender.ts +29 -4
- package/src/lending/fetchLenderAll.ts +32 -12
- package/src/lending/morpho/chainsConfigs.ts +268 -0
- package/src/lending/morpho/constants/markets.ts +64 -0
- package/src/lending/morpho/convertPublic.ts +2 -14
- package/src/lending/morpho/getMarketsFromChain.ts +402 -0
- package/src/lending/morpho/publicCallBuild.ts +17 -0
- package/src/lending/morpho/utils/evmParser.ts +122 -0
- package/src/lending/morpho/utils/mathLib.ts +434 -0
- package/src/lending/morpho/utils/parsers.ts +53 -0
- package/src/lending/user-data/aave-v2-type/userCallParse.ts +2 -2
- package/src/lending/user-data/aave-v3-type/userCallParse.ts +2 -2
- package/src/lending/user-data/aave-v3-type/userCallParseYldr.ts +2 -2
- package/src/lending/user-data/morpho/userCallBuild.ts +9 -8
- package/src/lending-pairs/computeLendingPairs.ts +15 -10
- package/src/prices/main-prices/fetchOracleData.ts +2 -34
- package/src/utils/index.ts +3 -4
- package/src/utils/parsing.ts +32 -0
- package/test/lenderData.test.ts +1 -1
- package/test/mbChain.test.ts +44 -0
|
@@ -6,37 +6,17 @@ import { RWADynamicOracleAbi } from '../../abis/oracle/RWADynamicOracle';
|
|
|
6
6
|
import { api3OracleAddresses } from './addresses/api3';
|
|
7
7
|
import { AAVE_V2_LENDERS } from '@1delta/lender-registry';
|
|
8
8
|
import { Chain } from '@1delta/chain-registry';
|
|
9
|
-
import {
|
|
9
|
+
import { formatUnits } from 'viem';
|
|
10
10
|
import { getAaveAssets } from '../../assets';
|
|
11
11
|
import { chainlinkOracles, getChainLinkKeys, ChainlinkAggregatorIndexes, } from './addresses/chainlink';
|
|
12
12
|
import { fetchDefillamaData } from '../defillama';
|
|
13
13
|
import { fetchPendlePrices } from '../pendle';
|
|
14
14
|
import { getAavesForChain } from '../../utils';
|
|
15
|
-
import { parseRawAmount } from '../../utils/parsing';
|
|
15
|
+
import { formatAavePrice, formatMorphoPrice, parseRawAmount } from '../../utils/parsing';
|
|
16
16
|
import { ProxyOracleAbi } from '../../abis/oracle/ProxyOracle';
|
|
17
17
|
import { multicallRetry } from '@1delta/providers';
|
|
18
18
|
import { UniswapV3Abi } from '../../abis/oracle/UniV3';
|
|
19
19
|
import { aaveOracles, morphoOracles } from '@1delta/data-sdk';
|
|
20
|
-
export const formatAavePrice = (price, isV2 = false) => {
|
|
21
|
-
try {
|
|
22
|
-
return Number(formatEther(BigInt(price ?? '0') *
|
|
23
|
-
// 10^(18 - decimals)
|
|
24
|
-
10n ** (isV2 ? 0n : 10n)));
|
|
25
|
-
}
|
|
26
|
-
catch {
|
|
27
|
-
return NaN;
|
|
28
|
-
}
|
|
29
|
-
};
|
|
30
|
-
export const formatMorphoPrice = (price, collateralDec, debtDec) => {
|
|
31
|
-
try {
|
|
32
|
-
return Number(formatUnits(BigInt(price ?? '0'),
|
|
33
|
-
// 10^(18 - decimals)
|
|
34
|
-
36 + collateralDec - debtDec));
|
|
35
|
-
}
|
|
36
|
-
catch {
|
|
37
|
-
return NaN;
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
20
|
const LENDLE_PAIR_MANTLE = '0x4c57BE599d0e0414785943569E9B6A66dA79Aa6b';
|
|
41
21
|
const AU_PAIR_MANTLE = '0x709503fbb50b10f921e812c48fbd5c5522a0b20c';
|
|
42
22
|
const WMNT_USDT_PAIR = '0x3e5922cd0cec71dc2d60ec8b36aa4c05b7c1672f';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,EAEP,MAAM,yBAAyB,CAAA;AAehC,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,WAE1C;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,WAE9C;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,yBAEpC;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,WAE1C;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,WAE1C;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,WAE1C;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,yBAEpC;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,WAE3C;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,WAExC;AAED,eAAO,MAAM,kBAAkB,GAAI,GAAG,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,MAAM,EAEP,MAAM,yBAAyB,CAAA;AAehC,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,WAE1C;AAED,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,MAAM,WAE9C;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,yBAEpC;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,WAE1C;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,WAE1C;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,WAE1C;AAED,wBAAgB,MAAM,CAAC,MAAM,EAAE,MAAM,yBAEpC;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,WAE3C;AAED,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,WAExC;AAED,eAAO,MAAM,kBAAkB,GAAI,GAAG,MAAM,aA0B3C,CAAA;AAED,sCAAsC;AACtC,eAAO,MAAM,uBAAuB,GAClC,YAAY,MAAM,EAAE,EACpB,eAAe,MAAM,EAAE,KACtB,MAAM,EAaR,CAAA;AAED,mCAAmC;AACnC,eAAO,MAAM,gBAAgB;;CAS5B,CAAA;AAED,eAAO,MAAM,kBAAkB,GAAI,SAAS,MAAM,KAAG,MAEpD,CAAA;AAED,eAAO,MAAM,eAAe,GAC1B,SAAS,MAAM,GAAG,MAAM,GAAG,SAAS,EACpC,wBAAgC,KAC/B,MAAM,EAOR,CAAA;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,WAE3C"}
|
package/dist/utils/index.js
CHANGED
|
@@ -40,11 +40,8 @@ export const getLendersForChain = (c) => {
|
|
|
40
40
|
lenders.push(l);
|
|
41
41
|
});
|
|
42
42
|
// compound V3s
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
if (chains.includes(c))
|
|
46
|
-
lenders.push(l);
|
|
47
|
-
});
|
|
43
|
+
if (compoundV3Pools()?.[c])
|
|
44
|
+
lenders = [...lenders, ...Object.keys(compoundV3Pools()?.[c])];
|
|
48
45
|
// init
|
|
49
46
|
Object.entries(initConfig() ?? {}).forEach(([l, data]) => {
|
|
50
47
|
const chains = Object.keys(data);
|
package/dist/utils/parsing.d.ts
CHANGED
|
@@ -12,4 +12,6 @@ export declare const formatAaveYieldToNumber: (n?: string | bigint) => number;
|
|
|
12
12
|
export declare const calculateRateForCompound: (n: string, chainId: string, lender?: Lender) => number;
|
|
13
13
|
export declare const formatAaveRawApyToApr: (raw: bigint | string | undefined) => number;
|
|
14
14
|
export declare const convertRateToApr: (ratePerSecond: number | string) => number;
|
|
15
|
+
export declare const formatAavePrice: (price: string, isV2?: boolean) => number;
|
|
16
|
+
export declare const formatMorphoPrice: (price: string, collateralDec: number, debtDec: number) => number;
|
|
15
17
|
//# sourceMappingURL=parsing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parsing.d.ts","sourceRoot":"","sources":["../../src/utils/parsing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAIhD,eAAO,MAAM,GAAG,QAAQ,CAAA;AAExB,eAAO,MAAM,cAAc,GAAI,SAAS,MAAM,EAAE,iBAAa,KAAG,MAO/D,CAAA;AAED,oBAAY,SAAS;IACnB,KAAK,IAAA;IACL,EAAE,IAAA;CACH;AAYD,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,WAEnC,CAAA;AAED,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,WAEnC,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,WAI1C,CAAA;AAED,eAAO,MAAM,uBAAuB,GAAI,IAAI,MAAM,GAAG,MAAM,KAAG,MAG7D,CAAA;AAED,eAAO,MAAM,wBAAwB,GACnC,GAAG,MAAM,EACT,SAAS,MAAM,EACf,eAAiC,KAChC,MAgBF,CAAA;AACD,eAAO,MAAM,qBAAqB,GAAI,KAAK,MAAM,GAAG,MAAM,GAAG,SAAS,WAGrE,CAAA;AAGD,eAAO,MAAM,gBAAgB,GAAI,eAAe,MAAM,GAAG,MAAM,WAI9D,CAAA"}
|
|
1
|
+
{"version":3,"file":"parsing.d.ts","sourceRoot":"","sources":["../../src/utils/parsing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAA;AAIhD,eAAO,MAAM,GAAG,QAAQ,CAAA;AAExB,eAAO,MAAM,cAAc,GAAI,SAAS,MAAM,EAAE,iBAAa,KAAG,MAO/D,CAAA;AAED,oBAAY,SAAS;IACnB,KAAK,IAAA;IACL,EAAE,IAAA;CACH;AAYD,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,WAEnC,CAAA;AAED,eAAO,MAAM,QAAQ,GAAI,KAAK,MAAM,WAEnC,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,KAAK,MAAM,WAI1C,CAAA;AAED,eAAO,MAAM,uBAAuB,GAAI,IAAI,MAAM,GAAG,MAAM,KAAG,MAG7D,CAAA;AAED,eAAO,MAAM,wBAAwB,GACnC,GAAG,MAAM,EACT,SAAS,MAAM,EACf,eAAiC,KAChC,MAgBF,CAAA;AACD,eAAO,MAAM,qBAAqB,GAAI,KAAK,MAAM,GAAG,MAAM,GAAG,SAAS,WAGrE,CAAA;AAGD,eAAO,MAAM,gBAAgB,GAAI,eAAe,MAAM,GAAG,MAAM,WAI9D,CAAA;AAED,eAAO,MAAM,eAAe,GAAI,OAAO,MAAM,EAAE,cAAY,KAAG,MAY7D,CAAA;AAED,eAAO,MAAM,iBAAiB,GAC5B,OAAO,MAAM,EACb,eAAe,MAAM,EACrB,SAAS,MAAM,KACd,MAYF,CAAA"}
|
package/dist/utils/parsing.js
CHANGED
|
@@ -65,3 +65,23 @@ export const convertRateToApr = (ratePerSecond) => {
|
|
|
65
65
|
return 0;
|
|
66
66
|
return rps * 3600 * 24 * 365 * 100;
|
|
67
67
|
};
|
|
68
|
+
export const formatAavePrice = (price, isV2 = false) => {
|
|
69
|
+
try {
|
|
70
|
+
return Number(formatEther(BigInt(price ?? '0') *
|
|
71
|
+
// 10^(18 - decimals)
|
|
72
|
+
10n ** (isV2 ? 0n : 10n)));
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return NaN;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
export const formatMorphoPrice = (price, collateralDec, debtDec) => {
|
|
79
|
+
try {
|
|
80
|
+
return Number(formatUnits(BigInt(price ?? '0'),
|
|
81
|
+
// 10^(18 - decimals)
|
|
82
|
+
36 + collateralDec - debtDec));
|
|
83
|
+
}
|
|
84
|
+
catch {
|
|
85
|
+
return NaN;
|
|
86
|
+
}
|
|
87
|
+
};
|
package/package.json
CHANGED
package/src/abis/morpho/lens.ts
CHANGED
|
@@ -1,31 +1,41 @@
|
|
|
1
1
|
export const MorphoLensAbi = [
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
2
|
+
{
|
|
3
|
+
inputs: [
|
|
4
|
+
{
|
|
5
|
+
internalType: 'bytes32[]',
|
|
6
|
+
name: 'marketsIds',
|
|
7
|
+
type: 'bytes32[]',
|
|
8
|
+
},
|
|
9
|
+
{
|
|
10
|
+
internalType: 'address',
|
|
11
|
+
name: 'user',
|
|
12
|
+
type: 'address',
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
internalType: 'address',
|
|
16
|
+
name: 'morpho',
|
|
17
|
+
type: 'address',
|
|
18
|
+
},
|
|
19
|
+
],
|
|
20
|
+
name: 'getUserDataCompact',
|
|
21
|
+
outputs: [
|
|
22
|
+
{
|
|
23
|
+
internalType: 'bytes',
|
|
24
|
+
name: 'data',
|
|
25
|
+
type: 'bytes',
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
stateMutability: 'view',
|
|
29
|
+
type: 'function',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: 'getMarketDataCompact',
|
|
33
|
+
type: 'function',
|
|
34
|
+
stateMutability: 'view',
|
|
35
|
+
inputs: [
|
|
36
|
+
{ type: 'address', name: 'morpho' },
|
|
37
|
+
{ type: 'bytes32[]', name: 'marketsIds' },
|
|
38
|
+
],
|
|
39
|
+
outputs: [{ type: 'bytes', name: 'data' }],
|
|
40
|
+
},
|
|
41
|
+
] as const
|
|
@@ -45,7 +45,7 @@ function createAssetArrayPerChain() {
|
|
|
45
45
|
return assetsPerChain
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
export const RELEVANT_LENDING_ASSETS = createAssetArrayPerChain()
|
|
48
|
+
export const RELEVANT_LENDING_ASSETS = () => createAssetArrayPerChain()
|
|
49
49
|
|
|
50
50
|
interface PoolData {
|
|
51
51
|
pool: string
|
|
@@ -72,7 +72,8 @@ function createSimpleArrayPerChain(
|
|
|
72
72
|
export const RELEVANT_BALANCER_V2_FORKS =
|
|
73
73
|
createSimpleArrayPerChain(BALANCER_V2_FORKS)
|
|
74
74
|
|
|
75
|
-
export const RELEVANT_MORPHOB_FORKS =
|
|
75
|
+
export const RELEVANT_MORPHOB_FORKS = () =>
|
|
76
|
+
createSimpleArrayPerChain(morphoPools())
|
|
76
77
|
|
|
77
78
|
export const RELEVANT_BALANCER_V3_FORKS = createSimpleArrayPerChain(
|
|
78
79
|
BALANCER_V3_FORKS,
|
|
@@ -16,6 +16,7 @@ import { formatUnits, zeroAddress } from 'viem'
|
|
|
16
16
|
import { AAVE_V2_LENDERS, AAVE_V3_LENDERS } from '@1delta/lender-registry'
|
|
17
17
|
import _ from 'lodash'
|
|
18
18
|
import { MULTICALL_ADDRESS } from '../utils/constants'
|
|
19
|
+
import { morphoPools } from '@1delta/data-sdk'
|
|
19
20
|
|
|
20
21
|
const DEFAULT_BATCH_SIZE = 4096
|
|
21
22
|
|
|
@@ -73,9 +74,9 @@ export async function fetchFlashLiquidityForChain(
|
|
|
73
74
|
})
|
|
74
75
|
|
|
75
76
|
// @ts-ignore
|
|
76
|
-
const morphoBs = RELEVANT_MORPHOB_FORKS[chain] ?? []
|
|
77
|
+
const morphoBs = RELEVANT_MORPHOB_FORKS()?.[chain] ?? []
|
|
77
78
|
|
|
78
|
-
const otherAssets = RELEVANT_LENDING_ASSETS[chain] ?? []
|
|
79
|
+
const otherAssets = RELEVANT_LENDING_ASSETS()?.[chain] ?? []
|
|
79
80
|
|
|
80
81
|
let morphoCalls: Call[] = []
|
|
81
82
|
|
|
@@ -22,6 +22,8 @@ import {
|
|
|
22
22
|
isAaveV3Type,
|
|
23
23
|
isCompoundV3,
|
|
24
24
|
isInit,
|
|
25
|
+
isMorphoType,
|
|
26
|
+
isMultiMarket,
|
|
25
27
|
} from '../utils'
|
|
26
28
|
import { AdditionalYields, MulticallRetryFunction } from '../types'
|
|
27
29
|
import { buildAaveV2StyleLenderReserveCall } from './aave-v2-type/publicCallBuild'
|
|
@@ -38,6 +40,9 @@ import { Lender } from '@1delta/lender-registry'
|
|
|
38
40
|
import { Call } from 'viem'
|
|
39
41
|
import { YLDRProtocolDataProviderAbi } from '../abis/aave-v2/YLDR'
|
|
40
42
|
import { GenericTokenList } from './types'
|
|
43
|
+
import { buildMorphoCall } from './morpho/publicCallBuild'
|
|
44
|
+
import { getMorphoMarketDataConverter } from './morpho/getMarketsFromChain'
|
|
45
|
+
import { MorphoLensAbi } from '../abis/morpho/lens'
|
|
41
46
|
|
|
42
47
|
function buildLenderCall(chainId: string, lender: Lender) {
|
|
43
48
|
if (isAaveV2Type(lender))
|
|
@@ -47,6 +52,7 @@ function buildLenderCall(chainId: string, lender: Lender) {
|
|
|
47
52
|
if (isCompoundV3(lender))
|
|
48
53
|
return buildCompoundV3StyleLenderReserveCall(chainId, lender)
|
|
49
54
|
if (isInit(lender)) return buildInitStyleLenderReserveCall(chainId, lender)
|
|
55
|
+
if (isMorphoType(lender)) return buildMorphoCall(chainId)
|
|
50
56
|
return []
|
|
51
57
|
}
|
|
52
58
|
|
|
@@ -90,6 +96,15 @@ function getLenderDataConverter(
|
|
|
90
96
|
additionalYields,
|
|
91
97
|
tokenList,
|
|
92
98
|
)
|
|
99
|
+
|
|
100
|
+
if (isMorphoType(lender))
|
|
101
|
+
return getMorphoMarketDataConverter(
|
|
102
|
+
lender,
|
|
103
|
+
chainId,
|
|
104
|
+
prices,
|
|
105
|
+
additionalYields,
|
|
106
|
+
tokenList,
|
|
107
|
+
)
|
|
93
108
|
return [() => null, 0] as any
|
|
94
109
|
}
|
|
95
110
|
|
|
@@ -112,6 +127,8 @@ const getAbi = (lender: string) => {
|
|
|
112
127
|
if (isCompoundV3(lender)) return [...IrgetterAbi, ...CometAbi, ...CometExtAbi]
|
|
113
128
|
|
|
114
129
|
if (isInit(lender)) return InitLensAbi
|
|
130
|
+
|
|
131
|
+
if (isMorphoType(lender)) return MorphoLensAbi
|
|
115
132
|
|
|
116
133
|
return []
|
|
117
134
|
}
|
|
@@ -153,7 +170,7 @@ export const getLenderPublicData = async (
|
|
|
153
170
|
])
|
|
154
171
|
|
|
155
172
|
const invalidLenders: string[] = []
|
|
156
|
-
|
|
173
|
+
let lenderData: { [lender: string]: any } = {}
|
|
157
174
|
|
|
158
175
|
let currentSlice = 0
|
|
159
176
|
for (const lender of lenders) {
|
|
@@ -167,10 +184,18 @@ export const getLenderPublicData = async (
|
|
|
167
184
|
if (sliceLength > 0) {
|
|
168
185
|
const data = rawResults.slice(currentSlice, currentSlice + sliceLength)
|
|
169
186
|
const convertedData = converter(data)
|
|
170
|
-
if (
|
|
171
|
-
|
|
187
|
+
if (isMultiMarket(lender)) {
|
|
188
|
+
if (!convertedData) {
|
|
189
|
+
invalidLenders.push(lender)
|
|
190
|
+
} else {
|
|
191
|
+
lenderData = { ...lenderData, ...convertedData }
|
|
192
|
+
}
|
|
172
193
|
} else {
|
|
173
|
-
|
|
194
|
+
if (!convertedData) {
|
|
195
|
+
invalidLenders.push(lender)
|
|
196
|
+
} else {
|
|
197
|
+
lenderData[lender] = convertedData
|
|
198
|
+
}
|
|
174
199
|
}
|
|
175
200
|
|
|
176
201
|
currentSlice += sliceLength
|
|
@@ -3,8 +3,17 @@ import { Lender } from '@1delta/lender-registry'
|
|
|
3
3
|
import { getLenderPublicData } from './fetchLender'
|
|
4
4
|
import { getLenderPublicDataViaApi } from './fetchLenderExt'
|
|
5
5
|
import { GenericTokenList } from './types'
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
import { Chain } from '@1delta/chain-registry'
|
|
7
|
+
|
|
8
|
+
function lenderCanUseApi(lender: string, chainId: string) {
|
|
9
|
+
if (lender === Lender.MORPHO_BLUE) {
|
|
10
|
+
if (chainId === Chain.HYPEREVM) return false
|
|
11
|
+
if (chainId === Chain.OP_MAINNET) return false
|
|
12
|
+
if (chainId === Chain.SONEIUM) return false
|
|
13
|
+
return true
|
|
14
|
+
}
|
|
15
|
+
return false
|
|
16
|
+
}
|
|
8
17
|
|
|
9
18
|
export const getLenderPublicDataAll = async (
|
|
10
19
|
chainId: string,
|
|
@@ -12,19 +21,30 @@ export const getLenderPublicDataAll = async (
|
|
|
12
21
|
prices: { [asset: string]: number },
|
|
13
22
|
additionalYields: AdditionalYields,
|
|
14
23
|
multicallRetry: MulticallRetryFunction,
|
|
15
|
-
tokenList?: () => Promise<GenericTokenList
|
|
24
|
+
tokenList?: () => Promise<GenericTokenList>,
|
|
16
25
|
): Promise<{ [lender: string]: any }> => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
26
|
+
const lendersApi = lenders.filter((l) => lenderCanUseApi(l, chainId))
|
|
27
|
+
|
|
28
|
+
const lendersOnChain = lenders.filter((l) => !lenderCanUseApi(l, chainId))
|
|
29
|
+
|
|
30
|
+
const onChain = getLenderPublicData(
|
|
31
|
+
chainId,
|
|
32
|
+
lendersOnChain,
|
|
33
|
+
prices,
|
|
34
|
+
additionalYields,
|
|
35
|
+
multicallRetry,
|
|
36
|
+
tokenList,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
const api = getLenderPublicDataViaApi(
|
|
40
|
+
chainId,
|
|
41
|
+
lendersApi,
|
|
42
|
+
prices,
|
|
43
|
+
additionalYields,
|
|
44
|
+
tokenList,
|
|
45
|
+
)
|
|
25
46
|
|
|
26
47
|
const [onChainRes, apiRes] = await Promise.all([onChain, api])
|
|
27
48
|
|
|
28
49
|
return { ...onChainRes, ...apiRes }
|
|
29
|
-
|
|
30
50
|
}
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { Address } from 'viem'
|
|
2
|
+
import { Chain } from '@1delta/chain-registry'
|
|
3
|
+
|
|
4
|
+
type MorphoContractName =
|
|
5
|
+
| 'Morpho'
|
|
6
|
+
| 'MetaMorphoFactory'
|
|
7
|
+
| 'MetaMorphoV1_1Factory'
|
|
8
|
+
|
|
9
|
+
type OptionalContracts = 'MetaMorphoFactory'
|
|
10
|
+
type RequiredContracts = Exclude<MorphoContractName, OptionalContracts>
|
|
11
|
+
type DeploymentDetails = { address: Address; fromBlock: bigint }
|
|
12
|
+
export type Deployments = {
|
|
13
|
+
[chainId: string]: {
|
|
14
|
+
[name in RequiredContracts]-?: DeploymentDetails
|
|
15
|
+
} & {
|
|
16
|
+
[name in OptionalContracts]?: DeploymentDetails
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const DEPLOYMENTS: Deployments = {
|
|
21
|
+
[Chain.ETHEREUM_MAINNET]: {
|
|
22
|
+
Morpho: {
|
|
23
|
+
address: '0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb',
|
|
24
|
+
fromBlock: 18883124n,
|
|
25
|
+
},
|
|
26
|
+
MetaMorphoFactory: {
|
|
27
|
+
address: '0xA9c3D3a366466Fa809d1Ae982Fb2c46E5fC41101',
|
|
28
|
+
fromBlock: 18925584n,
|
|
29
|
+
},
|
|
30
|
+
MetaMorphoV1_1Factory: {
|
|
31
|
+
address: '0x1897A8997241C1cD4bD0698647e4EB7213535c24',
|
|
32
|
+
fromBlock: 21439510n,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
[Chain.BASE]: {
|
|
36
|
+
Morpho: {
|
|
37
|
+
address: '0xBBBBBbbBBb9cC5e90e3b3Af64bdAF62C37EEFFCb',
|
|
38
|
+
fromBlock: 13977148n,
|
|
39
|
+
},
|
|
40
|
+
MetaMorphoFactory: {
|
|
41
|
+
address: '0xA9c3D3a366466Fa809d1Ae982Fb2c46E5fC41101',
|
|
42
|
+
fromBlock: 13978134n,
|
|
43
|
+
},
|
|
44
|
+
MetaMorphoV1_1Factory: {
|
|
45
|
+
address: '0xFf62A7c278C62eD665133147129245053Bbf5918',
|
|
46
|
+
fromBlock: 23928808n,
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
[Chain.INK]: {
|
|
50
|
+
Morpho: {
|
|
51
|
+
address: '0x857f3EefE8cbda3Bc49367C996cd664A880d3042',
|
|
52
|
+
fromBlock: 4078776n,
|
|
53
|
+
},
|
|
54
|
+
MetaMorphoV1_1Factory: {
|
|
55
|
+
address: '0xd3f39505d0c48AFED3549D625982FdC38Ea9904b',
|
|
56
|
+
fromBlock: 4078830n,
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
[Chain.ARBITRUM_ONE]: {
|
|
60
|
+
Morpho: {
|
|
61
|
+
address: '0x6c247b1F6182318877311737BaC0844bAa518F5e',
|
|
62
|
+
fromBlock: 296446593n,
|
|
63
|
+
},
|
|
64
|
+
MetaMorphoV1_1Factory: {
|
|
65
|
+
address: '0x878988f5f561081deEa117717052164ea1Ef0c82',
|
|
66
|
+
fromBlock: 296447195n,
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
[Chain.OP_MAINNET]: {
|
|
70
|
+
Morpho: {
|
|
71
|
+
address: '0xce95AfbB8EA029495c66020883F87aaE8864AF92',
|
|
72
|
+
fromBlock: 130770075n,
|
|
73
|
+
},
|
|
74
|
+
MetaMorphoV1_1Factory: {
|
|
75
|
+
address: '0x3Bb6A6A0Bc85b367EFE0A5bAc81c5E52C892839a',
|
|
76
|
+
fromBlock: 130770189n,
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
[Chain.POLYGON_MAINNET]: {
|
|
80
|
+
Morpho: {
|
|
81
|
+
address: '0x1bF0c2541F820E775182832f06c0B7Fc27A25f67',
|
|
82
|
+
fromBlock: 66931042n,
|
|
83
|
+
},
|
|
84
|
+
MetaMorphoV1_1Factory: {
|
|
85
|
+
address: '0xa9c87daB340631C34BB738625C70499e29ddDC98',
|
|
86
|
+
fromBlock: 66931118n,
|
|
87
|
+
},
|
|
88
|
+
},
|
|
89
|
+
[Chain.WORLD_CHAIN]: {
|
|
90
|
+
Morpho: {
|
|
91
|
+
address: '0xE741BC7c34758b4caE05062794E8Ae24978AF432',
|
|
92
|
+
fromBlock: 9025669n,
|
|
93
|
+
},
|
|
94
|
+
MetaMorphoV1_1Factory: {
|
|
95
|
+
address: '0x4DBB3a642a2146d5413750Cca3647086D9ba5F12',
|
|
96
|
+
fromBlock: 9025733n,
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
[Chain.SCROLL]: {
|
|
100
|
+
Morpho: {
|
|
101
|
+
address: '0x2d012EdbAdc37eDc2BC62791B666f9193FDF5a55',
|
|
102
|
+
fromBlock: 12842868n,
|
|
103
|
+
},
|
|
104
|
+
MetaMorphoV1_1Factory: {
|
|
105
|
+
address: '0x56b65742ade55015e6480959808229Ad6dbc9295',
|
|
106
|
+
fromBlock: 12842903n,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
[Chain.FRAXTAL]: {
|
|
110
|
+
Morpho: {
|
|
111
|
+
address: '0xa6030627d724bA78a59aCf43Be7550b4C5a0653b',
|
|
112
|
+
fromBlock: 15317931n,
|
|
113
|
+
},
|
|
114
|
+
MetaMorphoV1_1Factory: {
|
|
115
|
+
address: '0x27D4Af0AC9E7FDfA6D0853236f249CC27AE79488',
|
|
116
|
+
fromBlock: 15318007n,
|
|
117
|
+
},
|
|
118
|
+
},
|
|
119
|
+
[Chain.UNICHAIN]: {
|
|
120
|
+
Morpho: {
|
|
121
|
+
address: '0x8f5ae9CddB9f68de460C77730b018Ae7E04a140A',
|
|
122
|
+
fromBlock: 9139027n,
|
|
123
|
+
},
|
|
124
|
+
MetaMorphoV1_1Factory: {
|
|
125
|
+
address: '0xe9EdE3929F43a7062a007C3e8652e4ACa610Bdc0',
|
|
126
|
+
fromBlock: 9316789n,
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
[Chain.CORN]: {
|
|
130
|
+
Morpho: {
|
|
131
|
+
address: '0xc2B1E031540e3F3271C5F3819F0cC7479a8DdD90',
|
|
132
|
+
fromBlock: 251401n,
|
|
133
|
+
},
|
|
134
|
+
MetaMorphoV1_1Factory: {
|
|
135
|
+
address: '0xe430821595602eA5DD0cD350f86987437c7362fA',
|
|
136
|
+
fromBlock: 253027n,
|
|
137
|
+
},
|
|
138
|
+
},
|
|
139
|
+
[Chain.MODE]: {
|
|
140
|
+
Morpho: {
|
|
141
|
+
address: '0xd85cE6BD68487E0AaFb0858FDE1Cd18c76840564',
|
|
142
|
+
fromBlock: 19983370n,
|
|
143
|
+
},
|
|
144
|
+
MetaMorphoV1_1Factory: {
|
|
145
|
+
address: '0xae5b0884bfff430493D6C844B9fd052Af7d79278',
|
|
146
|
+
fromBlock: 19983443n,
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
[Chain.HEMI_NETWORK]: {
|
|
150
|
+
Morpho: {
|
|
151
|
+
address: '0xa4Ca2c2e25b97DA19879201bA49422bc6f181f42',
|
|
152
|
+
fromBlock: 1188872n,
|
|
153
|
+
},
|
|
154
|
+
MetaMorphoV1_1Factory: {
|
|
155
|
+
address: '0x8e52179BeB18E882040b01632440d8Ca0f01da82',
|
|
156
|
+
fromBlock: 1188885n,
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
[Chain.SONIC_MAINNET]: {
|
|
160
|
+
Morpho: {
|
|
161
|
+
address: '0xd6c916eB7542D0Ad3f18AEd0FCBD50C582cfa95f',
|
|
162
|
+
fromBlock: 9100931n,
|
|
163
|
+
},
|
|
164
|
+
MetaMorphoV1_1Factory: {
|
|
165
|
+
address: '0x0cE9e3512CB4df8ae7e265e62Fb9258dc14f12e8',
|
|
166
|
+
fromBlock: 9101319n,
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
[Chain.PLUME_MAINNET]: {
|
|
170
|
+
Morpho: {
|
|
171
|
+
address: '0x42b18785CE0Aed7BF7Ca43a39471ED4C0A3e0bB5',
|
|
172
|
+
fromBlock: 765994n,
|
|
173
|
+
},
|
|
174
|
+
MetaMorphoV1_1Factory: {
|
|
175
|
+
address: '0x2525D453D9BA13921D5aB5D8c12F9202b0e19456',
|
|
176
|
+
fromBlock: 766078n,
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
[Chain.LISK]: {
|
|
180
|
+
Morpho: {
|
|
181
|
+
address: '0x00cD58DEEbd7A2F1C55dAec715faF8aed5b27BF8',
|
|
182
|
+
fromBlock: 15731231n,
|
|
183
|
+
},
|
|
184
|
+
MetaMorphoV1_1Factory: {
|
|
185
|
+
address: '0x01dD876130690469F685a65C2B295A90a81BaD91',
|
|
186
|
+
fromBlock: 15731333n,
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
[Chain.SONEIUM]: {
|
|
190
|
+
Morpho: {
|
|
191
|
+
address: '0xE75Fc5eA6e74B824954349Ca351eb4e671ADA53a',
|
|
192
|
+
fromBlock: 6440817n,
|
|
193
|
+
},
|
|
194
|
+
MetaMorphoV1_1Factory: {
|
|
195
|
+
address: '0x7026b436f294e560b3C26E731f5cac5992cA2B33',
|
|
196
|
+
fromBlock: 6440899n,
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
[Chain.FLAME]: {
|
|
200
|
+
Morpho: {
|
|
201
|
+
address: '0x63971484590b054b6Abc4FEe9F31BC6F68CfeC04',
|
|
202
|
+
fromBlock: 5991116n,
|
|
203
|
+
},
|
|
204
|
+
MetaMorphoV1_1Factory: {
|
|
205
|
+
address: '0xf2BD176D3A89f6E9f6D0c7F17C4Ae6A3515007a8',
|
|
206
|
+
fromBlock: 5991236n,
|
|
207
|
+
},
|
|
208
|
+
},
|
|
209
|
+
[Chain.BASECAMP]: {
|
|
210
|
+
Morpho: {
|
|
211
|
+
address: '0xc7CAd9B1377Eb8103397Cb07Cb5c4f03eb2eBEa8',
|
|
212
|
+
fromBlock: 4804080n,
|
|
213
|
+
},
|
|
214
|
+
MetaMorphoV1_1Factory: {
|
|
215
|
+
address: '0xa8CD521d42b716821D7ddD2Ca6a237087aA5b487',
|
|
216
|
+
fromBlock: 4804270n,
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
[Chain.HYPEREVM]: {
|
|
220
|
+
Morpho: {
|
|
221
|
+
address: '0x68e37dE8d93d3496ae143F2E900490f6280C57cD',
|
|
222
|
+
fromBlock: 1988429n,
|
|
223
|
+
},
|
|
224
|
+
MetaMorphoV1_1Factory: {
|
|
225
|
+
address: '0xec051b19d654C48c357dC974376DeB6272f24e53',
|
|
226
|
+
fromBlock: 1988677n,
|
|
227
|
+
},
|
|
228
|
+
},
|
|
229
|
+
[Chain.KATANA]: {
|
|
230
|
+
Morpho: {
|
|
231
|
+
address: '0xD50F2DffFd62f94Ee4AEd9ca05C61d0753268aBc',
|
|
232
|
+
fromBlock: 2741069n,
|
|
233
|
+
},
|
|
234
|
+
MetaMorphoV1_1Factory: {
|
|
235
|
+
address: '0x1c8De6889acee12257899BFeAa2b7e534de32E16',
|
|
236
|
+
fromBlock: 2741420n,
|
|
237
|
+
},
|
|
238
|
+
},
|
|
239
|
+
[Chain.TAC_MAINNET]: {
|
|
240
|
+
Morpho: {
|
|
241
|
+
address: '0x918B9F2E4B44E20c6423105BB6cCEB71473aD35c',
|
|
242
|
+
fromBlock: 853025n,
|
|
243
|
+
},
|
|
244
|
+
MetaMorphoV1_1Factory: {
|
|
245
|
+
address: '0xcDA78f4979d17Ec93052A84A12001fe0088AD734',
|
|
246
|
+
fromBlock: 978654n,
|
|
247
|
+
},
|
|
248
|
+
},
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export function getContractDeploymentInfo(
|
|
252
|
+
chainId: number,
|
|
253
|
+
name: OptionalContracts,
|
|
254
|
+
): DeploymentDetails | undefined
|
|
255
|
+
export function getContractDeploymentInfo(
|
|
256
|
+
chainId: number,
|
|
257
|
+
name: RequiredContracts,
|
|
258
|
+
): DeploymentDetails
|
|
259
|
+
export function getContractDeploymentInfo(
|
|
260
|
+
chainId: number | undefined,
|
|
261
|
+
name: MorphoContractName,
|
|
262
|
+
): DeploymentDetails | undefined
|
|
263
|
+
export function getContractDeploymentInfo(
|
|
264
|
+
chainId: number | undefined,
|
|
265
|
+
name: MorphoContractName,
|
|
266
|
+
) {
|
|
267
|
+
return chainId !== undefined ? DEPLOYMENTS[chainId][name] : undefined
|
|
268
|
+
}
|