@1delta/margin-fetcher 0.0.17 → 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/aave-v3-type/userCallParse.d.ts.map +1 -1
- package/dist/lending/user-data/fetchUserData.d.ts.map +1 -1
- package/dist/lending/user-data/fetchUserData.js +1 -3
- package/dist/lending/user-data/morpho/userCallParse.d.ts.map +1 -1
- package/dist/lending/user-data/morpho/userCallParse.js +2 -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/aave-v3-type/userCallParse.ts +2 -0
- package/src/lending/user-data/fetchUserData.ts +1 -4
- package/src/lending/user-data/morpho/userCallParse.ts +2 -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/data.ts +47979 -0
- 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
- package/test/userDataAll.test.ts +32 -41
|
@@ -77,7 +77,8 @@ export const getMorphoUserDataConverterWithlens = (lender, chainId, account, mar
|
|
|
77
77
|
id: market.id,
|
|
78
78
|
};
|
|
79
79
|
}
|
|
80
|
-
for (const
|
|
80
|
+
for (const marketId of markets) {
|
|
81
|
+
const pubData = lenderData[marketId];
|
|
81
82
|
if (marketsHandled.includes(marketId))
|
|
82
83
|
continue;
|
|
83
84
|
const payload = {
|
|
@@ -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
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"computeLendingPairs.d.ts","sourceRoot":"","sources":["../../src/lending-pairs/computeLendingPairs.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"computeLendingPairs.d.ts","sourceRoot":"","sources":["../../src/lending-pairs/computeLendingPairs.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAClD,OAAO,EAAe,UAAU,EAAY,MAAM,UAAU,CAAA;AAG5D,UAAU,eAAe;IACvB,KAAK,EAAE,eAAe,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;CACf;AAED,MAAM,WAAW,WAAW;IAE1B,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IAEd,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,MAAM,CAAA;IAElB,sBAAsB;IACtB,QAAQ,EAAE,eAAe,CAAA;IACzB,SAAS,EAAE,eAAe,CAAA;IAG1B,cAAc,EAAE,MAAM,CAAA;IAEtB,eAAe,EAAE,MAAM,CAAA;IAEvB,KAAK,EAAE,MAAM,CAAA;IACb,QAAQ,EAAE,MAAM,CAAA;IAChB,WAAW,EAAE,MAAM,CAAA;IAGnB,WAAW,EAAE,MAAM,CAAA;IACnB,GAAG,EAAE,MAAM,CAAA;IACX,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAA;IACf,KAAK,CAAC,EAAE,MAAM,CAAA;IAGd,oBAAoB,EAAE,MAAM,CAAA;IAC5B,gBAAgB,EAAE,MAAM,CAAA;IACxB,qBAAqB,EAAE,MAAM,CAAA;IAC7B,qBAAqB,EAAE,MAAM,CAAA;IAC7B,iBAAiB,EAAE,MAAM,CAAA;IACzB,sBAAsB,EAAE,MAAM,CAAA;IAG9B,YAAY,EAAE,OAAO,CAAA;IACrB,YAAY,EAAE,OAAO,CAAA;IACrB,aAAa,EAAE,OAAO,CAAA;IACtB,aAAa,EAAE,OAAO,CAAA;IACtB,qBAAqB,EAAE,OAAO,CAAA;CAC/B;AAmDD,kDAAkD;AAClD,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,EAC/B,UAAU,EAAE;IAAE,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GAClC,WAAW,EAAE,CA4If;AAkFD,wBAAgB,WAAW,CAAC,KAAK,EAAE,WAAW,EAAE;;;;;EAyB/C;AAMD,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,WAAW,EAAE,GACnB,WAAW,EAAE,CAwFf"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { getAssetMeta, toGenericPriceKey, toOracleKey } from
|
|
2
|
-
import { getLiquidityThresholds,
|
|
3
|
-
import { isAaveV3Type, isInit } from
|
|
1
|
+
import { getAssetMeta, toGenericPriceKey, toOracleKey } from '../assets';
|
|
2
|
+
import { getLiquidityThresholds, meetsLiquidityThresholdsLong, meetsLiquidityThresholdsShort, } from '../assets/liquidityThresholds';
|
|
3
|
+
import { isAaveV3Type, isInit } from '../utils';
|
|
4
4
|
const isEMode = (longData, shortData) => Boolean(longData.eMode)
|
|
5
5
|
? Number(longData.eMode?.category) > 0 &&
|
|
6
6
|
Number(longData.eMode?.category) === shortData.eMode?.category
|
|
@@ -46,12 +46,12 @@ export function generateLendingPairs(lenderData, prices, histPrices) {
|
|
|
46
46
|
// protect agaist error data
|
|
47
47
|
let pools = Object.values(lenderEntry?.data ?? lenderEntry ?? {}).map((a) => (a?.data ? a.data : a));
|
|
48
48
|
// sometimes error messages are included
|
|
49
|
-
const hasErrorMessages = pools.some((p) => typeof p ===
|
|
50
|
-
(p.includes(
|
|
49
|
+
const hasErrorMessages = pools.some((p) => typeof p === 'string' &&
|
|
50
|
+
(p.includes('No lenders available') || p.includes('Failed to fetch')));
|
|
51
51
|
if (hasErrorMessages)
|
|
52
52
|
continue;
|
|
53
53
|
// cast to poolData
|
|
54
|
-
const validPools = pools.filter((p) => typeof p ===
|
|
54
|
+
const validPools = pools.filter((p) => typeof p === 'object' && p !== null);
|
|
55
55
|
const poolArray = validPools.filter((p) => !p?.isFrozen);
|
|
56
56
|
// Loop through all ordered pairs of pools
|
|
57
57
|
for (let i = 0; i < poolArray.length; i++) {
|
|
@@ -66,8 +66,11 @@ export function generateLendingPairs(lenderData, prices, histPrices) {
|
|
|
66
66
|
if (long.underlying === short.underlying)
|
|
67
67
|
continue;
|
|
68
68
|
const maxDepositLeverage = getMaxLeverage(lender, long, short);
|
|
69
|
+
// non-leveraged pair is pointless
|
|
70
|
+
if (maxDepositLeverage < 1.05)
|
|
71
|
+
continue;
|
|
69
72
|
const borrowLeverage = maxDepositLeverage - 1;
|
|
70
|
-
const depositLeverage =
|
|
73
|
+
const depositLeverage = maxDepositLeverage;
|
|
71
74
|
let collateralRewards = 0;
|
|
72
75
|
let borrowRewards = 0;
|
|
73
76
|
const rewards = {};
|
|
@@ -100,8 +103,7 @@ export function generateLendingPairs(lenderData, prices, histPrices) {
|
|
|
100
103
|
// only base apr
|
|
101
104
|
const baseApr = depositApr * depositLeverage - borrowApr * borrowLeverage;
|
|
102
105
|
// only rewards apr
|
|
103
|
-
const rewardApr = collateralRewards * depositLeverage +
|
|
104
|
-
borrowRewards * borrowLeverage;
|
|
106
|
+
const rewardApr = collateralRewards * depositLeverage + borrowRewards * borrowLeverage;
|
|
105
107
|
// total apr
|
|
106
108
|
const totalApr = baseApr + rewardApr;
|
|
107
109
|
pairs.push({
|
|
@@ -109,6 +111,8 @@ export function generateLendingPairs(lenderData, prices, histPrices) {
|
|
|
109
111
|
lender,
|
|
110
112
|
assetLong: long.underlying,
|
|
111
113
|
assetShort: short.underlying,
|
|
114
|
+
infoLong: { poolId: long.poolId, asset: long.asset },
|
|
115
|
+
infoShort: { poolId: short.poolId, asset: short.asset },
|
|
112
116
|
price,
|
|
113
117
|
price24h,
|
|
114
118
|
assetGroupLong,
|
|
@@ -151,8 +155,8 @@ function filterPairsByCategory(pairs, longFilter, shortFilter) {
|
|
|
151
155
|
if (!longFilter(p.assetGroupLong) || !shortFilter(p.assetGroupShort)) {
|
|
152
156
|
return false;
|
|
153
157
|
}
|
|
154
|
-
if (p.assetGroupShort?.includes(
|
|
155
|
-
p.assetGroupLong?.includes(
|
|
158
|
+
if (p.assetGroupShort?.includes('PT-') ||
|
|
159
|
+
p.assetGroupLong?.includes('PT-')) {
|
|
156
160
|
return false;
|
|
157
161
|
}
|
|
158
162
|
if (!p.longIsActive ||
|
|
@@ -167,12 +171,12 @@ function filterPairsByCategory(pairs, longFilter, shortFilter) {
|
|
|
167
171
|
// apply liquidity thresholds
|
|
168
172
|
const longThresholds = getLiquidityThresholds(p.chainId, p.assetLong, p.assetGroupLong);
|
|
169
173
|
const shortThresholds = getLiquidityThresholds(p.chainId, p.assetShort, p.assetGroupShort);
|
|
170
|
-
const longMeetsThresholds =
|
|
174
|
+
const longMeetsThresholds = meetsLiquidityThresholdsLong({
|
|
171
175
|
totalDepositsUSD: p.longTotalDepositsUSD,
|
|
172
176
|
totalDebtUSD: p.longTotalDebtUSD,
|
|
173
177
|
totalLiquidityUSD: p.longTotalLiquidityUSD,
|
|
174
178
|
}, longThresholds);
|
|
175
|
-
const shortMeetsThresholds =
|
|
179
|
+
const shortMeetsThresholds = meetsLiquidityThresholdsShort({
|
|
176
180
|
totalDepositsUSD: p.shortTotalDepositsUSD,
|
|
177
181
|
totalDebtUSD: p.shortTotalDebtUSD,
|
|
178
182
|
totalLiquidityUSD: p.shortTotalLiquidityUSD,
|
|
@@ -182,13 +186,13 @@ function filterPairsByCategory(pairs, longFilter, shortFilter) {
|
|
|
182
186
|
}
|
|
183
187
|
return true;
|
|
184
188
|
})
|
|
185
|
-
.sort((a, b) => b.
|
|
189
|
+
.sort((a, b) => b.baseApr - a.baseApr)
|
|
186
190
|
.slice(0, MAX_ENTRIES);
|
|
187
191
|
}
|
|
188
192
|
export function getTopPairs(pairs) {
|
|
189
|
-
const stables = filterPairsByCategory(pairs, (group) => group?.includes(
|
|
190
|
-
const btcLst = filterPairsByCategory(pairs, (group) => group?.includes(
|
|
191
|
-
const ethLst = filterPairsByCategory(pairs, (group) => group?.includes(
|
|
193
|
+
const stables = filterPairsByCategory(pairs, (group) => group?.includes('USD') ?? false, (group) => group?.includes('USD') ?? false);
|
|
194
|
+
const btcLst = filterPairsByCategory(pairs, (group) => group?.includes('BTC') ?? false, (group) => group?.includes('BTC') ?? false);
|
|
195
|
+
const ethLst = filterPairsByCategory(pairs, (group) => group?.includes('ETH') ?? false, (group) => group?.includes('ETH') ?? false);
|
|
192
196
|
return {
|
|
193
197
|
stables,
|
|
194
198
|
btcLst,
|
|
@@ -197,7 +201,7 @@ export function getTopPairs(pairs) {
|
|
|
197
201
|
};
|
|
198
202
|
}
|
|
199
203
|
function isStable(assetGroup) {
|
|
200
|
-
return assetGroup.includes(
|
|
204
|
+
return assetGroup.includes('USD');
|
|
201
205
|
}
|
|
202
206
|
export function getDistinctPairsByShortAsset(pairs) {
|
|
203
207
|
const qualityPairs = pairs.filter((p) => {
|
|
@@ -216,12 +220,12 @@ export function getDistinctPairsByShortAsset(pairs) {
|
|
|
216
220
|
// Apply liquidity thresholds
|
|
217
221
|
const longThresholds = getLiquidityThresholds(p.chainId, p.assetLong, p.assetGroupLong);
|
|
218
222
|
const shortThresholds = getLiquidityThresholds(p.chainId, p.assetShort, p.assetGroupShort);
|
|
219
|
-
const longMeetsThresholds =
|
|
223
|
+
const longMeetsThresholds = meetsLiquidityThresholdsLong({
|
|
220
224
|
totalDepositsUSD: p.longTotalDepositsUSD,
|
|
221
225
|
totalDebtUSD: p.longTotalDebtUSD,
|
|
222
226
|
totalLiquidityUSD: p.longTotalLiquidityUSD,
|
|
223
227
|
}, longThresholds);
|
|
224
|
-
const shortMeetsThresholds =
|
|
228
|
+
const shortMeetsThresholds = meetsLiquidityThresholdsShort({
|
|
225
229
|
totalDepositsUSD: p.shortTotalDepositsUSD,
|
|
226
230
|
totalDebtUSD: p.shortTotalDebtUSD,
|
|
227
231
|
totalLiquidityUSD: p.shortTotalLiquidityUSD,
|
|
@@ -229,8 +233,8 @@ export function getDistinctPairsByShortAsset(pairs) {
|
|
|
229
233
|
if (!longMeetsThresholds || !shortMeetsThresholds) {
|
|
230
234
|
return false;
|
|
231
235
|
}
|
|
232
|
-
if (p.assetGroupShort?.includes(
|
|
233
|
-
p.assetGroupLong?.includes(
|
|
236
|
+
if (p.assetGroupShort?.includes('PT-') ||
|
|
237
|
+
p.assetGroupLong?.includes('PT-')) {
|
|
234
238
|
return false;
|
|
235
239
|
}
|
|
236
240
|
return true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/prices/defillama/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/prices/defillama/index.ts"],"names":[],"mappings":"AAkOA,wBAAsB,kBAAkB,iBAwCvC;AAED,wBAAsB,sBAAsB,iBA2C3C"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import fetch from
|
|
1
|
+
import fetch from 'axios';
|
|
2
2
|
const prefixEthereum = 'ethereum:';
|
|
3
3
|
const RETH = '0xae78736Cd615f374D3085123A210448E74Fc6393';
|
|
4
4
|
const WBTC = '0x2260fac5e5542a773aa44fbcfedf7c193bc2c599';
|
|
@@ -32,14 +32,14 @@ const FRAX = '0x853d955acef822db058eb8505911ed77f175b99e';
|
|
|
32
32
|
const WEETH = '0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee';
|
|
33
33
|
const ARB = '0xb50721bcf8d664c30412cfbc6cf7a15145234ad1';
|
|
34
34
|
const WUSDM = '0x57f5e098cad7a3d1eed53991d4d66c45c9af7812';
|
|
35
|
-
const RSETH =
|
|
36
|
-
const CBETH =
|
|
37
|
-
const SNX =
|
|
38
|
-
const VUSD =
|
|
39
|
-
const EZETH =
|
|
40
|
-
const LBTC =
|
|
41
|
-
const BRBTC =
|
|
42
|
-
const SDAI =
|
|
35
|
+
const RSETH = '0xa1290d69c65a6fe4df752f95823fae25cb99e5a7';
|
|
36
|
+
const CBETH = '0xbe9895146f7af43049ca1c1ae358b0541ea49704';
|
|
37
|
+
const SNX = '0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f';
|
|
38
|
+
const VUSD = '0x677ddbd918637e5f2c79e164d402454de7da8619';
|
|
39
|
+
const EZETH = '0xbf5495Efe5DB9ce00f80364C8B423567e58d2110';
|
|
40
|
+
const LBTC = '0x8236a87084f8B84306f72007F36F2618A5634494';
|
|
41
|
+
const BRBTC = '0x2eC37d45FCAE65D9787ECf71dc85a444968f6646';
|
|
42
|
+
const SDAI = '0x83f20f44975d03b1b09e64809b757c47f942beea';
|
|
43
43
|
const datasEthereum = [
|
|
44
44
|
RETH,
|
|
45
45
|
WBTC,
|
|
@@ -80,41 +80,45 @@ const datasEthereum = [
|
|
|
80
80
|
VUSD,
|
|
81
81
|
LBTC,
|
|
82
82
|
BRBTC,
|
|
83
|
-
SDAI
|
|
84
|
-
]
|
|
83
|
+
SDAI,
|
|
84
|
+
]
|
|
85
|
+
.map((d) => prefixEthereum + d)
|
|
86
|
+
.join(',');
|
|
85
87
|
const prefixAvalanche = 'avax:';
|
|
86
88
|
const WAVAX = '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7';
|
|
87
|
-
const SAVAX =
|
|
88
|
-
const prefixArbitrum =
|
|
89
|
-
const GMX =
|
|
90
|
-
const prefixOptimism =
|
|
91
|
-
const OP =
|
|
92
|
-
const SUSD =
|
|
93
|
-
const WRSETH =
|
|
94
|
-
const prefixBase =
|
|
95
|
-
const AERO =
|
|
96
|
-
const prefixCore =
|
|
97
|
-
const WCORE =
|
|
98
|
-
const prefixMetis =
|
|
99
|
-
const WMETIS =
|
|
100
|
-
const prefixSonic =
|
|
101
|
-
const WS =
|
|
102
|
-
const prefixFantom =
|
|
103
|
-
const WFTM =
|
|
104
|
-
const
|
|
105
|
-
const
|
|
106
|
-
const
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
].map(d =>
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
const
|
|
114
|
-
const
|
|
115
|
-
const
|
|
116
|
-
const
|
|
117
|
-
const
|
|
89
|
+
const SAVAX = '0x2b2C81e08f1Af8835a78Bb2A90AE924ACE0eA4bE';
|
|
90
|
+
const prefixArbitrum = 'arbitrum:';
|
|
91
|
+
const GMX = '0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a';
|
|
92
|
+
const prefixOptimism = 'optimism:';
|
|
93
|
+
const OP = '0x4200000000000000000000000000000000000042';
|
|
94
|
+
const SUSD = '0x8c6f28f2F1A3C87F0f938b96d27520d9751ec8d9';
|
|
95
|
+
const WRSETH = '0x87eee96d50fb761ad85b1c982d28a042169d61b1';
|
|
96
|
+
const prefixBase = 'base:';
|
|
97
|
+
const AERO = '0x940181a94A35A4569E4529A3CDfB74e38FD98631';
|
|
98
|
+
const prefixCore = 'core:';
|
|
99
|
+
const WCORE = '0xb0788b601c0d712702bc829b52771199ad8e33ff';
|
|
100
|
+
const prefixMetis = 'metis:';
|
|
101
|
+
const WMETIS = '0x75cb093e4d61d2a2e65d8e0bbb01de8d89b53481';
|
|
102
|
+
const prefixSonic = 'sonic:';
|
|
103
|
+
const WS = '0x039e2fb66102314ce7b64ce5ce3e5183bc94ad38';
|
|
104
|
+
const prefixFantom = 'fantom:';
|
|
105
|
+
const WFTM = '0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83';
|
|
106
|
+
const prefixHyperEVM = 'hyperliquid:';
|
|
107
|
+
const WYPE = '0x5555555555555555555555555555555555555555';
|
|
108
|
+
// const prefixKaia = 'kaia:'
|
|
109
|
+
// const WKAIA = '0x19aac5f612f524b754ca7e7c41cbfa2e981a4432'
|
|
110
|
+
const datasAvalanche = [WAVAX, SAVAX].map((d) => prefixAvalanche + d).join(',');
|
|
111
|
+
const datasArbitrum = [GMX].map((d) => prefixArbitrum + d).join(',');
|
|
112
|
+
const datasOptimism = [OP, SUSD, WRSETH]
|
|
113
|
+
.map((d) => prefixOptimism + d)
|
|
114
|
+
.join(',');
|
|
115
|
+
const datasBase = [AERO].map((d) => prefixBase + d).join(',');
|
|
116
|
+
const datasCore = [WCORE].map((d) => prefixCore + d).join(',');
|
|
117
|
+
const datasMetis = [WMETIS].map((d) => prefixMetis + d).join(',');
|
|
118
|
+
const datasFantom = [WFTM].map((d) => prefixFantom + d).join(',');
|
|
119
|
+
const datasSonic = [WS].map((d) => prefixSonic + d).join(',');
|
|
120
|
+
const datasHyperEvm = [WYPE].map((d) => prefixHyperEVM + d).join(',');
|
|
121
|
+
// const datasKaia = [WKAIA].map((d) => prefixKaia + d).join(',')
|
|
118
122
|
const URL = `https://coins.llama.fi/prices/current/${[
|
|
119
123
|
datasEthereum,
|
|
120
124
|
datasAvalanche,
|
|
@@ -124,7 +128,8 @@ const URL = `https://coins.llama.fi/prices/current/${[
|
|
|
124
128
|
datasCore,
|
|
125
129
|
datasMetis,
|
|
126
130
|
datasFantom,
|
|
127
|
-
|
|
131
|
+
datasHyperEvm,
|
|
132
|
+
// datasKaia,
|
|
128
133
|
datasSonic, //
|
|
129
134
|
].join(',')}?searchWidth=4h`;
|
|
130
135
|
const URL_HIST = (ref) => `https://coins.llama.fi/prices/historical/${ref}/${[
|
|
@@ -136,99 +141,103 @@ const URL_HIST = (ref) => `https://coins.llama.fi/prices/historical/${ref}/${[
|
|
|
136
141
|
datasCore,
|
|
137
142
|
datasMetis,
|
|
138
143
|
datasFantom,
|
|
139
|
-
datasKaia,
|
|
144
|
+
// datasKaia,
|
|
145
|
+
datasHyperEvm,
|
|
140
146
|
datasSonic, //
|
|
141
147
|
].join(',')}?searchWidth=4h`;
|
|
142
148
|
const SYMBOL_MAP = {
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
149
|
+
weth: 'WETH',
|
|
150
|
+
usde: 'USDE',
|
|
151
|
+
meth: 'METH',
|
|
152
|
+
mnt: 'WMNT',
|
|
153
|
+
usdc: 'USDC',
|
|
154
|
+
usdt: 'USDT',
|
|
155
|
+
wbtc: 'WBTC',
|
|
156
|
+
usdy: 'USDY',
|
|
157
|
+
crv: 'CRV',
|
|
158
|
+
op: 'OP',
|
|
159
|
+
bal: 'BAL',
|
|
160
|
+
eura: 'AGEUR',
|
|
161
|
+
link: 'LINK',
|
|
162
|
+
dai: 'DAI',
|
|
163
|
+
bnb: 'WBNB',
|
|
164
|
+
matic: 'WPOL',
|
|
165
|
+
wpol: 'WPOL',
|
|
166
|
+
pol: 'WPOL',
|
|
167
|
+
stmatic: 'STMATIC',
|
|
168
|
+
maticx: 'MATICX',
|
|
169
|
+
wavax: 'WAVAX',
|
|
170
|
+
aave: 'AAVE',
|
|
171
|
+
comp: 'COMP',
|
|
172
|
+
eurs: 'EURS',
|
|
173
|
+
fbtc: 'FBTC',
|
|
174
|
+
taiko: 'TAIKO',
|
|
175
|
+
cmeth: 'CMETH',
|
|
176
|
+
ausd: 'AUSD',
|
|
177
|
+
susde: 'SUSDE',
|
|
178
|
+
fuel: 'FUEL',
|
|
179
|
+
gho: 'GHO',
|
|
180
|
+
frax: 'FRAX',
|
|
181
|
+
weeth: 'WEETH',
|
|
182
|
+
arb: 'ARB',
|
|
183
|
+
lusd: 'LUSD',
|
|
184
|
+
reth: 'RETH',
|
|
185
|
+
gmx: 'GMX',
|
|
186
|
+
wusdm: 'WUSDM',
|
|
187
|
+
rseth: 'RSETH',
|
|
188
|
+
susd: 'SUSD',
|
|
189
|
+
wrseth: 'WRSETH',
|
|
190
|
+
cbeth: 'CBETH',
|
|
191
|
+
aero: 'AERO',
|
|
192
|
+
snx: 'SNX',
|
|
193
|
+
wftm: 'WFTM',
|
|
194
|
+
ftm: 'WFTM',
|
|
195
|
+
wcore: 'WCORE',
|
|
196
|
+
core: 'WCORE',
|
|
197
|
+
ws: 'WS',
|
|
198
|
+
s: 'WS',
|
|
199
|
+
wmetis: 'WMETIS',
|
|
200
|
+
metis: 'WMETIS',
|
|
201
|
+
vusd: 'VUSD',
|
|
202
|
+
ezeth: 'EZETH',
|
|
203
|
+
lbtc: 'LBTC',
|
|
204
|
+
brbtc: 'BRBTC',
|
|
205
|
+
sdai: 'SDAI',
|
|
206
|
+
wkaia: 'KAIA',
|
|
207
|
+
savax: 'SAVAX',
|
|
208
|
+
whype: 'WHYPE',
|
|
202
209
|
};
|
|
203
210
|
export async function fetchDefillamaData() {
|
|
204
211
|
try {
|
|
205
212
|
const res = await fetch(URL);
|
|
206
|
-
let prices = Object.assign({}, ...Object.values(res.data.coins).map(
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
prices[
|
|
211
|
-
prices[
|
|
212
|
-
prices[
|
|
213
|
-
prices[
|
|
214
|
-
prices[
|
|
215
|
-
prices[
|
|
216
|
-
prices[
|
|
217
|
-
prices[
|
|
218
|
-
prices[
|
|
219
|
-
prices[
|
|
220
|
-
prices[
|
|
221
|
-
prices[
|
|
222
|
-
prices[
|
|
223
|
-
prices[
|
|
224
|
-
prices[
|
|
225
|
-
prices[
|
|
226
|
-
prices[
|
|
227
|
-
prices[
|
|
213
|
+
let prices = Object.assign({}, ...Object.values(res.data.coins).map((k) => {
|
|
214
|
+
// @ts-ignore
|
|
215
|
+
return { [SYMBOL_MAP[k.symbol.toLowerCase()]]: k.price };
|
|
216
|
+
}));
|
|
217
|
+
prices['POL'] = prices['WPOL'];
|
|
218
|
+
prices['BNB'] = prices['WBNB'];
|
|
219
|
+
prices['ETH'] = prices['WETH'];
|
|
220
|
+
prices['S'] = prices['WS'];
|
|
221
|
+
prices['CORE'] = prices['WCORE'];
|
|
222
|
+
prices['AVAX'] = prices['WAVAX'];
|
|
223
|
+
prices['METIS'] = prices['WMETIS'];
|
|
224
|
+
// prices['WKAIA'] = prices['KAIA']
|
|
225
|
+
prices['USDBC'] = prices['USDC'];
|
|
226
|
+
prices['BTCB'] = prices['WBTC'];
|
|
227
|
+
prices['CBBTC'] = prices['WBTC'];
|
|
228
|
+
prices['SOLVBTC'] = prices['WBTC'];
|
|
229
|
+
prices['XSOLVBTC'] = prices['WBTC'];
|
|
230
|
+
prices['SUBTC'] = prices['WBTC'];
|
|
231
|
+
prices['IBTC'] = prices['WBTC'];
|
|
232
|
+
prices['ENZOBTC'] = prices['WBTC'];
|
|
233
|
+
prices['LUSD'] = prices['USDT'];
|
|
234
|
+
prices['XDAI'] = prices['DAI'];
|
|
235
|
+
prices['WXDAI'] = prices['DAI'];
|
|
236
|
+
prices['HYPE'] = prices['WHYPE'];
|
|
228
237
|
return prices;
|
|
229
238
|
}
|
|
230
239
|
catch (e) {
|
|
231
|
-
console.log(
|
|
240
|
+
console.log('error fetching prices from defillama', e);
|
|
232
241
|
return {};
|
|
233
242
|
}
|
|
234
243
|
}
|
|
@@ -236,34 +245,36 @@ export async function fetchDefillamaHistData() {
|
|
|
236
245
|
try {
|
|
237
246
|
const nowMinus24 = Math.floor(Date.now() / 1000 - 24 * 3600);
|
|
238
247
|
const resHist = await fetch(URL_HIST(nowMinus24));
|
|
239
|
-
let histPrices = Object.assign({}, ...Object.values(resHist.data.coins).map(
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
histPrices[
|
|
244
|
-
histPrices[
|
|
245
|
-
histPrices[
|
|
246
|
-
histPrices[
|
|
247
|
-
histPrices[
|
|
248
|
-
histPrices[
|
|
249
|
-
histPrices[
|
|
250
|
-
histPrices[
|
|
251
|
-
histPrices[
|
|
252
|
-
histPrices[
|
|
253
|
-
histPrices[
|
|
254
|
-
histPrices[
|
|
255
|
-
histPrices[
|
|
256
|
-
histPrices[
|
|
257
|
-
histPrices[
|
|
258
|
-
histPrices[
|
|
259
|
-
histPrices[
|
|
260
|
-
histPrices[
|
|
261
|
-
histPrices[
|
|
262
|
-
histPrices[
|
|
248
|
+
let histPrices = Object.assign({}, ...Object.values(resHist.data.coins).map((k) => {
|
|
249
|
+
// @ts-ignore
|
|
250
|
+
return { [SYMBOL_MAP[k.symbol.toLowerCase()]]: k.price };
|
|
251
|
+
}));
|
|
252
|
+
histPrices['POL'] = histPrices['WPOL'];
|
|
253
|
+
histPrices['BNB'] = histPrices['WBNB'];
|
|
254
|
+
histPrices['ETH'] = histPrices['WETH'];
|
|
255
|
+
histPrices['S'] = histPrices['WS'];
|
|
256
|
+
histPrices['CORE'] = histPrices['WCORE'];
|
|
257
|
+
histPrices['AVAX'] = histPrices['WAVAX'];
|
|
258
|
+
histPrices['METIS'] = histPrices['WMETIS'];
|
|
259
|
+
histPrices['HYPE'] = histPrices['WHYPE'];
|
|
260
|
+
// histPrices['WKAIA'] = histPrices['KAIA']
|
|
261
|
+
histPrices['LUSD'] = histPrices['USDT'];
|
|
262
|
+
histPrices['XDAI'] = histPrices['DAI'];
|
|
263
|
+
histPrices['WXDAI'] = histPrices['DAI'];
|
|
264
|
+
histPrices['BTCB'] = histPrices['WBTC'];
|
|
265
|
+
histPrices['M-BTC'] = histPrices['WBTC'];
|
|
266
|
+
histPrices['SOLVBTC'] = histPrices['WBTC'];
|
|
267
|
+
histPrices['XSOLVBTC'] = histPrices['WBTC'];
|
|
268
|
+
histPrices['UNIBTC'] = histPrices['WBTC'];
|
|
269
|
+
histPrices['HEMIBTC'] = histPrices['WBTC'];
|
|
270
|
+
histPrices['SUBTC'] = histPrices['WBTC'];
|
|
271
|
+
histPrices['IBTC'] = histPrices['WBTC'];
|
|
272
|
+
histPrices['ENZOBTC'] = histPrices['WBTC'];
|
|
273
|
+
histPrices['PUMPBTC'] = histPrices['WBTC'];
|
|
263
274
|
return histPrices;
|
|
264
275
|
}
|
|
265
276
|
catch (e) {
|
|
266
|
-
console.log(
|
|
277
|
+
console.log('error fetching prices from defillama', e);
|
|
267
278
|
return {};
|
|
268
279
|
}
|
|
269
280
|
}
|
package/dist/prices/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prices/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/prices/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAA;AAC3B,cAAc,eAAe,CAAA;AAC7B,cAAc,UAAU,CAAA"}
|
package/dist/prices/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from './defillama';
|
|
2
|
+
export * from './main-prices';
|
|
3
|
+
export * from './pendle';
|