Skip to content

Commit

Permalink
smardex fix
Browse files Browse the repository at this point in the history
  • Loading branch information
slasher125 committed Dec 20, 2023
1 parent 509a1fe commit 4607788
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/adaptors/smardex/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ const campaignRewardAPY = (
currentBlockNumber,
sdexPrice,
BLOCKS_PER_YEAR,
STAKING_ADDRESS,
STAKING_ADDRESS
) => {
let apr = 0;
if (
Expand All @@ -228,7 +228,9 @@ const campaignRewardAPY = (

if (currentBlockNumber < reward.endBlock) {
const aprBN = reward.rewardPerBlock
.mul(parseInt(campaign.id, 10) === 0 && STAKING_ADDRESS ? 1 : WeiPerEther)
.mul(
parseInt(campaign.id, 10) === 0 && STAKING_ADDRESS ? 1 : WeiPerEther
)
.mul(BLOCKS_PER_YEAR)
.mul(100)
.div(campaign.totalStaked);
Expand Down Expand Up @@ -327,7 +329,7 @@ const topLvl = async (
block,
sdexPrice,
BLOCKS_PER_YEAR,
STAKING_ADDRESS,
STAKING_ADDRESS
);

return {
Expand Down Expand Up @@ -356,7 +358,7 @@ const main = async (timestamp = null) => {
const chains = Object.keys(CONFIG);

// Fetching data for each chain in parallel
const resultData = await Promise.all(
const resultData = await Promise.allSettled(
chains.map(async (chain) => {
const data = await topLvl(
chain,
Expand All @@ -371,7 +373,11 @@ const main = async (timestamp = null) => {
})
);

return resultData.flat().filter(utils.keepFinite);
return resultData
.filter((i) => i.status === 'fulfilled')
.map((i) => i.value)
.flat()
.filter(utils.keepFinite);
};

module.exports = {
Expand Down

0 comments on commit 4607788

Please sign in to comment.