@1delta/margin-fetcher 0.0.31 → 0.0.32
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/index.d.ts +0 -1
- package/dist/assets/index.d.ts.map +1 -1
- package/dist/assets/index.js +2 -7
- package/dist/lending/addresses/compoundV3.d.ts.map +1 -1
- package/dist/lending/addresses/compoundV3.js +2 -3
- package/dist/prices/defillama/index.d.ts.map +1 -1
- package/dist/prices/defillama/index.js +21 -0
- package/dist/prices/main-prices/addresses/aaveOracles.d.ts +4 -1
- package/dist/prices/main-prices/addresses/aaveOracles.d.ts.map +1 -1
- package/dist/prices/main-prices/addresses/aaveOracles.js +4 -1
- package/dist/prices/main-prices/fetchOracleData.js +2 -0
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +19 -14
- package/dist/yields/index.d.ts.map +1 -1
- package/dist/yields/index.js +4 -1
- package/package.json +2 -2
- package/src/assets/index.ts +1 -11
- package/src/lending/addresses/compoundV3.ts +1 -5
- package/src/prices/defillama/index.ts +24 -0
- package/src/prices/main-prices/addresses/aaveOracles.ts +4 -1
- package/src/prices/main-prices/fetchOracleData.ts +1 -0
- package/src/utils/index.ts +33 -21
- package/src/yields/index.ts +4 -1
- package/test/lenderData.test.ts +1 -1
- package/test/mainPrices.test.ts +14 -13
package/dist/assets/index.d.ts
CHANGED
|
@@ -6,7 +6,6 @@ export declare const getAaveAssets: (chainId: string | undefined, lendingProtoco
|
|
|
6
6
|
export declare const getInitAssets: (chainId: string | undefined, lendingProtocol?: Lender) => string[];
|
|
7
7
|
export declare const getCompoundV3Assets: (chainId: string | undefined, lendingProtocol?: Lender) => string[];
|
|
8
8
|
export declare const getCompoundV2Assets: (chainId: string | undefined, lendingProtocol?: Lender) => string[];
|
|
9
|
-
export declare const getSwaylendAssets: (chainId: string | undefined, lendingProtocol?: Lender) => string[];
|
|
10
9
|
export declare function getAaveTypePoolDataProviderAddress(chainId: string, lender: string): any;
|
|
11
10
|
export declare function getAaveTypePoolAddress(chainId: string, lender: string): string;
|
|
12
11
|
export declare function getAssetMeta(chainId: string, asset: string | undefined): any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/assets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/assets/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,MAAM,EACP,MAAM,wBAAwB,CAAC;AAGhC,gCAAgC;AAChC,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAC3B,GAAG,CACnD;AAED,eAAO,MAAM,aAAa,GACxB,SAAS,MAAM,GAAG,SAAS,EAC3B,kBAAiB,MAAuB,KACvC,MAAM,EAIR,CAAC;AAEF,eAAO,MAAM,aAAa,GACxB,SAAS,MAAM,GAAG,SAAS,EAC3B,wBAA6B,KAC5B,MAAM,EAIR,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,SAAS,MAAM,GAAG,SAAS,EAC3B,wBAA0C,KACzC,MAAM,EAMR,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAC9B,SAAS,MAAM,GAAG,SAAS,EAC3B,wBAA8B,KAC7B,MAAM,EAMR,CAAC;AAEF,wBAAgB,kCAAkC,CAChD,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,OAIf;AAED,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,GACb,MAAM,CAGR;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS,GACF,GAAG,CACvE;AAED;;;;GAIG;AACH,eAAO,MAAM,WAAW,GAAI,GAAG,MAAM,WAEpC,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,cAAc,MAAM,EAAE,SAAS,MAAM,WAEtE,CAAC"}
|
package/dist/assets/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { AAVE_FORK_POOL_DATA, AAVE_STYLE_RESERVE_ASSETS, AAVE_STYLE_TOKENS, ASSET_META, COMPOUND_STYLE_RESERVE_ASSETS, COMPOUND_V2_STYLE_RESERVE_ASSETS, INIT_STYLE_RESERVE_ASSETS, Lender,
|
|
2
|
-
import { isAaveType, isCompoundV3, isInit
|
|
1
|
+
import { AAVE_FORK_POOL_DATA, AAVE_STYLE_RESERVE_ASSETS, AAVE_STYLE_TOKENS, ASSET_META, COMPOUND_STYLE_RESERVE_ASSETS, COMPOUND_V2_STYLE_RESERVE_ASSETS, INIT_STYLE_RESERVE_ASSETS, Lender, } from "@1delta/asset-registry";
|
|
2
|
+
import { isAaveType, isCompoundV3, isInit } from "../utils";
|
|
3
3
|
/** No specific configuration */
|
|
4
4
|
export const LENDER_MODE_NO_MODE = 0;
|
|
5
5
|
export function getAaveStyleProtocolTokenMap(chainId, lender) {
|
|
@@ -25,11 +25,6 @@ export const getCompoundV2Assets = (chainId, lendingProtocol = Lender.VENUS) =>
|
|
|
25
25
|
return (COMPOUND_V2_STYLE_RESERVE_ASSETS[lendingProtocol]?.[chainId ?? "0"] ?? []);
|
|
26
26
|
return [];
|
|
27
27
|
};
|
|
28
|
-
export const getSwaylendAssets = (chainId, lendingProtocol = Lender.SWAYLEND_USDC) => {
|
|
29
|
-
if (isSwaylend(lendingProtocol))
|
|
30
|
-
return SWAYLEND_RESERVE_ASSETS[lendingProtocol]?.[chainId ?? "0"] ?? [];
|
|
31
|
-
return [];
|
|
32
|
-
};
|
|
33
28
|
export function getAaveTypePoolDataProviderAddress(chainId, lender) {
|
|
34
29
|
// @ts-ignore
|
|
35
30
|
return AAVE_FORK_POOL_DATA[lender]?.[chainId]?.protocolDataProvider;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compoundV3.d.ts","sourceRoot":"","sources":["../../../src/lending/addresses/compoundV3.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,MAAM,
|
|
1
|
+
{"version":3,"file":"compoundV3.d.ts","sourceRoot":"","sources":["../../../src/lending/addresses/compoundV3.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,MAAM,EACP,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;;;EAGhB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Chain, COMETS_PER_CHAIN_MAP, COMPOUND_BASE_TOKENS, Lender,
|
|
1
|
+
import { Chain, COMETS_PER_CHAIN_MAP, COMPOUND_BASE_TOKENS, Lender, } 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
|
}
|
|
@@ -33,6 +33,5 @@ const addressesCompoundV3 = {
|
|
|
33
33
|
},
|
|
34
34
|
};
|
|
35
35
|
export function getCompoundV3BaseAsset(lender, chainId) {
|
|
36
|
-
return
|
|
37
|
-
SWAYLEND_BASE_TOKENS[lender]?.[chainId]);
|
|
36
|
+
return COMPOUND_BASE_TOKENS[lender]?.[chainId];
|
|
38
37
|
}
|
|
@@ -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":"AAoRA,wBAAsB,kBAAkB,iBA4CvC;AAED,wBAAsB,sBAAsB,iBAgD3C"}
|
|
@@ -119,6 +119,12 @@ const kHYPE = '0xfd739d4e423301ce9385c1fb8850539d657c296d';
|
|
|
119
119
|
const prefixSolana = 'solana:';
|
|
120
120
|
const JITOSOL = 'J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn';
|
|
121
121
|
const SOL = 'So11111111111111111111111111111111111111112';
|
|
122
|
+
const prefixXdc = 'xdc:';
|
|
123
|
+
const WXDC = '0x951857744785e80e2de051c32ee7b25f9c458c42';
|
|
124
|
+
const prefixBera = 'berachain:';
|
|
125
|
+
const WBERA = '0x6969696969696969696969696969696969696969';
|
|
126
|
+
const prefixCronos = 'cronos:';
|
|
127
|
+
const WCRO = '0x5c7f8a570d578ed84e63fdfa7b1ee72deae1ae23';
|
|
122
128
|
// const prefixKaia = 'kaia:'
|
|
123
129
|
// const WKAIA = '0x19aac5f612f524b754ca7e7c41cbfa2e981a4432'
|
|
124
130
|
const datasAvalanche = [WAVAX, SAVAX].map((d) => prefixAvalanche + d).join(',');
|
|
@@ -136,6 +142,9 @@ const datasHyperEvm = [WYPE, WSTHYPE, kHYPE]
|
|
|
136
142
|
.map((d) => prefixHyperEVM + d)
|
|
137
143
|
.join(',');
|
|
138
144
|
const datasSolana = [JITOSOL, SOL].map((d) => prefixSolana + d).join(',');
|
|
145
|
+
const datasBera = [WBERA].map((d) => prefixBera + d).join(',');
|
|
146
|
+
const datasXdc = [WXDC].map((d) => prefixXdc + d).join(',');
|
|
147
|
+
const datasCrpnos = [WCRO].map((d) => prefixCronos + d).join(',');
|
|
139
148
|
// const datasKaia = [WKAIA].map((d) => prefixKaia + d).join(',')
|
|
140
149
|
const URL = `https://coins.llama.fi/prices/current/${[
|
|
141
150
|
datasEthereum,
|
|
@@ -151,6 +160,9 @@ const URL = `https://coins.llama.fi/prices/current/${[
|
|
|
151
160
|
datasSonic,
|
|
152
161
|
datasPolygon,
|
|
153
162
|
datasSolana,
|
|
163
|
+
datasBera,
|
|
164
|
+
datasXdc,
|
|
165
|
+
datasCrpnos,
|
|
154
166
|
].join(',')}?searchWidth=4h`;
|
|
155
167
|
const URL_HIST = (ref) => `https://coins.llama.fi/prices/historical/${ref}/${[
|
|
156
168
|
datasEthereum,
|
|
@@ -237,6 +249,9 @@ const SYMBOL_MAP = {
|
|
|
237
249
|
woeth: 'Wrapped OETH::WOETH',
|
|
238
250
|
jitosol: 'Jito Staked SOL::JitoSOL',
|
|
239
251
|
sol: 'SOL',
|
|
252
|
+
wcro: 'WCRO',
|
|
253
|
+
wxdc: 'WXDC',
|
|
254
|
+
wbera: 'WBERA',
|
|
240
255
|
};
|
|
241
256
|
export async function fetchDefillamaData() {
|
|
242
257
|
try {
|
|
@@ -253,6 +268,9 @@ export async function fetchDefillamaData() {
|
|
|
253
268
|
prices['WSOL'] = prices['SOL'];
|
|
254
269
|
prices['AVAX'] = prices['WAVAX'];
|
|
255
270
|
prices['METIS'] = prices['WMETIS'];
|
|
271
|
+
prices['CRO'] = prices['WCRO'];
|
|
272
|
+
prices['XDC'] = prices['WXDC'];
|
|
273
|
+
prices['BERA'] = prices['WBERA'];
|
|
256
274
|
// prices['WKAIA'] = prices['KAIA']
|
|
257
275
|
prices['USDBC'] = prices['USDC'];
|
|
258
276
|
prices['BTCB'] = prices['WBTC'];
|
|
@@ -290,6 +308,9 @@ export async function fetchDefillamaHistData() {
|
|
|
290
308
|
histPrices['AVAX'] = histPrices['WAVAX'];
|
|
291
309
|
histPrices['METIS'] = histPrices['WMETIS'];
|
|
292
310
|
histPrices['HYPE'] = histPrices['WHYPE'];
|
|
311
|
+
histPrices['BERA'] = histPrices['WBERA'];
|
|
312
|
+
histPrices['CRO'] = histPrices['WCRO'];
|
|
313
|
+
histPrices['XDC'] = histPrices['WXDC'];
|
|
293
314
|
// histPrices['WKAIA'] = histPrices['KAIA']
|
|
294
315
|
histPrices['LUSD'] = histPrices['USDT'];
|
|
295
316
|
histPrices['XDAI'] = histPrices['DAI'];
|
|
@@ -175,7 +175,7 @@ export declare const AAVE_STYLE_ORACLES: {
|
|
|
175
175
|
AVALON_STBTC: {
|
|
176
176
|
'56': string;
|
|
177
177
|
};
|
|
178
|
-
|
|
178
|
+
AVALON_UNIIOTX: {
|
|
179
179
|
'4689': string;
|
|
180
180
|
};
|
|
181
181
|
AVALON_BOB: {
|
|
@@ -296,5 +296,8 @@ export declare const AAVE_STYLE_ORACLES: {
|
|
|
296
296
|
PHIAT: {
|
|
297
297
|
'369': string;
|
|
298
298
|
};
|
|
299
|
+
FATHOM: {
|
|
300
|
+
'50': string;
|
|
301
|
+
};
|
|
299
302
|
};
|
|
300
303
|
//# sourceMappingURL=aaveOracles.d.ts.map
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6S9B,CAAA"}
|
|
@@ -175,7 +175,7 @@ export const AAVE_STYLE_ORACLES = {
|
|
|
175
175
|
AVALON_STBTC: {
|
|
176
176
|
'56': '0xE8510211ed910A0fa1FeaD133353A306798BC0c8',
|
|
177
177
|
},
|
|
178
|
-
|
|
178
|
+
AVALON_UNIIOTX: {
|
|
179
179
|
'4689': '0x406010dA9450f62339FBF9e0aBBB2cEF6e426918',
|
|
180
180
|
},
|
|
181
181
|
AVALON_BOB: {
|
|
@@ -296,4 +296,7 @@ export const AAVE_STYLE_ORACLES = {
|
|
|
296
296
|
PHIAT: {
|
|
297
297
|
'369': '0x7f9d7476e6A2561fA011aA788979234De80900F7',
|
|
298
298
|
},
|
|
299
|
+
FATHOM: {
|
|
300
|
+
'50': '0x54348d953Abc4f167cbdeDe648095c1aF7DE355A',
|
|
301
|
+
},
|
|
299
302
|
};
|
|
@@ -281,6 +281,8 @@ function lowDecimalOracle(chainId, fork) {
|
|
|
281
281
|
if (chainId === Chain.AVALANCHE_C_CHAIN || chainId === Chain.MODE) {
|
|
282
282
|
return false;
|
|
283
283
|
}
|
|
284
|
+
if (chainId === Chain.XDC_NETWORK)
|
|
285
|
+
return true;
|
|
284
286
|
// otherwise, it depends on whether it is aave V3
|
|
285
287
|
return AAVE_V2_LENDERS.includes(fork);
|
|
286
288
|
}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Lender } from
|
|
1
|
+
import { Lender } from '@1delta/asset-registry';
|
|
2
2
|
export declare function isCompoundV3(lender: string): boolean;
|
|
3
3
|
export declare function isCompoundV3Type(lender: string): boolean;
|
|
4
4
|
export declare function isInit(lender: string): lender is Lender.INIT;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAQL,MAAM,EAIP,MAAM,wBAAwB,CAAA;AAO/B,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;AAID,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,wBAAgB,UAAU,CAAC,MAAM,EAAE,MAAM,WAExC;AAED,eAAO,MAAM,kBAAkB,GAAI,GAAG,MAAM,aA2B3C,CAAA;AAED,sCAAsC;AACtC,eAAO,MAAM,uBAAuB,GAClC,YAAY,MAAM,EAAE,EACpB,eAAe,MAAM,EAAE,KACtB,MAAM,EAaR,CAAA;AAaD,mCAAmC;AACnC,eAAO,MAAM,eAAe;;CAAqB,CAAA;AAEjD,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,EASR,CAAA;AAED,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,WAE3C"}
|
package/dist/utils/index.js
CHANGED
|
@@ -1,15 +1,21 @@
|
|
|
1
|
-
import { AAVE_FORK_POOL_DATA, AAVE_STYLE_RESERVE_ASSETS, AAVE_V2_LENDERS, AAVE_V3_LENDERS, COMPOUND_BASE_TOKENS, COMPOUND_STYLE_RESERVE_ASSETS, INIT_STYLE_RESERVE_ASSETS, Lender,
|
|
2
|
-
import { uniq } from
|
|
3
|
-
import { COMPOSERS } from
|
|
4
|
-
import { zeroAddress } from
|
|
5
|
-
const COMPOUND_V3_KEY =
|
|
6
|
-
export function isCompoundV3(lender) {
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { AAVE_FORK_POOL_DATA, AAVE_STYLE_RESERVE_ASSETS, AAVE_V2_LENDERS, AAVE_V3_LENDERS, COMPOUND_BASE_TOKENS, COMPOUND_STYLE_RESERVE_ASSETS, INIT_STYLE_RESERVE_ASSETS, Lender, INIT_CONFIG_DATA, MORPHO_BLUE_POOL_DATA, AAVE_V32_LENDERS, } from '@1delta/asset-registry';
|
|
2
|
+
import { uniq } from 'lodash';
|
|
3
|
+
import { COMPOSERS } from './constants';
|
|
4
|
+
import { zeroAddress } from 'viem';
|
|
5
|
+
const COMPOUND_V3_KEY = 'COMPOUND_V3';
|
|
6
|
+
export function isCompoundV3(lender) {
|
|
7
|
+
return lender?.startsWith(COMPOUND_V3_KEY);
|
|
8
|
+
}
|
|
9
|
+
export function isCompoundV3Type(lender) {
|
|
10
|
+
return lender?.startsWith(COMPOUND_V3_KEY);
|
|
11
|
+
}
|
|
12
|
+
export function isInit(lender) {
|
|
13
|
+
return lender === Lender.INIT;
|
|
14
|
+
}
|
|
9
15
|
export function isMorphoType(lender) {
|
|
10
|
-
return lender?.startsWith(
|
|
16
|
+
return lender?.startsWith('MORPHO_BLUE');
|
|
11
17
|
}
|
|
12
|
-
const SWAYLEND_KEY =
|
|
18
|
+
const SWAYLEND_KEY = 'SWAYLEND';
|
|
13
19
|
export function isAaveV3Type(lender) {
|
|
14
20
|
return AAVE_V3_LENDERS.includes(lender);
|
|
15
21
|
}
|
|
@@ -64,7 +70,8 @@ export const filterLendersByProtocol = (allLenders, protocolList) => {
|
|
|
64
70
|
}
|
|
65
71
|
const hasMorpho = protocolList.includes(Lender.MORPHO_BLUE);
|
|
66
72
|
// Filter lenders based on protocol list
|
|
67
|
-
return allLenders.filter((lender) => protocolList.includes(lender) ||
|
|
73
|
+
return allLenders.filter((lender) => protocolList.includes(lender) ||
|
|
74
|
+
(hasMorpho && lender?.startsWith('MORPHO_BLUE')));
|
|
68
75
|
};
|
|
69
76
|
const getAavesForChain = () => {
|
|
70
77
|
let lenders = {};
|
|
@@ -91,10 +98,8 @@ export const getLenderAssets = (chainId, lendingProtocol = Lender.AAVE_V3) => {
|
|
|
91
98
|
return COMPOUND_STYLE_RESERVE_ASSETS[lendingProtocol]?.[chainId] ?? [];
|
|
92
99
|
if (isInit(lendingProtocol))
|
|
93
100
|
return INIT_STYLE_RESERVE_ASSETS[lendingProtocol]?.[chainId] ?? [];
|
|
94
|
-
if (isSwaylend(lendingProtocol))
|
|
95
|
-
return SWAYLEND_RESERVE_ASSETS[lendingProtocol]?.[chainId ?? 0] ?? [];
|
|
96
101
|
return [];
|
|
97
102
|
};
|
|
98
103
|
export function isMultiMarket(lender) {
|
|
99
|
-
return lender?.startsWith(
|
|
104
|
+
return lender?.startsWith('MORPHO_BLUE');
|
|
100
105
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/yields/index.ts"],"names":[],"mappings":"AAkGA,UAAU,iBAAiB;IACzB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,qBAAqB,EAAE,GAAG,CAAA;IAC1B,oBAAoB,EAAE,GAAG,CAAA;CAC1B;AAED,MAAM,WAAW,sBAAsB;IACrC,eAAe,EAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;KAAE,CAAA;IACxD,aAAa,EAAE;QACb,CAAC,OAAO,EAAE,MAAM,GAAG;YACjB,CAAC,MAAM,EAAE,MAAM,GAAG;gBAAE,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB,CAAA;aAAE,CAAA;SACzD,CAAA;KACF,CAAA;CACF;AAcD,eAAO,MAAM,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/yields/index.ts"],"names":[],"mappings":"AAkGA,UAAU,iBAAiB;IACzB,OAAO,EAAE,MAAM,CAAA;IACf,MAAM,EAAE,MAAM,CAAA;IACd,qBAAqB,EAAE,GAAG,CAAA;IAC1B,oBAAoB,EAAE,GAAG,CAAA;CAC1B;AAED,MAAM,WAAW,sBAAsB;IACrC,eAAe,EAAE;QAAE,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAA;KAAE,CAAA;IACxD,aAAa,EAAE;QACb,CAAC,OAAO,EAAE,MAAM,GAAG;YACjB,CAAC,MAAM,EAAE,MAAM,GAAG;gBAAE,CAAC,KAAK,EAAE,MAAM,GAAG,iBAAiB,CAAA;aAAE,CAAA;SACzD,CAAA;KACF,CAAA;CACF;AAcD,eAAO,MAAM,kBAAkB,uCA+b9B,CAAA"}
|
package/dist/yields/index.js
CHANGED
|
@@ -183,7 +183,10 @@ export const fetchGeneralYields = async () => {
|
|
|
183
183
|
Object.entries(res).forEach(([addr, data]) => {
|
|
184
184
|
const key = addressToAssetYearn[addr.toLowerCase()];
|
|
185
185
|
if (key) {
|
|
186
|
-
const apr = ((data.apr.netAPR ?? 0) +
|
|
186
|
+
const apr = ((data.apr.netAPR ?? 0) +
|
|
187
|
+
(data.apr.extra.extrinsicYield ?? 0) +
|
|
188
|
+
(data.apr.extra.katanaNativeYield ?? 0)) *
|
|
189
|
+
100;
|
|
187
190
|
map[key] = apr;
|
|
188
191
|
}
|
|
189
192
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@1delta/margin-fetcher",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.32",
|
|
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.11"
|
|
21
21
|
},
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "tsc",
|
package/src/assets/index.ts
CHANGED
|
@@ -7,9 +7,8 @@ import {
|
|
|
7
7
|
COMPOUND_V2_STYLE_RESERVE_ASSETS,
|
|
8
8
|
INIT_STYLE_RESERVE_ASSETS,
|
|
9
9
|
Lender,
|
|
10
|
-
SWAYLEND_RESERVE_ASSETS,
|
|
11
10
|
} from "@1delta/asset-registry";
|
|
12
|
-
import { isAaveType, isCompoundV3, isInit
|
|
11
|
+
import { isAaveType, isCompoundV3, isInit } from "../utils";
|
|
13
12
|
|
|
14
13
|
/** No specific configuration */
|
|
15
14
|
export const LENDER_MODE_NO_MODE = 0;
|
|
@@ -58,15 +57,6 @@ export const getCompoundV2Assets = (
|
|
|
58
57
|
return [];
|
|
59
58
|
};
|
|
60
59
|
|
|
61
|
-
export const getSwaylendAssets = (
|
|
62
|
-
chainId: string | undefined,
|
|
63
|
-
lendingProtocol = Lender.SWAYLEND_USDC
|
|
64
|
-
): string[] => {
|
|
65
|
-
if (isSwaylend(lendingProtocol))
|
|
66
|
-
return SWAYLEND_RESERVE_ASSETS[lendingProtocol]?.[chainId ?? "0"] ?? [];
|
|
67
|
-
return [];
|
|
68
|
-
};
|
|
69
|
-
|
|
70
60
|
export function getAaveTypePoolDataProviderAddress(
|
|
71
61
|
chainId: string,
|
|
72
62
|
lender: string
|
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
COMETS_PER_CHAIN_MAP,
|
|
4
4
|
COMPOUND_BASE_TOKENS,
|
|
5
5
|
Lender,
|
|
6
|
-
SWAYLEND_BASE_TOKENS,
|
|
7
6
|
} from '@1delta/asset-registry'
|
|
8
7
|
|
|
9
8
|
export function getCompoundV3CometAddress(
|
|
@@ -50,8 +49,5 @@ export function getCompoundV3BaseAsset(
|
|
|
50
49
|
lender: Lender | string,
|
|
51
50
|
chainId: string,
|
|
52
51
|
) {
|
|
53
|
-
return
|
|
54
|
-
COMPOUND_BASE_TOKENS[lender]?.[chainId] ??
|
|
55
|
-
SWAYLEND_BASE_TOKENS[lender]?.[chainId]
|
|
56
|
-
)
|
|
52
|
+
return COMPOUND_BASE_TOKENS[lender]?.[chainId]
|
|
57
53
|
}
|
|
@@ -132,6 +132,15 @@ const prefixSolana = 'solana:'
|
|
|
132
132
|
const JITOSOL = 'J1toso1uCk3RLmjorhTtrVwY9HJ7X8V9yYac6Y7kGCPn'
|
|
133
133
|
const SOL = 'So11111111111111111111111111111111111111112'
|
|
134
134
|
|
|
135
|
+
const prefixXdc = 'xdc:'
|
|
136
|
+
const WXDC = '0x951857744785e80e2de051c32ee7b25f9c458c42'
|
|
137
|
+
|
|
138
|
+
const prefixBera = 'berachain:'
|
|
139
|
+
const WBERA = '0x6969696969696969696969696969696969696969'
|
|
140
|
+
|
|
141
|
+
const prefixCronos = 'cronos:'
|
|
142
|
+
const WCRO = '0x5c7f8a570d578ed84e63fdfa7b1ee72deae1ae23'
|
|
143
|
+
|
|
135
144
|
// const prefixKaia = 'kaia:'
|
|
136
145
|
// const WKAIA = '0x19aac5f612f524b754ca7e7c41cbfa2e981a4432'
|
|
137
146
|
|
|
@@ -150,6 +159,9 @@ const datasHyperEvm = [WYPE, WSTHYPE, kHYPE]
|
|
|
150
159
|
.map((d) => prefixHyperEVM + d)
|
|
151
160
|
.join(',')
|
|
152
161
|
const datasSolana = [JITOSOL, SOL].map((d) => prefixSolana + d).join(',')
|
|
162
|
+
const datasBera = [WBERA].map((d) => prefixBera + d).join(',')
|
|
163
|
+
const datasXdc = [WXDC].map((d) => prefixXdc + d).join(',')
|
|
164
|
+
const datasCrpnos = [WCRO].map((d) => prefixCronos + d).join(',')
|
|
153
165
|
// const datasKaia = [WKAIA].map((d) => prefixKaia + d).join(',')
|
|
154
166
|
|
|
155
167
|
const URL = `https://coins.llama.fi/prices/current/${[
|
|
@@ -166,6 +178,9 @@ const URL = `https://coins.llama.fi/prices/current/${[
|
|
|
166
178
|
datasSonic,
|
|
167
179
|
datasPolygon,
|
|
168
180
|
datasSolana,
|
|
181
|
+
datasBera,
|
|
182
|
+
datasXdc,
|
|
183
|
+
datasCrpnos,
|
|
169
184
|
].join(',')}?searchWidth=4h`
|
|
170
185
|
const URL_HIST = (ref: number) =>
|
|
171
186
|
`https://coins.llama.fi/prices/historical/${ref}/${[
|
|
@@ -254,6 +269,9 @@ const SYMBOL_MAP = {
|
|
|
254
269
|
woeth: 'Wrapped OETH::WOETH',
|
|
255
270
|
jitosol: 'Jito Staked SOL::JitoSOL',
|
|
256
271
|
sol: 'SOL',
|
|
272
|
+
wcro: 'WCRO',
|
|
273
|
+
wxdc: 'WXDC',
|
|
274
|
+
wbera: 'WBERA',
|
|
257
275
|
}
|
|
258
276
|
|
|
259
277
|
export async function fetchDefillamaData() {
|
|
@@ -276,6 +294,9 @@ export async function fetchDefillamaData() {
|
|
|
276
294
|
prices['WSOL'] = prices['SOL']
|
|
277
295
|
prices['AVAX'] = prices['WAVAX']
|
|
278
296
|
prices['METIS'] = prices['WMETIS']
|
|
297
|
+
prices['CRO'] = prices['WCRO']
|
|
298
|
+
prices['XDC'] = prices['WXDC']
|
|
299
|
+
prices['BERA'] = prices['WBERA']
|
|
279
300
|
// prices['WKAIA'] = prices['KAIA']
|
|
280
301
|
|
|
281
302
|
prices['USDBC'] = prices['USDC']
|
|
@@ -321,6 +342,9 @@ export async function fetchDefillamaHistData() {
|
|
|
321
342
|
histPrices['AVAX'] = histPrices['WAVAX']
|
|
322
343
|
histPrices['METIS'] = histPrices['WMETIS']
|
|
323
344
|
histPrices['HYPE'] = histPrices['WHYPE']
|
|
345
|
+
histPrices['BERA'] = histPrices['WBERA']
|
|
346
|
+
histPrices['CRO'] = histPrices['WCRO']
|
|
347
|
+
histPrices['XDC'] = histPrices['WXDC']
|
|
324
348
|
// histPrices['WKAIA'] = histPrices['KAIA']
|
|
325
349
|
|
|
326
350
|
histPrices['LUSD'] = histPrices['USDT']
|
|
@@ -175,7 +175,7 @@ export const AAVE_STYLE_ORACLES = {
|
|
|
175
175
|
AVALON_STBTC: {
|
|
176
176
|
'56': '0xE8510211ed910A0fa1FeaD133353A306798BC0c8',
|
|
177
177
|
},
|
|
178
|
-
|
|
178
|
+
AVALON_UNIIOTX: {
|
|
179
179
|
'4689': '0x406010dA9450f62339FBF9e0aBBB2cEF6e426918',
|
|
180
180
|
},
|
|
181
181
|
AVALON_BOB: {
|
|
@@ -296,4 +296,7 @@ export const AAVE_STYLE_ORACLES = {
|
|
|
296
296
|
PHIAT: {
|
|
297
297
|
'369': '0x7f9d7476e6A2561fA011aA788979234De80900F7',
|
|
298
298
|
},
|
|
299
|
+
FATHOM: {
|
|
300
|
+
'50': '0x54348d953Abc4f167cbdeDe648095c1aF7DE355A',
|
|
301
|
+
},
|
|
299
302
|
}
|
|
@@ -384,6 +384,7 @@ function lowDecimalOracle(chainId: string, fork: string) {
|
|
|
384
384
|
if (chainId === Chain.AVALANCHE_C_CHAIN || chainId === Chain.MODE) {
|
|
385
385
|
return false
|
|
386
386
|
}
|
|
387
|
+
if (chainId === Chain.XDC_NETWORK) return true
|
|
387
388
|
// otherwise, it depends on whether it is aave V3
|
|
388
389
|
return AAVE_V2_LENDERS.includes(fork as any)
|
|
389
390
|
}
|
package/src/utils/index.ts
CHANGED
|
@@ -7,28 +7,33 @@ import {
|
|
|
7
7
|
COMPOUND_STYLE_RESERVE_ASSETS,
|
|
8
8
|
INIT_STYLE_RESERVE_ASSETS,
|
|
9
9
|
Lender,
|
|
10
|
-
SWAYLEND_RESERVE_ASSETS,
|
|
11
10
|
INIT_CONFIG_DATA,
|
|
12
11
|
MORPHO_BLUE_POOL_DATA,
|
|
13
12
|
AAVE_V32_LENDERS,
|
|
14
|
-
} from
|
|
15
|
-
import { uniq } from
|
|
16
|
-
import { COMPOSERS } from
|
|
17
|
-
import { zeroAddress } from
|
|
13
|
+
} from '@1delta/asset-registry'
|
|
14
|
+
import { uniq } from 'lodash'
|
|
15
|
+
import { COMPOSERS } from './constants'
|
|
16
|
+
import { zeroAddress } from 'viem'
|
|
18
17
|
|
|
19
|
-
const COMPOUND_V3_KEY =
|
|
18
|
+
const COMPOUND_V3_KEY = 'COMPOUND_V3'
|
|
20
19
|
|
|
21
|
-
export function isCompoundV3(lender: string) {
|
|
20
|
+
export function isCompoundV3(lender: string) {
|
|
21
|
+
return lender?.startsWith(COMPOUND_V3_KEY)
|
|
22
|
+
}
|
|
22
23
|
|
|
23
|
-
export function isCompoundV3Type(lender: string) {
|
|
24
|
+
export function isCompoundV3Type(lender: string) {
|
|
25
|
+
return lender?.startsWith(COMPOUND_V3_KEY)
|
|
26
|
+
}
|
|
24
27
|
|
|
25
|
-
export function isInit(lender: string) {
|
|
28
|
+
export function isInit(lender: string) {
|
|
29
|
+
return lender === Lender.INIT
|
|
30
|
+
}
|
|
26
31
|
|
|
27
32
|
export function isMorphoType(lender: string) {
|
|
28
|
-
return lender?.startsWith(
|
|
33
|
+
return lender?.startsWith('MORPHO_BLUE')
|
|
29
34
|
}
|
|
30
35
|
|
|
31
|
-
const SWAYLEND_KEY =
|
|
36
|
+
const SWAYLEND_KEY = 'SWAYLEND'
|
|
32
37
|
|
|
33
38
|
export function isAaveV3Type(lender: string) {
|
|
34
39
|
return AAVE_V3_LENDERS.includes(lender as any)
|
|
@@ -80,12 +85,14 @@ export const getLendersForChain = (c: string) => {
|
|
|
80
85
|
if (chains.includes(c)) lenders.push(l)
|
|
81
86
|
})
|
|
82
87
|
|
|
83
|
-
|
|
84
88
|
return lenders
|
|
85
89
|
}
|
|
86
90
|
|
|
87
91
|
/** Filter lenders by protocol list */
|
|
88
|
-
export const filterLendersByProtocol = (
|
|
92
|
+
export const filterLendersByProtocol = (
|
|
93
|
+
allLenders: string[],
|
|
94
|
+
protocolList?: string[],
|
|
95
|
+
): string[] => {
|
|
89
96
|
// return all lenders if no filter is provided
|
|
90
97
|
if (!protocolList || protocolList.length === 0) {
|
|
91
98
|
return allLenders
|
|
@@ -93,7 +100,11 @@ export const filterLendersByProtocol = (allLenders: string[], protocolList?: str
|
|
|
93
100
|
|
|
94
101
|
const hasMorpho = protocolList.includes(Lender.MORPHO_BLUE)
|
|
95
102
|
// Filter lenders based on protocol list
|
|
96
|
-
return allLenders.filter(
|
|
103
|
+
return allLenders.filter(
|
|
104
|
+
(lender) =>
|
|
105
|
+
protocolList.includes(lender) ||
|
|
106
|
+
(hasMorpho && lender?.startsWith('MORPHO_BLUE')),
|
|
107
|
+
)
|
|
97
108
|
}
|
|
98
109
|
|
|
99
110
|
const getAavesForChain = () => {
|
|
@@ -116,17 +127,18 @@ export const getComposerAddress = (chainId: string): string => {
|
|
|
116
127
|
|
|
117
128
|
export const getLenderAssets = (
|
|
118
129
|
chainId: string | number | undefined,
|
|
119
|
-
lendingProtocol = Lender.AAVE_V3
|
|
130
|
+
lendingProtocol = Lender.AAVE_V3,
|
|
120
131
|
): string[] => {
|
|
121
132
|
if (!chainId) return []
|
|
122
|
-
if (isAaveType(lendingProtocol))
|
|
123
|
-
|
|
124
|
-
if (
|
|
125
|
-
|
|
133
|
+
if (isAaveType(lendingProtocol))
|
|
134
|
+
return AAVE_STYLE_RESERVE_ASSETS[lendingProtocol]?.[chainId] ?? []
|
|
135
|
+
if (isCompoundV3(lendingProtocol))
|
|
136
|
+
return COMPOUND_STYLE_RESERVE_ASSETS[lendingProtocol]?.[chainId] ?? []
|
|
137
|
+
if (isInit(lendingProtocol))
|
|
138
|
+
return INIT_STYLE_RESERVE_ASSETS[lendingProtocol]?.[chainId] ?? []
|
|
126
139
|
return []
|
|
127
140
|
}
|
|
128
141
|
|
|
129
|
-
|
|
130
142
|
export function isMultiMarket(lender: string) {
|
|
131
|
-
return lender?.startsWith(
|
|
143
|
+
return lender?.startsWith('MORPHO_BLUE')
|
|
132
144
|
}
|
package/src/yields/index.ts
CHANGED
|
@@ -230,7 +230,10 @@ export const fetchGeneralYields = async () => {
|
|
|
230
230
|
const key = addressToAssetYearn[addr.toLowerCase()]
|
|
231
231
|
if (key) {
|
|
232
232
|
const apr =
|
|
233
|
-
((data.apr.netAPR ?? 0) +
|
|
233
|
+
((data.apr.netAPR ?? 0) +
|
|
234
|
+
(data.apr.extra.extrinsicYield ?? 0) +
|
|
235
|
+
(data.apr.extra.katanaNativeYield ?? 0)) *
|
|
236
|
+
100
|
|
234
237
|
map[key] = apr
|
|
235
238
|
}
|
|
236
239
|
})
|
package/test/lenderData.test.ts
CHANGED
package/test/mainPrices.test.ts
CHANGED
|
@@ -7,19 +7,20 @@ describe(
|
|
|
7
7
|
'find prices',
|
|
8
8
|
() => {
|
|
9
9
|
it('should return prices for valid tokens', async () => {
|
|
10
|
-
const mainPrices = await fetchMainPrices(
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
const mainPrices = await fetchMainPrices([
|
|
11
|
+
// Chain.MANTLE,
|
|
12
|
+
// Chain.BNB_SMART_CHAIN_MAINNET,
|
|
13
|
+
// Chain.OP_MAINNET,
|
|
14
|
+
// Chain.POLYGON_MAINNET,
|
|
15
|
+
// Chain.HEMI_NETWORK,
|
|
16
|
+
// Chain.ARBITRUM_ONE,
|
|
17
|
+
// Chain.HYPEREVM,
|
|
18
|
+
// Chain.ETHEREUM_MAINNET,
|
|
19
|
+
Chain.BERACHAIN,
|
|
20
|
+
Chain.XDC_NETWORK,
|
|
21
|
+
Chain.CRONOS_MAINNET,
|
|
22
|
+
])
|
|
23
|
+
console.log(mainPrices['SOL'])
|
|
23
24
|
prettyPrint(mainPrices)
|
|
24
25
|
})
|
|
25
26
|
},
|