diff --git a/apps/hyperdrive-trading/src/ui/markets/PoolsList/PoolsList.tsx b/apps/hyperdrive-trading/src/ui/markets/PoolsList/PoolsList.tsx index c89ded0db..af49f7863 100644 --- a/apps/hyperdrive-trading/src/ui/markets/PoolsList/PoolsList.tsx +++ b/apps/hyperdrive-trading/src/ui/markets/PoolsList/PoolsList.tsx @@ -225,7 +225,12 @@ export function PoolsList(): ReactElement { )} - ) : null} + ) : ( + + )} ); diff --git a/packages/hyperdrive-appconfig/src/rewards/resolvers/morpho.ts b/packages/hyperdrive-appconfig/src/rewards/resolvers/morpho.ts index 2b5b8b3eb..7d368af8b 100644 --- a/packages/hyperdrive-appconfig/src/rewards/resolvers/morpho.ts +++ b/packages/hyperdrive-appconfig/src/rewards/resolvers/morpho.ts @@ -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, }; } @@ -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; +}