Skip to content

Commit

Permalink
fix claim
Browse files Browse the repository at this point in the history
  • Loading branch information
jarbacoa committed Jun 10, 2022
1 parent b0ec226 commit e303967
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 34 deletions.
26 changes: 11 additions & 15 deletions src/components/shared/Claim/ClaimRGTModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ import {
useUnclaimedFuseRewards,
} from "hooks/rewards/useUnclaimedFuseRewards";
import DashboardBox from "../DashboardBox";
import {
TokenData,
useTokensDataAsMap,
} from "hooks/useTokenData";
import { TokenData, useTokensDataAsMap } from "hooks/useTokenData";
import { useClaimable } from "hooks/rewards/useClaimable";
import { claimRewardsFromRewardsDistributors } from "utils/rewards";
import { SimpleTooltip } from "../SimpleTooltip";
Expand Down Expand Up @@ -56,7 +53,6 @@ export const ClaimRGTModal = ({

const { fuse } = useRari();


// pool2
// private
// yieldagg
Expand Down Expand Up @@ -120,13 +116,11 @@ const ClaimRewards = ({ showPrivate }: { showPrivate: boolean }) => {

const { allClaimable, allRewardsTokens } = useClaimable(showPrivate);


const [claimingAll, setClaimingAll] = useState(false);
const [claimingToken, setClaimingToken] = useState<string | undefined>();

const rewardTokensData = useTokensDataAsMap(allRewardsTokens);


// Claims all Fuse LM rewards at once
const handleClaimAll = useCallback(() => {
setClaimingAll(true);
Expand Down Expand Up @@ -168,6 +162,7 @@ const ClaimRewards = ({ showPrivate }: { showPrivate: boolean }) => {
const rDs = rewardTokensMap[rewardToken];
const rDAddresses = rDs.map((rD) => rD.rewardsDistributorAddress); // all rewardsdistributors for this token


if (!!rDs.length) {
setClaimingToken(rewardToken);
claimRewardsFromRewardsDistributors(fuse, address, rDAddresses)
Expand Down Expand Up @@ -248,8 +243,6 @@ const ClaimRewards = ({ showPrivate }: { showPrivate: boolean }) => {
);
};



const ClaimableRow = ({
unclaimed,
handleClaimFuseRewardsForToken,
Expand Down Expand Up @@ -305,8 +298,10 @@ const ClaimableRow = ({
};

const unclaimedAmount = useMemo(() => {
return parseFloat(unclaimed.unclaimed.toString()) /
(1 * 10 ** (rewardTokenData?.decimals ?? 18));
return (
parseFloat(unclaimed.unclaimed.toString()) /
(1 * 10 ** (rewardTokenData?.decimals ?? 18))
);
}, [unclaimed.unclaimed, rewardTokenData]);

return (
Expand Down Expand Up @@ -343,7 +338,7 @@ const ClaimableRow = ({
crossAxisAlignment="center"
px={6}
py={4}
// bg="aqua"
// bg="aqua"
>
<ul>
{pools.map((p) => (
Expand All @@ -367,7 +362,7 @@ const ClaimableRow = ({
crossAxisAlignment="center"
px={6}
py={2}
// bg="aqua"
// bg="aqua"
>
<ul>
<motion.li
Expand Down Expand Up @@ -395,8 +390,9 @@ const ClaimableRow = ({
h="100%"
>
<SimpleTooltip
label={`${unclaimedAmount.toString()} ${rewardTokenData?.symbol
}`}
label={`${unclaimedAmount.toString()} ${
rewardTokenData?.symbol
}`}
>
<Text fontWeight="bold" ml={3}>
{unclaimedAmount.toFixed(3)} {rewardTokenData?.symbol}
Expand Down
2 changes: 1 addition & 1 deletion src/esm/Fuse/contracts/compound-protocol.min.json

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions src/esm/utils/networks.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ export const chainMetadata = {
blockExplorerURL: "https://optimistic.etherscan.io",
color: "#FE0521",
},
// [ChainID.HARDHAT]: {
// chainId: ChainID.HARDHAT,
// name: "Hardhat",
// imageUrl: "/static/networks/optimism.svg", // no logo
// supported: true,
// rpcUrl: "http://localhost:8545",
// blockExplorerURL: "",
// color: "#BC6C6C"
// }
[ChainID.HARDHAT]: {
chainId: ChainID.HARDHAT,
name: "Hardhat",
imageUrl: "/static/networks/optimism.svg", // no logo
supported: true,
rpcUrl: "http://localhost:8545",
blockExplorerURL: "",
color: "#BC6C6C"
}
};
export const isSupportedChainId = (chainId) => Object.values(ChainID).includes(chainId);
export function getSupportedChains() {
Expand Down
4 changes: 1 addition & 3 deletions src/utils/multicall.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ export const sendWithMultiCall = async (

console.log("sendWithMultiCall", { encodedCalls, multicall });

const returnDatas = await multicall.aggregate(encodedCalls, {
from: address,
});
const returnDatas = await multicall.aggregate(encodedCalls);

return returnDatas;
};
Expand Down
15 changes: 9 additions & 6 deletions src/utils/rewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,23 @@ export const claimRewardsFromRewardsDistributors = async (
address: string,
rewardsDistributors: string[]
) => {
let iface = new utils.Interface(
fuse.compoundContracts[
"contracts/RewardsDistributorDelegate.sol:RewardsDistributorDelegate"
].abi
);

console.log({ fuse, address, rewardsDistributors, iface });

const encodedCalls = rewardsDistributors.map((rDAddress: string) => {
// const rd = createRewardsDistributor(rDAddress, fuse);
let iface = new utils.Interface(
fuse.compoundContracts[
"contracts/RewardsDistributorDelegate.sol:RewardsDistributorDelegate"
].abi
);

const callData = iface.encodeFunctionData("claimRewards", [address]);
return [rDAddress, callData];

// return rd.interface.function claimRewards(address);
});


const returnDatas = await sendWithMultiCall(fuse, encodedCalls, address);

console.log({ returnDatas });
Expand Down

1 comment on commit e303967

@vercel
Copy link

@vercel vercel bot commented on e303967 Jun 10, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.