@1delta/margin-fetcher 0.0.21 → 0.0.24
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/lending/addresses/compoundV3.d.ts +1 -2
- package/dist/lending/addresses/compoundV3.d.ts.map +1 -1
- package/dist/lending/addresses/compoundV3.js +17 -15
- package/dist/lending/compound-v3/publicCallBuild.js +2 -2
- package/dist/lending/fetchLender.d.ts.map +1 -1
- package/dist/lending/morpho/publicCallBuild.d.ts +1 -1
- package/dist/lending/morpho/publicCallBuild.d.ts.map +1 -1
- package/dist/lending/morpho/publicCallBuild.js +7 -3
- package/dist/lending/user-data/morpho/userCallBuild.d.ts.map +1 -1
- package/dist/lending/user-data/morpho/userCallBuild.js +1 -0
- package/dist/prices/main-prices/addresses/aaveOracles.d.ts +6 -0
- package/dist/prices/main-prices/addresses/aaveOracles.d.ts.map +1 -1
- package/dist/prices/main-prices/addresses/aaveOracles.js +6 -0
- package/dist/utils/multicall.d.ts.map +1 -1
- package/dist/utils/multicall.js +3 -3
- package/package.json +2 -2
- package/src/lending/addresses/compoundV3.ts +24 -23
- package/src/lending/compound-v3/publicCallBuild.ts +2 -2
- package/src/lending/fetchLender.ts +1 -2
- package/src/lending/morpho/publicCallBuild.ts +13 -8
- package/src/lending/user-data/morpho/userCallBuild.ts +1 -0
- package/src/prices/main-prices/addresses/aaveOracles.ts +6 -0
- package/src/utils/multicall.ts +45 -37
- package/test/lenderData.test.ts +3 -3
- package/test/lenderDataBasic.test.ts +43 -0
- package/test/mainPriceMB.test.ts +17 -2
- package/test/mainPrices.test.ts +1 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { Lender } from
|
|
1
|
+
import { Lender } from '@1delta/asset-registry';
|
|
2
2
|
export declare function getCompoundV3CometAddress(chainId: string, lender?: Lender): string | undefined;
|
|
3
3
|
export declare function getCompoundV3CometRewardsAddress(chainId: string): any;
|
|
4
|
-
export declare function getCompoundV3CometIRGetterAddress(chainId: string): any;
|
|
5
4
|
export declare function getCompoundV3CometLens(chainId: string): any;
|
|
6
5
|
export declare function getCompoundV3BaseAsset(lender: Lender | string, chainId: string): {
|
|
7
6
|
baseAsset: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compoundV3.d.ts","sourceRoot":"","sources":["../../../src/lending/addresses/compoundV3.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,MAAM,EAEP,MAAM,wBAAwB,
|
|
1
|
+
{"version":3,"file":"compoundV3.d.ts","sourceRoot":"","sources":["../../../src/lending/addresses/compoundV3.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,MAAM,EAEP,MAAM,wBAAwB,CAAA;AAE/B,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,MAAM,EACf,MAAM,SAA2B,GAChC,MAAM,GAAG,SAAS,CAEpB;AAED,wBAAgB,gCAAgC,CAAC,OAAO,EAAE,MAAM,OAG/D;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,MAAM,OAGrD;AAyBD,wBAAgB,sBAAsB,CACpC,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,OAAO,EAAE,MAAM;;;EAMhB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Chain, COMETS_PER_CHAIN_MAP, COMPOUND_BASE_TOKENS, Lender, SWAYLEND_BASE_TOKENS, } from
|
|
1
|
+
import { Chain, COMETS_PER_CHAIN_MAP, COMPOUND_BASE_TOKENS, Lender, SWAYLEND_BASE_TOKENS, } from '@1delta/asset-registry';
|
|
2
2
|
export function getCompoundV3CometAddress(chainId, lender = Lender.COMPOUND_V3_USDCE) {
|
|
3
3
|
return COMETS_PER_CHAIN_MAP[chainId]?.[lender];
|
|
4
4
|
}
|
|
@@ -6,28 +6,30 @@ export function getCompoundV3CometRewardsAddress(chainId) {
|
|
|
6
6
|
// @ts-ignore
|
|
7
7
|
return addressesCompoundV3.cometRewards[chainId];
|
|
8
8
|
}
|
|
9
|
-
export function getCompoundV3CometIRGetterAddress(chainId) {
|
|
10
|
-
// @ts-ignore
|
|
11
|
-
return addressesCompoundV3.lens[chainId];
|
|
12
|
-
}
|
|
13
9
|
export function getCompoundV3CometLens(chainId) {
|
|
14
10
|
// @ts-ignore
|
|
15
11
|
return addressesCompoundV3.lens[chainId];
|
|
16
12
|
}
|
|
17
13
|
const addressesCompoundV3 = {
|
|
18
14
|
lens: {
|
|
19
|
-
[Chain.POLYGON_MAINNET]:
|
|
20
|
-
[Chain.MANTLE]:
|
|
21
|
-
[Chain.ARBITRUM_ONE]:
|
|
22
|
-
[Chain.BASE]:
|
|
23
|
-
[Chain.OP_MAINNET]:
|
|
15
|
+
[Chain.POLYGON_MAINNET]: '0x4eDA401658c5286d16c4d342884F32280B4E8b1b',
|
|
16
|
+
[Chain.MANTLE]: '0x32B31A066c8dd3F7b77283Ba1d89Ddaf6DA0a8aE',
|
|
17
|
+
[Chain.ARBITRUM_ONE]: '0x13D9c35f4901491Ac4FFebd3100238BBfFBD7181',
|
|
18
|
+
[Chain.BASE]: '0x7e2D250E4FD0EeD6BD2cB3DC525A2b9f12508152',
|
|
19
|
+
[Chain.OP_MAINNET]: '0xA453ba397c61B0c292EA3959A858821145B2707F',
|
|
20
|
+
[Chain.ETHEREUM_MAINNET]: '0xCe434378adacC51d54312c872113D687Ac19B516',
|
|
21
|
+
[Chain.UNICHAIN]: '0x0bd7473CbBf81d9dD936c61117eD230d95006CA2',
|
|
22
|
+
[Chain.LINEA]: '0x7a59ddbB76521E8982Fa3A08598C9a83b14A6C07',
|
|
24
23
|
},
|
|
25
24
|
cometRewards: {
|
|
26
|
-
[Chain.POLYGON_MAINNET]:
|
|
27
|
-
[Chain.MANTLE]:
|
|
28
|
-
[Chain.ARBITRUM_ONE]:
|
|
29
|
-
[Chain.BASE]:
|
|
30
|
-
[Chain.OP_MAINNET]:
|
|
25
|
+
[Chain.POLYGON_MAINNET]: '0x45939657d1CA34A8FA39A924B71D28Fe8431e581',
|
|
26
|
+
[Chain.MANTLE]: '0xCd83CbBFCE149d141A5171C3D6a0F0fCCeE225Ab',
|
|
27
|
+
[Chain.ARBITRUM_ONE]: '0x88730d254A2f7e6AC8388c3198aFd694bA9f7fae',
|
|
28
|
+
[Chain.BASE]: '0x123964802e6ABabBE1Bc9547D72Ef1B69B00A6b1',
|
|
29
|
+
[Chain.OP_MAINNET]: '0x443EA0340cb75a160F31A440722dec7b5bc3C2E9',
|
|
30
|
+
[Chain.ETHEREUM_MAINNET]: '0x1B0e765F6224C21223AeA2af16c1C46E38885a40',
|
|
31
|
+
[Chain.SCROLL]: '0x70167D30964cbFDc315ECAe02441Af747bE0c5Ee',
|
|
32
|
+
[Chain.LINEA]: '0x2c7118c4C88B9841FCF839074c26Ae8f035f2921',
|
|
31
33
|
},
|
|
32
34
|
};
|
|
33
35
|
export function getCompoundV3BaseAsset(lender, chainId) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { getCompoundV3Assets } from "../../assets";
|
|
2
|
-
import { getCompoundV3BaseAsset, getCompoundV3CometAddress,
|
|
2
|
+
import { getCompoundV3BaseAsset, getCompoundV3CometAddress, getCompoundV3CometLens } from "../addresses/compoundV3";
|
|
3
3
|
export const buildCompoundV3StyleLenderReserveCall = (chainId, lender) => {
|
|
4
4
|
const baseAssetData = getCompoundV3BaseAsset(lender, chainId);
|
|
5
5
|
const underlyingArray = getCompoundV3Assets(chainId, lender);
|
|
@@ -46,7 +46,7 @@ export const buildCompoundV3StyleLenderReserveCall = (chainId, lender) => {
|
|
|
46
46
|
params: [],
|
|
47
47
|
};
|
|
48
48
|
const callInterest = {
|
|
49
|
-
address:
|
|
49
|
+
address: getCompoundV3CometLens(chainId),
|
|
50
50
|
name: 'getCometInterest',
|
|
51
51
|
params: [cometContractAddress],
|
|
52
52
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchLender.d.ts","sourceRoot":"","sources":["../../src/lending/fetchLender.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAWnE,OAAO,
|
|
1
|
+
{"version":3,"file":"fetchLender.d.ts","sourceRoot":"","sources":["../../src/lending/fetchLender.ts"],"names":[],"mappings":"AAyBA,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,MAAM,UAAU,CAAA;AAWnE,OAAO,EAAS,MAAM,EAAE,MAAM,wBAAwB,CAAA;AAGtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AA+E1C,eAAO,MAAM,mBAAmB,GAC9B,SAAS,MAAM,EACf,SAAS,MAAM,EAAE,EACjB,QAAQ;IAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EACnC,kBAAkB,gBAAgB,EAClC,gBAAgB,sBAAsB,EACtC,YAAW,MAAM,OAAO,CAAC,gBAAgB,CAExC,KACA,OAAO,CAAC;IAAE,CAAC,MAAM,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAqDnC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publicCallBuild.d.ts","sourceRoot":"","sources":["../../../src/lending/morpho/publicCallBuild.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"publicCallBuild.d.ts","sourceRoot":"","sources":["../../../src/lending/morpho/publicCallBuild.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAA;AAI9C,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,MAAM,EACf,MAAM,GAAE,gBAIP;;GAIF"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import { convertMarketsToMorphoResponse } from
|
|
2
|
-
import { fetchMorphoMarkets } from
|
|
3
|
-
export async function fetchMorphoPublicData(chainId, yields = {
|
|
1
|
+
import { convertMarketsToMorphoResponse } from './convertPublic';
|
|
2
|
+
import { fetchMorphoMarkets } from './fetchPublic';
|
|
3
|
+
export async function fetchMorphoPublicData(chainId, yields = {
|
|
4
|
+
intrinsicYields: {},
|
|
5
|
+
lenderRewards: {},
|
|
6
|
+
loaded: true,
|
|
7
|
+
}) {
|
|
4
8
|
const mbData = await fetchMorphoMarkets(chainId);
|
|
5
9
|
return convertMarketsToMorphoResponse(mbData, chainId, yields);
|
|
6
10
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"userCallBuild.d.ts","sourceRoot":"","sources":["../../../../src/lending/user-data/morpho/userCallBuild.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAyB,MAAM,wBAAwB,CAAA;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;
|
|
1
|
+
{"version":3,"file":"userCallBuild.d.ts","sourceRoot":"","sources":["../../../../src/lending/user-data/morpho/userCallBuild.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,MAAM,EAAyB,MAAM,wBAAwB,CAAA;AAC7E,OAAO,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAA;AAmC/C,eAAO,MAAM,mBAAmB,GAC9B,SAAS,MAAM,EACf,SAAS,MAAM,EACf,QAAQ,MAAM,EACd,gBAAgB,MAAM,EAAE,KACvB,IAAI,EAIN,CAAA;AAED,eAAO,MAAM,2BAA2B,GACtC,SAAS,MAAM,EACf,SAAS,MAAM,EACf,QAAQ,MAAM,EACd,gBAAgB,MAAM,EAAE,KACvB,IAAI,EAaN,CAAA"}
|
|
@@ -7,6 +7,7 @@ const MORPHO_LENS = {
|
|
|
7
7
|
[Chain.ARBITRUM_ONE]: '0xF64F862Fb7D687411585e06C08711B612e156530',
|
|
8
8
|
[Chain.KATANA]: '0xcB6Eb8df68153cebF60E1872273Ef52075a5C297',
|
|
9
9
|
[Chain.HYPEREVM]: '0xCe434378adacC51d54312c872113D687Ac19B516',
|
|
10
|
+
[Chain.ETHEREUM_MAINNET]: '0x0bd7473CbBf81d9dD936c61117eD230d95006CA2',
|
|
10
11
|
};
|
|
11
12
|
const getBaseMorphoCalls = (lender, chainId, account, marketsToQuery) => {
|
|
12
13
|
return marketsToQuery.flatMap((id) => [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aaveOracles.d.ts","sourceRoot":"","sources":["../../../../src/prices/main-prices/addresses/aaveOracles.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB
|
|
1
|
+
{"version":3,"file":"aaveOracles.d.ts","sourceRoot":"","sources":["../../../../src/prices/main-prices/addresses/aaveOracles.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA0S9B,CAAA"}
|
|
@@ -93,6 +93,12 @@ export const AAVE_STYLE_ORACLES = {
|
|
|
93
93
|
HYPERYIELD: {
|
|
94
94
|
'999': '0x2a740743Fc385197a71f0d1773E419715B88D734',
|
|
95
95
|
},
|
|
96
|
+
RADIANT_V2: {
|
|
97
|
+
'1': '0xbD60293fBe4B285402510562A64E5fCEE9c4a8F9',
|
|
98
|
+
'56': '0x0BB5c1Bc173b207cBf47CDf013617087776F3782',
|
|
99
|
+
'8453': '0xe373749cd9b2D379f7f6Dd595e5164498b922164',
|
|
100
|
+
'42161': '0xC0cE5De939aaD880b0bdDcf9aB5750a53EDa454b',
|
|
101
|
+
},
|
|
96
102
|
AVALON_SOLVBTC: {
|
|
97
103
|
'1': '0x7db0217b628240f583fA8Cb01fb98B79B80e99F1',
|
|
98
104
|
'56': '0xC204f75f22Ec427869aBf80b1b8Cf98e028f7Fc1',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"multicall.d.ts","sourceRoot":"","sources":["../../src/utils/multicall.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAE5D,MAAM,MAAM,IAAI,GAAG,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"multicall.d.ts","sourceRoot":"","sources":["../../src/utils/multicall.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAA;AAE5D,MAAM,MAAM,IAAI,GAAG,WAAW,CAAA;AAW9B,0FAA0F;AAC1F,eAAO,MAAM,qBAAqB,GAChC,SAAS,MAAM,EACf,KAAK,GAAG,EAAE,EACV,OAAO,IAAI,EAAE,EACb,cAAc,oBAAoB,EAClC,eAAY,EACZ,mBAAc,EACd,gBAAoB,KACnB,OAAO,CAAC,GAAG,EAAE,CAqCf,CAAA"}
|
package/dist/utils/multicall.js
CHANGED
|
@@ -16,14 +16,14 @@ export const multicallViemAbiArray = async (chainId, abi, calls, getEvmClient, r
|
|
|
16
16
|
args: params,
|
|
17
17
|
})),
|
|
18
18
|
});
|
|
19
|
-
const res = returnData.map(({ result, status }) => status !==
|
|
19
|
+
const res = returnData.map(({ result, status }) => status !== 'success' ? '0x' : result);
|
|
20
20
|
return res;
|
|
21
21
|
}
|
|
22
22
|
catch (error) {
|
|
23
|
-
console.log(
|
|
23
|
+
console.log('error in multicall', error);
|
|
24
24
|
retries--;
|
|
25
25
|
if (retries < 0)
|
|
26
|
-
throw new Error(
|
|
26
|
+
throw new Error('Failed too often');
|
|
27
27
|
providerId++;
|
|
28
28
|
return multicallViemAbiArray(chainId, abi, calls, getEvmClient, retry, providerId, retries);
|
|
29
29
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1delta/margin-fetcher",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"@types/async-retry": "^1.4.9",
|
|
18
18
|
"async-retry": "^1.3.3",
|
|
19
19
|
"typescript": "^5.9.2",
|
|
20
|
-
"@1delta/providers": "0.0.
|
|
20
|
+
"@1delta/providers": "0.0.8"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "tsc",
|
|
@@ -4,53 +4,54 @@ import {
|
|
|
4
4
|
COMPOUND_BASE_TOKENS,
|
|
5
5
|
Lender,
|
|
6
6
|
SWAYLEND_BASE_TOKENS,
|
|
7
|
-
} from
|
|
7
|
+
} from '@1delta/asset-registry'
|
|
8
8
|
|
|
9
9
|
export function getCompoundV3CometAddress(
|
|
10
10
|
chainId: string,
|
|
11
|
-
lender = Lender.COMPOUND_V3_USDCE
|
|
11
|
+
lender = Lender.COMPOUND_V3_USDCE,
|
|
12
12
|
): string | undefined {
|
|
13
|
-
return COMETS_PER_CHAIN_MAP[chainId]?.[lender]
|
|
13
|
+
return COMETS_PER_CHAIN_MAP[chainId]?.[lender]
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export function getCompoundV3CometRewardsAddress(chainId: string) {
|
|
17
17
|
// @ts-ignore
|
|
18
|
-
return addressesCompoundV3.cometRewards[chainId]
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function getCompoundV3CometIRGetterAddress(chainId: string) {
|
|
22
|
-
// @ts-ignore
|
|
23
|
-
return addressesCompoundV3.lens[chainId];
|
|
18
|
+
return addressesCompoundV3.cometRewards[chainId]
|
|
24
19
|
}
|
|
25
20
|
|
|
26
21
|
export function getCompoundV3CometLens(chainId: string) {
|
|
27
22
|
// @ts-ignore
|
|
28
|
-
return addressesCompoundV3.lens[chainId]
|
|
23
|
+
return addressesCompoundV3.lens[chainId]
|
|
29
24
|
}
|
|
30
25
|
|
|
31
26
|
const addressesCompoundV3 = {
|
|
32
27
|
lens: {
|
|
33
|
-
[Chain.POLYGON_MAINNET]:
|
|
34
|
-
[Chain.MANTLE]:
|
|
35
|
-
[Chain.ARBITRUM_ONE]:
|
|
36
|
-
[Chain.BASE]:
|
|
37
|
-
[Chain.OP_MAINNET]:
|
|
28
|
+
[Chain.POLYGON_MAINNET]: '0x4eDA401658c5286d16c4d342884F32280B4E8b1b',
|
|
29
|
+
[Chain.MANTLE]: '0x32B31A066c8dd3F7b77283Ba1d89Ddaf6DA0a8aE',
|
|
30
|
+
[Chain.ARBITRUM_ONE]: '0x13D9c35f4901491Ac4FFebd3100238BBfFBD7181',
|
|
31
|
+
[Chain.BASE]: '0x7e2D250E4FD0EeD6BD2cB3DC525A2b9f12508152',
|
|
32
|
+
[Chain.OP_MAINNET]: '0xA453ba397c61B0c292EA3959A858821145B2707F',
|
|
33
|
+
[Chain.ETHEREUM_MAINNET]: '0xCe434378adacC51d54312c872113D687Ac19B516',
|
|
34
|
+
[Chain.UNICHAIN]: '0x0bd7473CbBf81d9dD936c61117eD230d95006CA2',
|
|
35
|
+
[Chain.LINEA]: '0x7a59ddbB76521E8982Fa3A08598C9a83b14A6C07',
|
|
38
36
|
},
|
|
39
37
|
cometRewards: {
|
|
40
|
-
[Chain.POLYGON_MAINNET]:
|
|
41
|
-
[Chain.MANTLE]:
|
|
42
|
-
[Chain.ARBITRUM_ONE]:
|
|
43
|
-
[Chain.BASE]:
|
|
44
|
-
[Chain.OP_MAINNET]:
|
|
38
|
+
[Chain.POLYGON_MAINNET]: '0x45939657d1CA34A8FA39A924B71D28Fe8431e581',
|
|
39
|
+
[Chain.MANTLE]: '0xCd83CbBFCE149d141A5171C3D6a0F0fCCeE225Ab',
|
|
40
|
+
[Chain.ARBITRUM_ONE]: '0x88730d254A2f7e6AC8388c3198aFd694bA9f7fae',
|
|
41
|
+
[Chain.BASE]: '0x123964802e6ABabBE1Bc9547D72Ef1B69B00A6b1',
|
|
42
|
+
[Chain.OP_MAINNET]: '0x443EA0340cb75a160F31A440722dec7b5bc3C2E9',
|
|
43
|
+
[Chain.ETHEREUM_MAINNET]: '0x1B0e765F6224C21223AeA2af16c1C46E38885a40',
|
|
44
|
+
[Chain.SCROLL]: '0x70167D30964cbFDc315ECAe02441Af747bE0c5Ee',
|
|
45
|
+
[Chain.LINEA]: '0x2c7118c4C88B9841FCF839074c26Ae8f035f2921',
|
|
45
46
|
},
|
|
46
|
-
}
|
|
47
|
+
}
|
|
47
48
|
|
|
48
49
|
export function getCompoundV3BaseAsset(
|
|
49
50
|
lender: Lender | string,
|
|
50
|
-
chainId: string
|
|
51
|
+
chainId: string,
|
|
51
52
|
) {
|
|
52
53
|
return (
|
|
53
54
|
COMPOUND_BASE_TOKENS[lender]?.[chainId] ??
|
|
54
55
|
SWAYLEND_BASE_TOKENS[lender]?.[chainId]
|
|
55
|
-
)
|
|
56
|
+
)
|
|
56
57
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Lender } from "@1delta/asset-registry"
|
|
2
2
|
import { getCompoundV3Assets } from "../../assets"
|
|
3
|
-
import { getCompoundV3BaseAsset, getCompoundV3CometAddress,
|
|
3
|
+
import { getCompoundV3BaseAsset, getCompoundV3CometAddress, getCompoundV3CometLens } from "../addresses/compoundV3"
|
|
4
4
|
import { Call } from "../../utils/multicall"
|
|
5
5
|
|
|
6
6
|
export const buildCompoundV3StyleLenderReserveCall = (chainId: string, lender: Lender) => {
|
|
@@ -57,7 +57,7 @@ export const buildCompoundV3StyleLenderReserveCall = (chainId: string, lender: L
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
const callInterest: Call = {
|
|
60
|
-
address:
|
|
60
|
+
address: getCompoundV3CometLens(chainId),
|
|
61
61
|
name: 'getCometInterest',
|
|
62
62
|
params: [cometContractAddress],
|
|
63
63
|
}
|
|
@@ -34,7 +34,7 @@ import { getInitReservesDataConverter } from './init/publicCallParse'
|
|
|
34
34
|
import { getCompoundV3ReservesDataConverter } from './compound-v3/publicCallParse'
|
|
35
35
|
import { AavePoolLegacyAbi } from '../abis/aave-v3/AavePoolLegacy'
|
|
36
36
|
import { AavePoolDataProviderLegacyAbi } from '../abis/aave-v3/AavePoolDataProviderLegacy'
|
|
37
|
-
import { Lender } from '@1delta/asset-registry'
|
|
37
|
+
import { Chain, Lender } from '@1delta/asset-registry'
|
|
38
38
|
import { Call } from 'viem'
|
|
39
39
|
import { YLDRProtocolDataProviderAbi } from '../abis/aave-v2/YLDR'
|
|
40
40
|
import { GenericTokenList } from './types'
|
|
@@ -152,7 +152,6 @@ export const getLenderPublicData = async (
|
|
|
152
152
|
await tokenList(),
|
|
153
153
|
])
|
|
154
154
|
|
|
155
|
-
|
|
156
155
|
const invalidLenders: string[] = []
|
|
157
156
|
const lenderData: { [lender: string]: any } = {}
|
|
158
157
|
|
|
@@ -1,11 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import { Chain } from '@1delta/asset-registry'
|
|
2
|
+
import { AdditionalYields } from '../../types'
|
|
3
|
+
import { convertMarketsToMorphoResponse } from './convertPublic'
|
|
4
|
+
import { fetchMorphoMarkets } from './fetchPublic'
|
|
4
5
|
|
|
5
6
|
export async function fetchMorphoPublicData(
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
chainId: string,
|
|
8
|
+
yields: AdditionalYields = {
|
|
9
|
+
intrinsicYields: {},
|
|
10
|
+
lenderRewards: {},
|
|
11
|
+
loaded: true,
|
|
12
|
+
},
|
|
8
13
|
) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}
|
|
14
|
+
const mbData = await fetchMorphoMarkets(chainId)
|
|
15
|
+
return convertMarketsToMorphoResponse(mbData, chainId, yields)
|
|
16
|
+
}
|
|
@@ -9,6 +9,7 @@ const MORPHO_LENS: { [c: string]: string } = {
|
|
|
9
9
|
[Chain.ARBITRUM_ONE]: '0xF64F862Fb7D687411585e06C08711B612e156530',
|
|
10
10
|
[Chain.KATANA]: '0xcB6Eb8df68153cebF60E1872273Ef52075a5C297',
|
|
11
11
|
[Chain.HYPEREVM]: '0xCe434378adacC51d54312c872113D687Ac19B516',
|
|
12
|
+
[Chain.ETHEREUM_MAINNET]: '0x0bd7473CbBf81d9dD936c61117eD230d95006CA2',
|
|
12
13
|
}
|
|
13
14
|
|
|
14
15
|
const getBaseMorphoCalls = (
|
|
@@ -93,6 +93,12 @@ export const AAVE_STYLE_ORACLES = {
|
|
|
93
93
|
HYPERYIELD: {
|
|
94
94
|
'999': '0x2a740743Fc385197a71f0d1773E419715B88D734',
|
|
95
95
|
},
|
|
96
|
+
RADIANT_V2: {
|
|
97
|
+
'1': '0xbD60293fBe4B285402510562A64E5fCEE9c4a8F9',
|
|
98
|
+
'56': '0x0BB5c1Bc173b207cBf47CDf013617087776F3782',
|
|
99
|
+
'8453': '0xe373749cd9b2D379f7f6Dd595e5164498b922164',
|
|
100
|
+
'42161': '0xC0cE5De939aaD880b0bdDcf9aB5750a53EDa454b',
|
|
101
|
+
},
|
|
96
102
|
AVALON_SOLVBTC: {
|
|
97
103
|
'1': '0x7db0217b628240f583fA8Cb01fb98B79B80e99F1',
|
|
98
104
|
'56': '0xC204f75f22Ec427869aBf80b1b8Cf98e028f7Fc1',
|
package/src/utils/multicall.ts
CHANGED
|
@@ -3,51 +3,59 @@ import { GeneralCall, GetEvmClientFunction } from '../types'
|
|
|
3
3
|
|
|
4
4
|
export type Call = GeneralCall
|
|
5
5
|
|
|
6
|
-
|
|
7
6
|
interface ViemMulticallresult {
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
result: any[]
|
|
8
|
+
status: string
|
|
10
9
|
}
|
|
11
10
|
|
|
12
11
|
const MULTICALL_DEFAULT_BATCH_SIZE = 4096
|
|
13
12
|
|
|
14
13
|
const maxRetries = 3
|
|
15
14
|
|
|
16
|
-
|
|
17
15
|
/** Same as Multicall viem except that the abi param is supposed to be the abi per call */
|
|
18
16
|
export const multicallViemAbiArray = async (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
17
|
+
chainId: string,
|
|
18
|
+
abi: any[],
|
|
19
|
+
calls: Call[],
|
|
20
|
+
getEvmClient: GetEvmClientFunction,
|
|
21
|
+
retry = true,
|
|
22
|
+
providerId = 0,
|
|
23
|
+
retries = maxRetries,
|
|
26
24
|
): Promise<any[]> => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
25
|
+
try {
|
|
26
|
+
const provider = getEvmClient(chainId, providerId)
|
|
27
|
+
|
|
28
|
+
const abiIsArray = isArray(abi[0])
|
|
29
|
+
const returnData = await provider.multicall({
|
|
30
|
+
allowFailure: true,
|
|
31
|
+
batchSize: MULTICALL_DEFAULT_BATCH_SIZE,
|
|
32
|
+
contracts: calls.map(({ address, name, params }, i) => ({
|
|
33
|
+
abi: abiIsArray ? (abi?.[i] as any) : abi,
|
|
34
|
+
address: address as any,
|
|
35
|
+
functionName: name,
|
|
36
|
+
args: params,
|
|
37
|
+
})),
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
const res = (returnData as any[]).map(
|
|
41
|
+
({ result, status }: ViemMulticallresult) =>
|
|
42
|
+
status !== 'success' ? '0x' : result,
|
|
43
|
+
)
|
|
44
|
+
return res
|
|
45
|
+
} catch (error: any) {
|
|
46
|
+
console.log('error in multicall', error)
|
|
47
|
+
retries--
|
|
48
|
+
if (retries < 0) throw new Error('Failed too often')
|
|
49
|
+
providerId++
|
|
50
|
+
|
|
51
|
+
return multicallViemAbiArray(
|
|
52
|
+
chainId,
|
|
53
|
+
abi,
|
|
54
|
+
calls,
|
|
55
|
+
getEvmClient,
|
|
56
|
+
retry,
|
|
57
|
+
providerId,
|
|
58
|
+
retries,
|
|
59
|
+
)
|
|
60
|
+
}
|
|
53
61
|
}
|
package/test/lenderData.test.ts
CHANGED
|
@@ -16,8 +16,8 @@ import { prettyPrint } from './utils'
|
|
|
16
16
|
describe(
|
|
17
17
|
'find lending data',
|
|
18
18
|
() => {
|
|
19
|
-
it('should return lender data', async () => {
|
|
20
|
-
const chainId = Chain.
|
|
19
|
+
it.only('should return lender data', async () => {
|
|
20
|
+
const chainId = Chain.ARBITRUM_ONE
|
|
21
21
|
|
|
22
22
|
const ps = [
|
|
23
23
|
fetchMainPrices([chainId], getEvmClient),
|
|
@@ -29,7 +29,7 @@ describe(
|
|
|
29
29
|
// console.log("yields", yields)
|
|
30
30
|
// console.log("prices", prices)
|
|
31
31
|
|
|
32
|
-
const lenders =
|
|
32
|
+
const lenders = getLendersForChain(chainId) as any
|
|
33
33
|
console.log('lenders', lenders)
|
|
34
34
|
const lendingData = await getLenderPublicData(
|
|
35
35
|
chainId,
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { describe, it } from 'vitest'
|
|
2
|
+
import {
|
|
3
|
+
fetchGeneralYields,
|
|
4
|
+
fetchMainPrices,
|
|
5
|
+
getLenderPublicData,
|
|
6
|
+
} from '../src'
|
|
7
|
+
import { getEvmClient, multicallRetry } from '@1delta/providers'
|
|
8
|
+
import { Chain } from '@1delta/asset-registry'
|
|
9
|
+
import { getLendersForChain } from '../src/utils'
|
|
10
|
+
import { prettyPrint } from './utils'
|
|
11
|
+
|
|
12
|
+
describe(
|
|
13
|
+
'find lending data',
|
|
14
|
+
() => {
|
|
15
|
+
it('should return lender data', async () => {
|
|
16
|
+
const chainId = Chain.ETHEREUM_MAINNET
|
|
17
|
+
|
|
18
|
+
const ps = [
|
|
19
|
+
fetchMainPrices([chainId], getEvmClient),
|
|
20
|
+
fetchGeneralYields(),
|
|
21
|
+
]
|
|
22
|
+
|
|
23
|
+
const [prices, yields] = await Promise.all(ps)
|
|
24
|
+
|
|
25
|
+
// console.log("yields", yields)
|
|
26
|
+
// console.log("prices", prices)
|
|
27
|
+
|
|
28
|
+
const lenders = getLendersForChain(chainId) as any
|
|
29
|
+
console.log('lenders', lenders)
|
|
30
|
+
const lendingData = await getLenderPublicData(
|
|
31
|
+
chainId,
|
|
32
|
+
lenders,
|
|
33
|
+
prices as any,
|
|
34
|
+
yields as any,
|
|
35
|
+
multicallRetry,
|
|
36
|
+
)
|
|
37
|
+
|
|
38
|
+
prettyPrint(lendingData)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
},
|
|
42
|
+
{ timeout: 50000 },
|
|
43
|
+
)
|
package/test/mainPriceMB.test.ts
CHANGED
|
@@ -3,12 +3,27 @@ import { Chain } from '@1delta/asset-registry'
|
|
|
3
3
|
import { fetchMainPrices } from '../src'
|
|
4
4
|
import { getEvmClient } from '@1delta/providers'
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const chainIds =
|
|
7
|
+
// [ Chain.BASE]
|
|
8
|
+
[
|
|
9
|
+
Chain.HEMI_NETWORK,
|
|
10
|
+
Chain.BASE,
|
|
11
|
+
Chain.ARBITRUM_ONE,
|
|
12
|
+
Chain.MANTLE,
|
|
13
|
+
Chain.TAIKO_ALETHIA,
|
|
14
|
+
Chain.BNB_SMART_CHAIN_MAINNET,
|
|
15
|
+
Chain.KAIA_MAINNET,
|
|
16
|
+
Chain.SONEIUM,
|
|
17
|
+
Chain.GNOSIS,
|
|
18
|
+
Chain.CORE_BLOCKCHAIN_MAINNET,
|
|
19
|
+
Chain.HYPEREVM,
|
|
20
|
+
Chain.KATANA,
|
|
21
|
+
]
|
|
7
22
|
describe(
|
|
8
23
|
'find prices',
|
|
9
24
|
() => {
|
|
10
25
|
it('should return prices for valid tokens', async () => {
|
|
11
|
-
const prices = await fetchMainPrices(
|
|
26
|
+
const prices = await fetchMainPrices(chainIds, getEvmClient)
|
|
12
27
|
|
|
13
28
|
prettyPrint(prices)
|
|
14
29
|
})
|