Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/api/rewards.js
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -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)));
}

Expand All @@ -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;
}
}
}}
9 changes: 9 additions & 0 deletions src/lib/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
}