From f08e4fd4a3dc1725a424da0d741147aa4e41a761 Mon Sep 17 00:00:00 2001 From: Daniel Simon <60874270+danielattilasimon@users.noreply.github.com> Date: Wed, 22 Jan 2025 17:11:25 +0700 Subject: [PATCH] fix: not being able to claim from V1 staking (#739) * fix: not being able to claim from V1 staking * chore: clarify TX param * fix: error when reloading the app at /stake/rewards --- .../app/src/screens/StakeScreen/PanelRewards.tsx | 12 ++++++------ frontend/app/src/tx-flows/stakeClaimRewards.tsx | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/frontend/app/src/screens/StakeScreen/PanelRewards.tsx b/frontend/app/src/screens/StakeScreen/PanelRewards.tsx index 5007085d4..712ad81da 100644 --- a/frontend/app/src/screens/StakeScreen/PanelRewards.tsx +++ b/frontend/app/src/screens/StakeScreen/PanelRewards.tsx @@ -15,7 +15,7 @@ import { useTransactionFlow } from "@/src/services/TransactionFlow"; import { css } from "@/styled-system/css"; import { Button, HFlex, TokenIcon, VFlex } from "@liquity2/uikit"; import * as dn from "dnum"; -import { encodeFunctionData } from "viem"; +import { encodeFunctionData, zeroAddress } from "viem"; import { useEstimateGas, useGasPrice } from "wagmi"; export function PanelRewards() { @@ -26,16 +26,16 @@ export function PanelRewards() { const ethPrice = usePrice("ETH"); const stakePosition = useStakePosition(account.address ?? null); - const LqtyStaking = getProtocolContract("LqtyStaking"); + const Governance = getProtocolContract("Governance"); const gasEstimate = useEstimateGas({ account: account.address, data: encodeFunctionData({ - abi: LqtyStaking.abi, - functionName: "unstake", - args: [0n], + abi: Governance.abi, + functionName: "claimFromStakingV1", + args: [account.address ?? zeroAddress], // address to receive the payout }), - to: LqtyStaking.address, + to: Governance.address, }); const gasPrice = useGasPrice(); diff --git a/frontend/app/src/tx-flows/stakeClaimRewards.tsx b/frontend/app/src/tx-flows/stakeClaimRewards.tsx index 1fb93c8f6..30af9981c 100644 --- a/frontend/app/src/tx-flows/stakeClaimRewards.tsx +++ b/frontend/app/src/tx-flows/stakeClaimRewards.tsx @@ -85,11 +85,11 @@ export const stakeClaimRewards: FlowDeclaration = { name: () => "Claim rewards", Status: TransactionStatus, - async commit({ contracts, wagmiConfig }) { + async commit({ contracts, wagmiConfig, request }) { return writeContract(wagmiConfig, { - ...contracts.LqtyStaking, - functionName: "unstake", - args: [0n], + ...contracts.Governance, + functionName: "claimFromStakingV1", + args: [request.stakePosition.owner], // address to receive the payout }); },