mirror of
https://github.com/uniwhale-io/DefiLlama-yield-server.git
synced 2026-01-12 08:53:45 +08:00
1inch api add rate limit
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
const sdk = require('@defillama/sdk');
|
||||
const axios = require('axios');
|
||||
|
||||
function sleep(ms) {
|
||||
return new Promise((resolve) => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
const rebase =
|
||||
'Rebase Token: Staking rewards accrue as new tokens. Expected Peg = 1 : 1';
|
||||
const valueAccruing =
|
||||
@@ -98,15 +102,13 @@ const getMarketRates = async () => {
|
||||
for (const url of urls) {
|
||||
try {
|
||||
marketRates.push((await axios.get(url)).data);
|
||||
// 1inch api 5requests/sec max
|
||||
await sleep(300);
|
||||
} catch (err) {
|
||||
console.log(url, err);
|
||||
}
|
||||
}
|
||||
|
||||
// const marketRates = (await Promise.allSettled(urls.map((u) => axios.get(u))))
|
||||
// .map((p) => p.value?.data)
|
||||
// .filter(Boolean);
|
||||
|
||||
return marketRates;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user