@1delta/margin-fetcher 0.0.26 → 0.0.27
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.
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { GetEvmClientFunction } from '../../types';
|
|
2
1
|
export declare const formatAavePrice: (price: string, isV2?: boolean) => number;
|
|
3
2
|
export declare const formatMorphoPrice: (price: string, collateralDec: number, debtDec: number) => number;
|
|
4
3
|
interface OracleData {
|
|
@@ -7,6 +6,8 @@ interface OracleData {
|
|
|
7
6
|
/**
|
|
8
7
|
* Fetches Aave and uniswap V2 oracle data
|
|
9
8
|
*/
|
|
10
|
-
export declare const fetchMainPrices: (chainIds: string[],
|
|
9
|
+
export declare const fetchMainPrices: (chainIds: string[], rpcOverrides?: {
|
|
10
|
+
[chainId: string]: string;
|
|
11
|
+
}) => Promise<OracleData>;
|
|
11
12
|
export {};
|
|
12
13
|
//# sourceMappingURL=fetchOracleData.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchOracleData.d.ts","sourceRoot":"","sources":["../../../src/prices/main-prices/fetchOracleData.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fetchOracleData.d.ts","sourceRoot":"","sources":["../../../src/prices/main-prices/fetchOracleData.ts"],"names":[],"mappings":"AAwBA,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;AAOD,UAAU,UAAU;IAClB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;CACtB;AAID;;GAEG;AACH,eAAO,MAAM,eAAe,GAC1B,UAAU,MAAM,EAAE,EAClB,eAAe;IAAE,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,KAC3C,OAAO,CAAC,UAAU,CAkKpB,CAAA"}
|
|
@@ -10,12 +10,12 @@ import { getAaveAssets } from '../../assets';
|
|
|
10
10
|
import { chainlinkOracles, getChainLinkKeys, ChainlinkAggregatorIndexes, } from './addresses/chainlink';
|
|
11
11
|
import { fetchDefillamaData } from '../defillama';
|
|
12
12
|
import { fetchPendlePrices } from '../pendle';
|
|
13
|
-
import { multicallViemAbiArray } from '../../utils/multicall';
|
|
14
13
|
import { AAVE_STYLE_ORACLES } from './addresses/aaveOracles';
|
|
15
14
|
import { AAVES_PER_CHAIN } from '../../utils';
|
|
16
15
|
import { parseRawAmount } from '../../utils/parsing';
|
|
17
16
|
import { ProxyOracleAbi } from '../../abis/oracle/ProxyOracle';
|
|
18
17
|
import { MrophoOracles } from './addresses/morpho';
|
|
18
|
+
import { multicallRetry } from '@1delta/providers';
|
|
19
19
|
export const formatAavePrice = (price, isV2 = false) => {
|
|
20
20
|
try {
|
|
21
21
|
return Number(formatEther(BigInt(price ?? '0') *
|
|
@@ -43,7 +43,7 @@ const RWA_DYNAMIC_ORACLE = '0xA96abbe61AfEdEB0D14a20440Ae7100D9aB4882f';
|
|
|
43
43
|
/**
|
|
44
44
|
* Fetches Aave and uniswap V2 oracle data
|
|
45
45
|
*/
|
|
46
|
-
export const fetchMainPrices = async (chainIds,
|
|
46
|
+
export const fetchMainPrices = async (chainIds, rpcOverrides) => {
|
|
47
47
|
const multicallPromises = chainIds.map(async (chainId) => {
|
|
48
48
|
const aaveForks = AAVES_PER_CHAIN[chainId];
|
|
49
49
|
const reservesToQuery = aaveForks?.map((a) => ({
|
|
@@ -87,7 +87,7 @@ export const fetchMainPrices = async (chainIds, getEvmClient) => {
|
|
|
87
87
|
...RWADynamicOracleAbi,
|
|
88
88
|
...ProxyOracleAbi,
|
|
89
89
|
];
|
|
90
|
-
const result = await
|
|
90
|
+
const result = await multicallRetry(chainId, allCalls, abis, undefined, 3, 0, true, rpcOverrides);
|
|
91
91
|
return {
|
|
92
92
|
chainId,
|
|
93
93
|
result,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1delta/margin-fetcher",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.27",
|
|
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.9"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "tsc",
|
|
@@ -15,13 +15,12 @@ import {
|
|
|
15
15
|
} from './addresses/chainlink'
|
|
16
16
|
import { fetchDefillamaData } from '../defillama'
|
|
17
17
|
import { fetchPendlePrices } from '../pendle'
|
|
18
|
-
import { multicallViemAbiArray } from '../../utils/multicall'
|
|
19
18
|
import { AAVE_STYLE_ORACLES } from './addresses/aaveOracles'
|
|
20
19
|
import { AAVES_PER_CHAIN } from '../../utils'
|
|
21
|
-
import { GetEvmClientFunction } from '../../types'
|
|
22
20
|
import { parseRawAmount } from '../../utils/parsing'
|
|
23
21
|
import { ProxyOracleAbi } from '../../abis/oracle/ProxyOracle'
|
|
24
22
|
import { MrophoOracleInfo, MrophoOracles } from './addresses/morpho'
|
|
23
|
+
import { multicallRetry } from '@1delta/providers'
|
|
25
24
|
|
|
26
25
|
export const formatAavePrice = (price: string, isV2 = false): number => {
|
|
27
26
|
try {
|
|
@@ -71,7 +70,7 @@ type QueryAave = { oracle: string; assets: string[]; fork: string }
|
|
|
71
70
|
*/
|
|
72
71
|
export const fetchMainPrices = async (
|
|
73
72
|
chainIds: string[],
|
|
74
|
-
|
|
73
|
+
rpcOverrides?: { [chainId: string]: string },
|
|
75
74
|
): Promise<OracleData> => {
|
|
76
75
|
const multicallPromises = chainIds.map(async (chainId) => {
|
|
77
76
|
const aaveForks = AAVES_PER_CHAIN[chainId]
|
|
@@ -126,11 +125,15 @@ export const fetchMainPrices = async (
|
|
|
126
125
|
...ProxyOracleAbi,
|
|
127
126
|
]
|
|
128
127
|
|
|
129
|
-
const result = await
|
|
128
|
+
const result = await multicallRetry(
|
|
130
129
|
chainId,
|
|
131
|
-
abis,
|
|
132
130
|
allCalls,
|
|
133
|
-
|
|
131
|
+
abis,
|
|
132
|
+
undefined,
|
|
133
|
+
3,
|
|
134
|
+
0,
|
|
135
|
+
true,
|
|
136
|
+
rpcOverrides,
|
|
134
137
|
)
|
|
135
138
|
|
|
136
139
|
return {
|
package/test/mainPrices.test.ts
CHANGED
|
@@ -10,16 +10,15 @@ describe(
|
|
|
10
10
|
it('should return prices for valid tokens', async () => {
|
|
11
11
|
const mainPrices = await fetchMainPrices(
|
|
12
12
|
[
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
Chain.MANTLE,
|
|
14
|
+
Chain.BNB_SMART_CHAIN_MAINNET,
|
|
15
|
+
Chain.OP_MAINNET,
|
|
16
|
+
Chain.POLYGON_MAINNET,
|
|
17
|
+
Chain.HEMI_NETWORK,
|
|
18
|
+
Chain.ARBITRUM_ONE,
|
|
19
19
|
Chain.HYPEREVM,
|
|
20
|
-
|
|
20
|
+
Chain.ETHEREUM_MAINNET,
|
|
21
21
|
],
|
|
22
|
-
getEvmClient,
|
|
23
22
|
)
|
|
24
23
|
prettyPrint(mainPrices)
|
|
25
24
|
})
|