Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,7 @@ function ClaimRewardsButton({
rewardTokenAddress: reward.rewardTokenAddress,
claimContractAddress: reward.claimContractAddress,
account,
chainId: reward.chainId,
});
const appConfig = useAppConfigForConnectedChain({ strict: false });

Expand All @@ -273,7 +274,7 @@ function ClaimRewardsButton({
disabled
className="daisy-btn daisy-btn-disabled daisy-btn-ghost rounded-full bg-gray-600 font-inter"
>
Claim Reward
Claim Rewards
</button>
);
}
Expand All @@ -300,7 +301,7 @@ function ClaimRewardsButton({
)}
onClick={claim}
>
Claim Reward
Claim Rewards
</button>
);
}
Expand All @@ -323,6 +324,7 @@ function ClaimableAmount({
rewardTokenAddress: reward.rewardTokenAddress,
claimContractAddress: reward.claimContractAddress,
account,
chainId: reward.chainId,
});

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { parseFixed } from "@delvtech/fixed-point-wasm";
import { MerklApi } from "@merkl/api";
import { useQuery } from "@tanstack/react-query";
import { makeQueryKey2 } from "src/base/makeQueryKey";
import { rewardsFork } from "src/chains/rewardsFork";
import {
HyperdriveRewardsApi,
Reward,
} from "src/rewards/generated/HyperdriveRewardsApi";
import { Address, Hash } from "viem";
import { base, gnosis, linea, mainnet } from "viem/chains";
import { gnosis } from "viem/chains";
import { usePublicClient } from "wagmi";

export function useClaimableRewards({
Expand Down Expand Up @@ -58,6 +59,7 @@ async function fetchHyperdriveRewardApi(account: Address): Promise<Reward[]> {
// TODO: Remove this once claimbableAmount is no longer formatted server side
return response.rewards.map((r) => ({
...r,
chainId: rewardsFork.id,
claimableAmount: parseFixed(r.claimableAmount).bigint.toString(),
}));
} catch (error: any) {
Expand All @@ -84,14 +86,14 @@ const merkl = MerklApi("https://api.merkl.xyz").v4;
* See: https://app.merkl.xyz/status
*/
const MerklDistributorsByChain: Record<number, Address> = {
[mainnet.id]: "0x3Ef3D8bA38EBe18DB133cEc108f4D14CE00Dd9Ae",
[gnosis.id]: "0x3Ef3D8bA38EBe18DB133cEc108f4D14CE00Dd9Ae",
[base.id]: "0x3Ef3D8bA38EBe18DB133cEc108f4D14CE00Dd9Ae",
[linea.id]: "0x3Ef3D8bA38EBe18DB133cEc108f4D14CE00Dd9Ae",
};

async function fetchMileRewards(account: Address): Promise<Reward[]> {
const chainIds = [mainnet.id, gnosis.id, linea.id, base.id];
// Merkl.xyz accumulates Miles across all chains and hyperdrives onto Gnosis
// chain only. This makes things easier for turning them into HD later if
// they're all just on one chain.
const chainIds = [gnosis.id];

// Request miles earned on each chain. We have to call this once per chain
// since the merkl api is buggy, despite accepting an array of chain ids. If
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,20 @@ import { useReadContract } from "wagmi";
export function useClaimedRewards({
rewardTokenAddress,
claimContractAddress,
chainId,
account,
}: {
rewardTokenAddress: Address | undefined;
claimContractAddress: Address | undefined;
chainId: number | undefined;
account: Address | undefined;
}): { claimed: bigint | undefined; status: "loading" | "error" | "success" } {
const enabled = !!rewardTokenAddress && !!account;
const { data: claimed, status } = useReadContract({
address: claimContractAddress,
abi: hyperdriveRewardsAbi,
functionName: "claimed",
chainId,
args: enabled ? [account, rewardTokenAddress] : undefined,
query: {
enabled,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const fetchHypervueMilesRewards: RewardResolver = async () => {
{
type: "info",
iconUrl: HyperVueMilesIconUrl,
message: "Earns 1 Mile per day for every $1 supplied",
message: "Earns 1 Mile per year for every $1 supplied",
},
];
};
Expand Down
Loading