@1delta/margin-fetcher 0.0.18 → 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/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/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/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
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
import fetch from "axios"
|
|
1
|
+
import fetch from 'axios'
|
|
3
2
|
|
|
4
3
|
const prefixEthereum = 'ethereum:'
|
|
5
4
|
const RETH = '0xae78736Cd615f374D3085123A210448E74Fc6393'
|
|
@@ -34,115 +33,121 @@ const FRAX = '0x853d955acef822db058eb8505911ed77f175b99e'
|
|
|
34
33
|
const WEETH = '0xcd5fe23c85820f7b72d0926fc9b05b43e359b7ee'
|
|
35
34
|
const ARB = '0xb50721bcf8d664c30412cfbc6cf7a15145234ad1'
|
|
36
35
|
const WUSDM = '0x57f5e098cad7a3d1eed53991d4d66c45c9af7812'
|
|
37
|
-
const RSETH =
|
|
38
|
-
const CBETH =
|
|
39
|
-
const SNX =
|
|
40
|
-
const VUSD =
|
|
41
|
-
const EZETH =
|
|
42
|
-
const LBTC =
|
|
43
|
-
const BRBTC =
|
|
44
|
-
const SDAI =
|
|
36
|
+
const RSETH = '0xa1290d69c65a6fe4df752f95823fae25cb99e5a7'
|
|
37
|
+
const CBETH = '0xbe9895146f7af43049ca1c1ae358b0541ea49704'
|
|
38
|
+
const SNX = '0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f'
|
|
39
|
+
const VUSD = '0x677ddbd918637e5f2c79e164d402454de7da8619'
|
|
40
|
+
const EZETH = '0xbf5495Efe5DB9ce00f80364C8B423567e58d2110'
|
|
41
|
+
const LBTC = '0x8236a87084f8B84306f72007F36F2618A5634494'
|
|
42
|
+
const BRBTC = '0x2eC37d45FCAE65D9787ECf71dc85a444968f6646'
|
|
43
|
+
const SDAI = '0x83f20f44975d03b1b09e64809b757c47f942beea'
|
|
45
44
|
const datasEthereum = [
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
]
|
|
45
|
+
RETH,
|
|
46
|
+
WBTC,
|
|
47
|
+
WETH,
|
|
48
|
+
MNT,
|
|
49
|
+
USDC,
|
|
50
|
+
USDT,
|
|
51
|
+
USDE,
|
|
52
|
+
METH,
|
|
53
|
+
USDY,
|
|
54
|
+
CRV,
|
|
55
|
+
BAL,
|
|
56
|
+
AGEUR,
|
|
57
|
+
LINK,
|
|
58
|
+
DAI,
|
|
59
|
+
BNB,
|
|
60
|
+
MATIC,
|
|
61
|
+
STMATIC,
|
|
62
|
+
MATICX,
|
|
63
|
+
AAVE,
|
|
64
|
+
COMP,
|
|
65
|
+
EURS,
|
|
66
|
+
FBTC,
|
|
67
|
+
TAIKO,
|
|
68
|
+
CMETH,
|
|
69
|
+
AUSD,
|
|
70
|
+
SUSDE,
|
|
71
|
+
FUEL,
|
|
72
|
+
GHO,
|
|
73
|
+
FRAX,
|
|
74
|
+
WEETH,
|
|
75
|
+
ARB,
|
|
76
|
+
WUSDM,
|
|
77
|
+
RSETH,
|
|
78
|
+
CBETH,
|
|
79
|
+
SNX,
|
|
80
|
+
EZETH,
|
|
81
|
+
VUSD,
|
|
82
|
+
LBTC,
|
|
83
|
+
BRBTC,
|
|
84
|
+
SDAI,
|
|
85
|
+
]
|
|
86
|
+
.map((d) => prefixEthereum + d)
|
|
87
|
+
.join(',')
|
|
87
88
|
|
|
88
89
|
const prefixAvalanche = 'avax:'
|
|
89
90
|
const WAVAX = '0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7'
|
|
90
|
-
const SAVAX =
|
|
91
|
+
const SAVAX = '0x2b2C81e08f1Af8835a78Bb2A90AE924ACE0eA4bE'
|
|
91
92
|
|
|
92
|
-
const prefixArbitrum =
|
|
93
|
-
const GMX =
|
|
93
|
+
const prefixArbitrum = 'arbitrum:'
|
|
94
|
+
const GMX = '0xfc5a1a6eb076a2c7ad06ed22c90d7e710e35ad0a'
|
|
94
95
|
|
|
95
|
-
const prefixOptimism =
|
|
96
|
-
const OP =
|
|
97
|
-
const SUSD =
|
|
98
|
-
const WRSETH =
|
|
96
|
+
const prefixOptimism = 'optimism:'
|
|
97
|
+
const OP = '0x4200000000000000000000000000000000000042'
|
|
98
|
+
const SUSD = '0x8c6f28f2F1A3C87F0f938b96d27520d9751ec8d9'
|
|
99
|
+
const WRSETH = '0x87eee96d50fb761ad85b1c982d28a042169d61b1'
|
|
99
100
|
|
|
100
|
-
const prefixBase =
|
|
101
|
-
const AERO =
|
|
101
|
+
const prefixBase = 'base:'
|
|
102
|
+
const AERO = '0x940181a94A35A4569E4529A3CDfB74e38FD98631'
|
|
102
103
|
|
|
103
|
-
const prefixCore =
|
|
104
|
-
const WCORE =
|
|
104
|
+
const prefixCore = 'core:'
|
|
105
|
+
const WCORE = '0xb0788b601c0d712702bc829b52771199ad8e33ff'
|
|
105
106
|
|
|
106
|
-
const prefixMetis =
|
|
107
|
-
const WMETIS =
|
|
107
|
+
const prefixMetis = 'metis:'
|
|
108
|
+
const WMETIS = '0x75cb093e4d61d2a2e65d8e0bbb01de8d89b53481'
|
|
108
109
|
|
|
109
|
-
const prefixSonic =
|
|
110
|
-
const WS =
|
|
110
|
+
const prefixSonic = 'sonic:'
|
|
111
|
+
const WS = '0x039e2fb66102314ce7b64ce5ce3e5183bc94ad38'
|
|
111
112
|
|
|
112
|
-
const prefixFantom =
|
|
113
|
-
const WFTM =
|
|
113
|
+
const prefixFantom = 'fantom:'
|
|
114
|
+
const WFTM = '0x21be370d5312f44cb42ce377bc9b8a0cef1a4c83'
|
|
114
115
|
|
|
115
|
-
const
|
|
116
|
-
const WKAIA = "0x19aac5f612f524b754ca7e7c41cbfa2e981a4432"
|
|
116
|
+
const prefixHyperEVM = 'hyperliquid:'
|
|
117
117
|
|
|
118
|
+
const WYPE = '0x5555555555555555555555555555555555555555'
|
|
118
119
|
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
SAVAX
|
|
122
|
-
].map(d => prefixAvalanche + d).join(',')
|
|
123
|
-
const datasArbitrum = [GMX].map(d => prefixArbitrum + d).join(',')
|
|
124
|
-
const datasOptimism = [OP, SUSD, WRSETH].map(d => prefixOptimism + d).join(',')
|
|
125
|
-
const datasBase = [AERO].map(d => prefixBase + d).join(',')
|
|
126
|
-
const datasCore = [WCORE].map(d => prefixCore + d).join(',')
|
|
127
|
-
const datasMetis = [WMETIS].map(d => prefixMetis + d).join(',')
|
|
128
|
-
const datasFantom = [WFTM].map(d => prefixFantom + d).join(',')
|
|
129
|
-
const datasSonic = [WS].map(d => prefixSonic + d).join(',')
|
|
130
|
-
const datasKaia = [WKAIA].map(d => prefixKaia + d).join(',')
|
|
120
|
+
// const prefixKaia = 'kaia:'
|
|
121
|
+
// const WKAIA = '0x19aac5f612f524b754ca7e7c41cbfa2e981a4432'
|
|
131
122
|
|
|
123
|
+
const datasAvalanche = [WAVAX, SAVAX].map((d) => prefixAvalanche + d).join(',')
|
|
124
|
+
const datasArbitrum = [GMX].map((d) => prefixArbitrum + d).join(',')
|
|
125
|
+
const datasOptimism = [OP, SUSD, WRSETH]
|
|
126
|
+
.map((d) => prefixOptimism + d)
|
|
127
|
+
.join(',')
|
|
128
|
+
const datasBase = [AERO].map((d) => prefixBase + d).join(',')
|
|
129
|
+
const datasCore = [WCORE].map((d) => prefixCore + d).join(',')
|
|
130
|
+
const datasMetis = [WMETIS].map((d) => prefixMetis + d).join(',')
|
|
131
|
+
const datasFantom = [WFTM].map((d) => prefixFantom + d).join(',')
|
|
132
|
+
const datasSonic = [WS].map((d) => prefixSonic + d).join(',')
|
|
133
|
+
const datasHyperEvm = [WYPE].map((d) => prefixHyperEVM + d).join(',')
|
|
134
|
+
// const datasKaia = [WKAIA].map((d) => prefixKaia + d).join(',')
|
|
132
135
|
|
|
133
136
|
const URL = `https://coins.llama.fi/prices/current/${[
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
137
|
+
datasEthereum,
|
|
138
|
+
datasAvalanche,
|
|
139
|
+
datasArbitrum,
|
|
140
|
+
datasOptimism,
|
|
141
|
+
datasBase,
|
|
142
|
+
datasCore,
|
|
143
|
+
datasMetis,
|
|
144
|
+
datasFantom,
|
|
145
|
+
datasHyperEvm,
|
|
146
|
+
// datasKaia,
|
|
147
|
+
datasSonic, //
|
|
144
148
|
].join(',')}?searchWidth=4h`
|
|
145
|
-
const URL_HIST = (ref: number) =>
|
|
149
|
+
const URL_HIST = (ref: number) =>
|
|
150
|
+
`https://coins.llama.fi/prices/historical/${ref}/${[
|
|
146
151
|
datasEthereum,
|
|
147
152
|
datasAvalanche,
|
|
148
153
|
datasArbitrum,
|
|
@@ -151,156 +156,157 @@ const URL_HIST = (ref: number) => `https://coins.llama.fi/prices/historical/${re
|
|
|
151
156
|
datasCore,
|
|
152
157
|
datasMetis,
|
|
153
158
|
datasFantom,
|
|
154
|
-
datasKaia,
|
|
159
|
+
// datasKaia,
|
|
160
|
+
datasHyperEvm,
|
|
155
161
|
datasSonic, //
|
|
156
|
-
].join(',')}?searchWidth=4h`
|
|
162
|
+
].join(',')}?searchWidth=4h`
|
|
157
163
|
|
|
158
164
|
const SYMBOL_MAP = {
|
|
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
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
165
|
+
weth: 'WETH',
|
|
166
|
+
usde: 'USDE',
|
|
167
|
+
meth: 'METH',
|
|
168
|
+
mnt: 'WMNT',
|
|
169
|
+
usdc: 'USDC',
|
|
170
|
+
usdt: 'USDT',
|
|
171
|
+
wbtc: 'WBTC',
|
|
172
|
+
usdy: 'USDY',
|
|
173
|
+
crv: 'CRV',
|
|
174
|
+
op: 'OP',
|
|
175
|
+
bal: 'BAL',
|
|
176
|
+
eura: 'AGEUR',
|
|
177
|
+
link: 'LINK',
|
|
178
|
+
dai: 'DAI',
|
|
179
|
+
bnb: 'WBNB',
|
|
180
|
+
matic: 'WPOL',
|
|
181
|
+
wpol: 'WPOL',
|
|
182
|
+
pol: 'WPOL',
|
|
183
|
+
stmatic: 'STMATIC',
|
|
184
|
+
maticx: 'MATICX',
|
|
185
|
+
wavax: 'WAVAX',
|
|
186
|
+
aave: 'AAVE',
|
|
187
|
+
comp: 'COMP',
|
|
188
|
+
eurs: 'EURS',
|
|
189
|
+
fbtc: 'FBTC',
|
|
190
|
+
taiko: 'TAIKO',
|
|
191
|
+
cmeth: 'CMETH',
|
|
192
|
+
ausd: 'AUSD',
|
|
193
|
+
susde: 'SUSDE',
|
|
194
|
+
fuel: 'FUEL',
|
|
195
|
+
gho: 'GHO',
|
|
196
|
+
frax: 'FRAX',
|
|
197
|
+
weeth: 'WEETH',
|
|
198
|
+
arb: 'ARB',
|
|
199
|
+
lusd: 'LUSD',
|
|
200
|
+
reth: 'RETH',
|
|
201
|
+
gmx: 'GMX',
|
|
202
|
+
wusdm: 'WUSDM',
|
|
203
|
+
rseth: 'RSETH',
|
|
204
|
+
susd: 'SUSD',
|
|
205
|
+
wrseth: 'WRSETH',
|
|
206
|
+
cbeth: 'CBETH',
|
|
207
|
+
aero: 'AERO',
|
|
208
|
+
snx: 'SNX',
|
|
209
|
+
wftm: 'WFTM',
|
|
210
|
+
ftm: 'WFTM',
|
|
211
|
+
wcore: 'WCORE',
|
|
212
|
+
core: 'WCORE',
|
|
213
|
+
ws: 'WS',
|
|
214
|
+
s: 'WS',
|
|
215
|
+
wmetis: 'WMETIS',
|
|
216
|
+
metis: 'WMETIS',
|
|
217
|
+
vusd: 'VUSD',
|
|
218
|
+
ezeth: 'EZETH',
|
|
219
|
+
lbtc: 'LBTC',
|
|
220
|
+
brbtc: 'BRBTC',
|
|
221
|
+
sdai: 'SDAI',
|
|
222
|
+
wkaia: 'KAIA',
|
|
223
|
+
savax: 'SAVAX',
|
|
224
|
+
whype: 'WHYPE',
|
|
218
225
|
}
|
|
219
226
|
|
|
220
227
|
export async function fetchDefillamaData() {
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
let prices = Object.assign(
|
|
224
|
-
{},
|
|
225
|
-
...Object.values(res.data.coins).map(
|
|
226
|
-
// @ts-ignore
|
|
227
|
-
(k: any) => { return { [SYMBOL_MAP[k.symbol.toLowerCase()]]: k.price } }
|
|
228
|
-
)
|
|
229
|
-
)
|
|
228
|
+
try {
|
|
229
|
+
const res: any = await fetch(URL)
|
|
230
230
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
prices["KAIA"] = prices["WKAIA"]
|
|
231
|
+
let prices = Object.assign(
|
|
232
|
+
{},
|
|
233
|
+
...Object.values(res.data.coins).map((k: any) => {
|
|
234
|
+
// @ts-ignore
|
|
235
|
+
return { [SYMBOL_MAP[k.symbol.toLowerCase()]]: k.price }
|
|
236
|
+
}),
|
|
237
|
+
)
|
|
239
238
|
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
239
|
+
prices['POL'] = prices['WPOL']
|
|
240
|
+
prices['BNB'] = prices['WBNB']
|
|
241
|
+
prices['ETH'] = prices['WETH']
|
|
242
|
+
prices['S'] = prices['WS']
|
|
243
|
+
prices['CORE'] = prices['WCORE']
|
|
244
|
+
prices['AVAX'] = prices['WAVAX']
|
|
245
|
+
prices['METIS'] = prices['WMETIS']
|
|
246
|
+
// prices['WKAIA'] = prices['KAIA']
|
|
246
247
|
|
|
247
|
-
|
|
248
|
-
|
|
248
|
+
prices['USDBC'] = prices['USDC']
|
|
249
|
+
prices['BTCB'] = prices['WBTC']
|
|
250
|
+
prices['CBBTC'] = prices['WBTC']
|
|
251
|
+
prices['SOLVBTC'] = prices['WBTC']
|
|
252
|
+
prices['XSOLVBTC'] = prices['WBTC']
|
|
253
|
+
prices['SUBTC'] = prices['WBTC']
|
|
249
254
|
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
255
|
+
prices['IBTC'] = prices['WBTC']
|
|
256
|
+
prices['ENZOBTC'] = prices['WBTC']
|
|
257
|
+
|
|
258
|
+
prices['LUSD'] = prices['USDT']
|
|
259
|
+
prices['XDAI'] = prices['DAI']
|
|
260
|
+
prices['WXDAI'] = prices['DAI']
|
|
261
|
+
prices['HYPE'] = prices['WHYPE']
|
|
262
|
+
return prices
|
|
263
|
+
} catch (e: any) {
|
|
264
|
+
console.log('error fetching prices from defillama', e)
|
|
265
|
+
return {}
|
|
266
|
+
}
|
|
259
267
|
}
|
|
260
268
|
|
|
261
269
|
export async function fetchDefillamaHistData() {
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
let histPrices = Object.assign(
|
|
267
|
-
{},
|
|
268
|
-
...Object.values(resHist.data.coins).map(
|
|
269
|
-
// @ts-ignore
|
|
270
|
-
(k: any) => { return { [SYMBOL_MAP[k.symbol.toLowerCase()]]: k.price } }
|
|
271
|
-
)
|
|
272
|
-
)
|
|
270
|
+
try {
|
|
271
|
+
const nowMinus24 = Math.floor(Date.now() / 1000 - 24 * 3600)
|
|
272
|
+
const resHist: any = await fetch(URL_HIST(nowMinus24))
|
|
273
273
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
histPrices["KAIA"] = histPrices["WKAIA"]
|
|
274
|
+
let histPrices = Object.assign(
|
|
275
|
+
{},
|
|
276
|
+
...Object.values(resHist.data.coins).map((k: any) => {
|
|
277
|
+
// @ts-ignore
|
|
278
|
+
return { [SYMBOL_MAP[k.symbol.toLowerCase()]]: k.price }
|
|
279
|
+
}),
|
|
280
|
+
)
|
|
282
281
|
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
282
|
+
histPrices['POL'] = histPrices['WPOL']
|
|
283
|
+
histPrices['BNB'] = histPrices['WBNB']
|
|
284
|
+
histPrices['ETH'] = histPrices['WETH']
|
|
285
|
+
histPrices['S'] = histPrices['WS']
|
|
286
|
+
histPrices['CORE'] = histPrices['WCORE']
|
|
287
|
+
histPrices['AVAX'] = histPrices['WAVAX']
|
|
288
|
+
histPrices['METIS'] = histPrices['WMETIS']
|
|
289
|
+
histPrices['HYPE'] = histPrices['WHYPE']
|
|
290
|
+
// histPrices['WKAIA'] = histPrices['KAIA']
|
|
286
291
|
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
histPrices["XSOLVBTC"] = histPrices["WBTC"]
|
|
291
|
-
histPrices["UNIBTC"] = histPrices["WBTC"]
|
|
292
|
-
histPrices["HEMIBTC"] = histPrices["WBTC"]
|
|
293
|
-
histPrices["SUBTC"] = histPrices["WBTC"]
|
|
294
|
-
histPrices["IBTC"] = histPrices["WBTC"]
|
|
295
|
-
histPrices["ENZOBTC"] = histPrices["WBTC"]
|
|
296
|
-
histPrices["PUMPBTC"] = histPrices["WBTC"]
|
|
292
|
+
histPrices['LUSD'] = histPrices['USDT']
|
|
293
|
+
histPrices['XDAI'] = histPrices['DAI']
|
|
294
|
+
histPrices['WXDAI'] = histPrices['DAI']
|
|
297
295
|
|
|
298
|
-
|
|
296
|
+
histPrices['BTCB'] = histPrices['WBTC']
|
|
297
|
+
histPrices['M-BTC'] = histPrices['WBTC']
|
|
298
|
+
histPrices['SOLVBTC'] = histPrices['WBTC']
|
|
299
|
+
histPrices['XSOLVBTC'] = histPrices['WBTC']
|
|
300
|
+
histPrices['UNIBTC'] = histPrices['WBTC']
|
|
301
|
+
histPrices['HEMIBTC'] = histPrices['WBTC']
|
|
302
|
+
histPrices['SUBTC'] = histPrices['WBTC']
|
|
303
|
+
histPrices['IBTC'] = histPrices['WBTC']
|
|
304
|
+
histPrices['ENZOBTC'] = histPrices['WBTC']
|
|
305
|
+
histPrices['PUMPBTC'] = histPrices['WBTC']
|
|
299
306
|
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
307
|
+
return histPrices
|
|
308
|
+
} catch (e: any) {
|
|
309
|
+
console.log('error fetching prices from defillama', e)
|
|
310
|
+
return {}
|
|
311
|
+
}
|
|
305
312
|
}
|
|
306
|
-
|
package/src/prices/index.ts
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from './defillama'
|
|
2
|
+
export * from './main-prices'
|
|
3
|
+
export * from './pendle'
|