Skip to content

Commit

Permalink
SOV-2807: fix outdated vesting fee tx estimates (#2565)
Browse files Browse the repository at this point in the history
* fix: outdated vesting fee tx estimates

* chore: resolve review comment
  • Loading branch information
soulBit authored Jul 20, 2023
1 parent 686ed06 commit 7606c0e
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 15 deletions.
30 changes: 18 additions & 12 deletions src/app/components/UserAssets/Vesting/VestingWithdrawForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { VestingUnlockScheduleDialog } from './VestingUnlockScheduleDialog';
import { gasLimit } from 'utils/classifiers';
import { TransactionDialog } from 'app/components/TransactionDialog';
import { Icon } from 'app/components/Icon';
import { TxFeeCalculator } from 'app/pages/MarginTradePage/components/TxFeeCalculator';

type VestingWithdrawFormProps = {
vesting: FullVesting;
Expand Down Expand Up @@ -50,18 +51,19 @@ export const VestingWithdrawForm: React.FC<VestingWithdrawFormProps> = ({
[vesting],
);

const txConfig = useMemo(
() => ({
from: account,
gas: gasLimit[vestingTxType],
}),
[account, vestingTxType],
);

const handleSubmit = useCallback(() => {
if (!tx.loading) {
send(
[address.toLowerCase()],
{
from: account,
gas: gasLimit[vestingTxType],
},
{ type: vestingTxType },
);
send([address.toLowerCase()], txConfig, { type: vestingTxType });
}
}, [account, address, send, tx, vestingTxType]);
}, [address, send, tx, vestingTxType, txConfig]);

const [scheduleOpen, setScheduleOpen] = useState(false);
const openSchedule = useCallback(event => {
Expand Down Expand Up @@ -119,9 +121,13 @@ export const VestingWithdrawForm: React.FC<VestingWithdrawFormProps> = ({
/>
</FieldGroup>

<div className="tw-text-white tw-text-sm tw-font-normal tw-mx-9 tw-my-5">
{t(translations.common.fee, { amount: '0.000019' })}
</div>
<TxFeeCalculator
args={[address.toLowerCase()]}
txConfig={txConfig}
methodName="withdrawTokens"
contractName="vesting"
className="tw-my-5"
/>
</div>

<div className="tw-flex tw-flex-row tw-justify-between tw-items-center">
Expand Down
9 changes: 6 additions & 3 deletions src/app/containers/StakePage/components/VestingContract.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ const getTokenContractNameByVestingType = (type: VestGroup) => {
}
};

const withdrawTxConfig = {
gas: gasLimit[TxType.SOV_WITHDRAW_VESTING],
};

export const VestingContract: React.FC<IVestingContractProps> = ({
vestingAddress,
type,
Expand Down Expand Up @@ -187,9 +191,7 @@ export const VestingContract: React.FC<IVestingContractProps> = ({

const handleWithdraw = useCallback(
(receiver: string) => {
send([receiver], {
gas: gasLimit[TxType.SOV_WITHDRAW_VESTING],
});
send([receiver], withdrawTxConfig);
},
[send],
);
Expand Down Expand Up @@ -366,6 +368,7 @@ export const VestingContract: React.FC<IVestingContractProps> = ({
vestingType={type}
onCloseModal={() => setShowWithdraw(false)}
onWithdraw={handleWithdraw}
txConfig={withdrawTxConfig}
/>
</>
}
Expand Down
4 changes: 4 additions & 0 deletions src/app/containers/StakePage/components/WithdrawVesting.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,22 @@ import { discordInvite } from 'utils/classifiers';
import { useMaintenance } from 'app/hooks/useMaintenance';
import { ErrorBadge } from 'app/components/Form/ErrorBadge';
import { VestGroup } from 'app/components/UserAssets/Vesting/types';
import type { TransactionConfig } from 'web3-core';

interface IWithdrawVestingProps {
vesting: string;
vestingType: VestGroup;
onCloseModal: () => void;
onWithdraw: (receiver: string) => void;
txConfig: TransactionConfig;
}

export const WithdrawVesting: React.FC<IWithdrawVestingProps> = ({
vesting,
vestingType,
onCloseModal,
onWithdraw,
txConfig,
}) => {
const { t } = useTranslation();
const account = useAccount();
Expand Down Expand Up @@ -87,6 +90,7 @@ export const WithdrawVesting: React.FC<IWithdrawVestingProps> = ({
</div>
<TxFeeCalculator
args={[address.toLowerCase()]}
txConfig={txConfig}
methodName="withdrawTokens"
contractName="vesting"
/>
Expand Down

0 comments on commit 7606c0e

Please sign in to comment.