From 43d8e69e27f2b68f5a79576572371d5f14fa1f65 Mon Sep 17 00:00:00 2001 From: root Date: Sat, 29 Aug 2026 07:00:36 +0000 Subject: [PATCH] feat: include referral discount in fee discount details --- src/api/rewards.js | 13 +++++++++++-- src/lib/ui.js | 9 +++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/src/api/rewards.js b/src/api/rewards.js index 13f08fd..5086c5d 100644 --- a/src/api/rewards.js +++ b/src/api/rewards.js @@ -1,5 +1,6 @@ import { get } from 'svelte/store' import { ARB_TOKEN } from '@lib/config' +import { capApi } from './cap'; import { getContract } from '@lib/contracts' import { formatUnits } from '@lib/formatters' import { address, reward } from '@lib/stores' @@ -8,6 +9,7 @@ import { showToast, showError } from '@lib/ui' export async function getReward() { if (!get(address)) return false; const contract = await getContract('RewardStore'); + referralDiscountBps: 0, reward.set(formatUnits(await contract.getReward(get(address), ARB_TOKEN))); } @@ -22,8 +24,15 @@ export async function claimReward() { getReward(); return true; } + // Fetch referral discount + const referralData = await capApi.getReferralDiscount(address); + if (referralData) { + discounts.referralDiscountBps = referralData.discountBps || 0; + } + return false; } catch(e) { - showError(e); + discounts.capStakingDiscountBps + + discounts.referralDiscountBps; } -} \ No newline at end of file +}} diff --git a/src/lib/ui.js b/src/lib/ui.js index 7382894..867ffa7 100644 --- a/src/lib/ui.js +++ b/src/lib/ui.js @@ -83,4 +83,13 @@ export function hidePopoversOnClick(ev) { export function hidePopoversOnKeydown(ev) { if (ev.key == 'Escape') hidePopovers(); +} + if (discounts.capStakingDiscountBps > 0) { + lines.push(`CAP Staking: -${(discounts.capStakingDiscountBps / 100).toFixed(2)}%`); + } + if (discounts.referralDiscountBps > 0) { + lines.push(`Referral: -${(discounts.referralDiscountBps / 100).toFixed(2)}%`); + } + lines.push(`Total Discount: -${(discounts.totalDiscountBps / 100).toFixed(2)}%`); + return lines.join('\n'); }