Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,12 @@ export function PoolsList(): ReactElement {
</Fade>
)}
</>
) : null}
) : (
<NonIdealState
heading="Error loading pools"
text="Please try again"
/>
)}
</div>
</>
);
Expand Down
20 changes: 17 additions & 3 deletions packages/hyperdrive-appconfig/src/rewards/resolvers/morpho.ts
Original file line number Diff line number Diff line change
Expand Up @@ -324,11 +324,17 @@ function parseAllocationRewards({
// Calculate "Reward rates" (like APR) for tokens that have monetary
// value, based on the vault's allocated assets.
if (reward.supplyApr) {
const vaultAdjustedRewardRate = percentOfVaultAllocatedToMarket.mul(
// The supplyAPR is provided as a javascript number from the
// Morpho endpoint, which could end up having more than 18 numbers
// after the decimal point. Since fixed=-point-wasm doesn't like
// that, we must make sure to truncate the supplyApr before using
// it.
parseFixed(truncateTo18Decimals(reward.supplyApr)),
);
return {
reward,
vaultAdjustedRewardRate: percentOfVaultAllocatedToMarket.mul(
parseFixed(reward.supplyApr),
),
vaultAdjustedRewardRate,
};
}

Expand Down Expand Up @@ -429,3 +435,11 @@ function parseAllocationRewards({

return [...transferableTokenRewards, ...nonTransferableTokenRewards];
}

/**
* Truncates a number to no more than 18 decimal places after the decimal point.
* This prevents fixed point wasm errors, "Exponent 18 is too small for I256"
*/
function truncateTo18Decimals(num: number) {
return Math.floor(num * 1e18) / 1e18;
}
Loading