Skip to content

Commit 32ece17

Browse files
authored
Fix LP rewards calculatino (#1457)
1 parent 51cdac4 commit 32ece17

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

apps/hyperdrive-trading/src/ui/rewards/useRewards.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,9 @@ type UseRewardsReturn =
3131
}[]
3232
| undefined;
3333

34-
function getWeight(
34+
function getWeightMorpho(
3535
poolConfig: PoolConfig,
3636
positionType: "short" | "lp",
37-
decimals: number,
3837
poolInfo?: PoolInfo,
3938
presentValue?: bigint,
4039
): FixedPoint {
@@ -46,11 +45,12 @@ function getWeight(
4645
return parseFixed(1, 18);
4746
}
4847

49-
const shareReserves = fixed(poolInfo.shareReserves, decimals);
50-
const minShareReserves = fixed(poolConfig.minimumShareReserves, decimals);
48+
// Morpho share price is in 24 decimals, but FixedPoint only supports 18 max.
49+
const shareReserves = fixed(poolInfo.shareReserves / BigInt(1e6));
50+
const minShareReserves = fixed(poolConfig.minimumShareReserves / BigInt(1e6));
5151
const netShareReserves = shareReserves.sub(minShareReserves);
5252

53-
return netShareReserves.div(parseFixed(presentValue, decimals));
53+
return netShareReserves.div(presentValue);
5454
}
5555

5656
export function useRewards(
@@ -72,10 +72,9 @@ export function useRewards(
7272
)
7373
) {
7474
const morphoRate = MorphoFlatRatePerYear.mul(
75-
getWeight(
75+
getWeightMorpho(
7676
hyperdrive.poolConfig,
7777
positionType,
78-
hyperdrive.decimals,
7978
poolInfo,
8079
presentValue,
8180
),

0 commit comments

Comments
 (0)