Skip to content

Commit

Permalink
improve: account for case where ref is the user
Browse files Browse the repository at this point in the history
  • Loading branch information
james-a-morris committed Nov 3, 2023
1 parent 3a451b4 commit eff02f9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/views/Bridge/hooks/useEstimatedTable.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { utils } from "@across-protocol/sdk-v2";
import { BigNumber } from "ethers";
import { useConnection } from "hooks";
import { useReferralSummary } from "hooks/useReferralSummary";
import useReferrer from "hooks/useReferrer";
import { useTokenConversion } from "hooks/useTokenConversion";
Expand All @@ -18,6 +19,7 @@ export function useEstimatedTable(
) {
const [isDetailedFeesAvailable, setIsDetailedFeesAvailable] = useState(false);

const { account } = useConnection();
const { referrer } = useReferrer();
const { summary: referralSummary } = useReferralSummary(referrer);

Expand All @@ -43,7 +45,8 @@ export function useEstimatedTable(
.mul(fixedPointAdjustment)
.div(acxExchangeRate);
// 75% of the reward goes to the referree of the referral rate
const availableRewardPercentage = referralSummary.referralRate * 0.75;
const availableRewardPercentage =
referralSummary.referralRate * (referrer === account ? 1.0 : 0.75);
return {
tokens: totalFeesACX
.mul(parseUnits(availableRewardPercentage.toString(), 18))
Expand All @@ -56,6 +59,7 @@ export function useEstimatedTable(
convertL1ToBaseCurrency,
convertRewardToBaseCurrency,
referrer,
account,
]);

const referralRewardAsBaseCurrency = convertRewardToBaseCurrency(
Expand Down

0 comments on commit eff02f9

Please sign in to comment.