Skip to content

Commit

Permalink
SOV-3653: Fix LP rewards (#2594)
Browse files Browse the repository at this point in the history
Fix LP rewards
  • Loading branch information
tiltom authored Feb 20, 2024
1 parent 2af17a6 commit 7f8d2aa
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export const RemoveLiquidityDialogV1: React.FC<IRemoveLiquidityDialogV1Props> =
const weiAmount = useWeiAmount(amount);

const {
value: { amount: poolTokenBalance, accumulatedReward },
value: { amount: poolTokenBalance },
loading,
} = useLiquidityMining_getUserInfo(pool.poolTokenA);

Expand Down Expand Up @@ -155,11 +155,6 @@ export const RemoveLiquidityDialogV1: React.FC<IRemoveLiquidityDialogV1Props> =

const rewards = useLiquidityMining_getUserAccumulatedReward(pool.poolTokenA);

const reward = useMemo(
() => bignumber(rewards.value).add(accumulatedReward).toFixed(0),
[rewards.value, accumulatedReward],
);

const handleConfirm = () => withdraw();

return (
Expand Down Expand Up @@ -203,7 +198,7 @@ export const RemoveLiquidityDialogV1: React.FC<IRemoveLiquidityDialogV1Props> =
value={
<LoadableValue
loading={rewards.loading || loading}
value={weiToNumberFormat(reward, 6)}
value={weiToNumberFormat(rewards.value, 6)}
/>
}
appendElem={<AssetRenderer asset={Asset.SOV} />}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const RemoveLiquidityDialog: React.FC<IRemoveLiquidityDialogProps> = ({
const poolTokenAddress = pool.getPoolTokenAddress(asset)!;

const {
value: { amount: poolTokenBalance, accumulatedReward },
value: { amount: poolTokenBalance },
loading,
} = useLiquidityMining_getUserInfo(poolTokenAddress);
const {
Expand Down Expand Up @@ -100,11 +100,6 @@ export const RemoveLiquidityDialog: React.FC<IRemoveLiquidityDialogProps> = ({

const rewards = useLiquidityMining_getUserAccumulatedReward(poolTokenAddress);

const reward = useMemo(
() => bignumber(rewards.value).add(accumulatedReward).toFixed(0),
[rewards.value, accumulatedReward],
);

const handleConfirm = () => withdraw();

const assets = useMemo(() => [pool.assetA, pool.assetB], [pool]);
Expand Down Expand Up @@ -144,7 +139,7 @@ export const RemoveLiquidityDialog: React.FC<IRemoveLiquidityDialogProps> = ({
value={
<LoadableValue
loading={rewards.loading || loading}
value={weiToNumberFormat(reward, 6)}
value={weiToNumberFormat(rewards.value, 6)}
/>
}
appendElem={<AssetRenderer asset={Asset.SOV} />}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
import { bignumber } from 'mathjs';
import { useLiquidityMining_getUserInfo } from './useLiquidityMining_getUserInfo';
import { useLiquidityMining_getUserAccumulatedReward } from './useLiquidityMining_getUserAccumulatedReward';

export function useLiquidityMining_getTotalUserAccumulatedReward(
poolToken: string,
) {
const info = useLiquidityMining_getUserInfo(poolToken);
const reward = useLiquidityMining_getUserAccumulatedReward(poolToken);

return {
value: bignumber(info.value?.accumulatedReward || '0')
.add(reward.value)
.toFixed(0),
loading: info.loading || reward.loading,
error: info.error || reward.error,
value: reward.value,
loading: reward.loading,
error: reward.error,
};
}

0 comments on commit 7f8d2aa

Please sign in to comment.