diff --git a/liquidity/lib/etherscanLink/etherscanLink.ts b/liquidity/lib/etherscanLink/etherscanLink.ts index f52d7a61c..46a77b9ee 100644 --- a/liquidity/lib/etherscanLink/etherscanLink.ts +++ b/liquidity/lib/etherscanLink/etherscanLink.ts @@ -1,20 +1,24 @@ -export function etherscanLink({ chain, address }: { chain: string; address: string }): string { +export function etherscanLink({ + chain, + address, + isTx = false, +}: { + chain: string; + address: string; + isTx?: boolean; +}): string { switch (chain) { - case 'goerli': - return `https://goerli.etherscan.io/address/${address}`; case 'sepolia': - return `https://sepolia.etherscan.io/address/${address}`; - case 'optimism-goerli': - return `https://goerli-optimism.etherscan.io/address/${address}`; + return `https://sepolia.etherscan.io/${isTx ? 'tx' : 'address'}/${address}`; case 'optimism': - return `https://optimistic.etherscan.io/address/${address}`; + return `https://optimistic.etherscan.io/${isTx ? 'tx' : 'address'}/${address}`; case 'base': - return `https://basescan.org/tx/${address}`; - case 'base-goerli': - return `https://goerli.basescan.org/tx/${address}`; + return `https://basescan.org/${isTx ? 'tx' : 'address'}/${address}`; + case 'base-sepolia': + return `https://sepolia.basescan.org/${isTx ? 'tx' : 'address'}/${address}`; case 'mainnet': default: - return `https://etherscan.io/address/${address}`; + return `https://etherscan.io/${isTx ? 'tx' : 'address'}/${address}`; } } diff --git a/liquidity/lib/usePoolData/usePoolData.tsx b/liquidity/lib/usePoolData/usePoolData.tsx index d5fcbaf4f..3e2f51ee0 100644 --- a/liquidity/lib/usePoolData/usePoolData.tsx +++ b/liquidity/lib/usePoolData/usePoolData.tsx @@ -56,6 +56,7 @@ const RewardDistributorSchema = z.object({ z.object({ amount: z.string(), duration: z.string(), + created_at: z.string(), }) ) .default([]), @@ -87,9 +88,10 @@ const PoolsDataDocument = gql` registered_distributors(where: { isActive: true }) { id total_distributed - rewards_distributions(orderBy: duration, orderDirection: desc) { + rewards_distributions(orderBy: created_at, orderDirection: desc) { amount duration + created_at } } total_weight diff --git a/liquidity/lib/useRewards/useRewards.ts b/liquidity/lib/useRewards/useRewards.ts index 7123e1b2b..4729d86f8 100644 --- a/liquidity/lib/useRewards/useRewards.ts +++ b/liquidity/lib/useRewards/useRewards.ts @@ -33,6 +33,7 @@ type RewardsInterface = { rewards_distributions: { amount: string; duration: string; + created_at: string; }[]; }[]; @@ -140,12 +141,20 @@ export function useRewards( 0 ); + // See if it is still active (i.e rewards are still being emitted) + const { duration: distribution_duration, created_at } = rewards_distributions[0]; + + const expiry = parseInt(distribution_duration) + parseInt(created_at); + + // const total = + const hasExpired = new Date().getTime() / 1000 > expiry; + return { address, name: name, token: token, duration, - total: rewards_distributions[0].amount, // Take the latest amount + total: hasExpired ? '0' : rewards_distributions[0].amount, // Take the latest amount lifetimeClaimed, }; }); diff --git a/liquidity/ui/src/components/Rewards/Rewards.tsx b/liquidity/ui/src/components/Rewards/Rewards.tsx index cd6ecef92..ab8fe7987 100644 --- a/liquidity/ui/src/components/Rewards/Rewards.tsx +++ b/liquidity/ui/src/components/Rewards/Rewards.tsx @@ -32,7 +32,7 @@ export const Rewards = ({ const empty = rewards && rewards.length === 0; return ( - + REWARDS @@ -61,7 +61,7 @@ export const Rewards = ({ px={4} py={3} > - Estimated Rate + Active Rewards diff --git a/liquidity/ui/src/components/Rewards/RewardsModal.tsx b/liquidity/ui/src/components/Rewards/RewardsModal.tsx index 250ce14a7..54ef6371b 100644 --- a/liquidity/ui/src/components/Rewards/RewardsModal.tsx +++ b/liquidity/ui/src/components/Rewards/RewardsModal.tsx @@ -149,7 +149,7 @@ export const RewardsModal = ({ > - - - - {` ${symbol}`} - - - {frequencyString && ( + + + + + + + + {frequencyString && totalAmount > 0 && ( {frequencyString}