Skip to content

Commit 79b6725

Browse files
authored
Merge pull request #76 from lidofinance/feature/si-1940-update-tx-modal-texts
Text & tx refetch
2 parents e1e278a + 13b1564 commit 79b6725

File tree

57 files changed

+804
-449
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+804
-449
lines changed

features/adjustment/mint/hooks/use-mint.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,25 @@ import { type Address, encodeFunctionData } from 'viem';
66
import { useSendTransaction, withSuccess } from 'modules/web3';
77

88
import { dashboardAbi } from 'abi/dashboard-abi';
9-
import { useVaultInfo, useVaultPermission } from 'modules/vaults';
9+
import { useVaultInfo, useVaultPermission, vaultTexts } from 'modules/vaults';
1010

1111
import { fallbackedAddress } from 'utils/fallbacked-address';
1212

1313
import { useReportStatus } from 'features/report';
1414
import { GoToVault } from 'modules/vaults/components/go-to-vault';
1515

1616
export const useMint = () => {
17-
const { activeVault } = useVaultInfo();
17+
const { activeVault, refetchVaultInfo } = useVaultInfo();
1818
const { isReportAvailable, prepareReportCall } = useReportStatus();
1919
const { sendTX, ...rest } = useSendTransaction();
2020

2121
return {
2222
mint: useCallback(
23-
async (recipient: Address, amount: bigint, token: string) => {
23+
async (recipient: Address, amount: bigint, token: 'stETH' | 'wstETH') => {
2424
invariant(activeVault?.owner, '[useMint] owner is undefined');
2525

26-
const loadingActionText = `Minting ${token} backed by vault`;
27-
const mainActionCompleteText = `Minted ${token} backed by vault`;
26+
const loadingActionText = vaultTexts.actions.mint.loading(token);
27+
const mainActionCompleteText = vaultTexts.actions.mint.completed(token);
2828

2929
const mintCall = {
3030
to: activeVault.owner,
@@ -53,9 +53,19 @@ export const useMint = () => {
5353
}),
5454
);
5555

56+
if (success) {
57+
await refetchVaultInfo();
58+
}
59+
5660
return success;
5761
},
58-
[activeVault?.owner, prepareReportCall, sendTX, isReportAvailable],
62+
[
63+
activeVault?.owner,
64+
refetchVaultInfo,
65+
prepareReportCall,
66+
sendTX,
67+
isReportAvailable,
68+
],
5969
),
6070
...rest,
6171
};

features/adjustment/mint/mint-form-context/mint-form-provider.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ export const MintFormProvider: FC<{ children: ReactNode }> = ({ children }) => {
6868
invariant(recipient, '[MintFormProvider] recipient is undefined');
6969
invariant(amount, '[MintFormProvider] amount is undefined');
7070
invariant(token, '[MintFormProvider] token is undefined');
71+
invariant(
72+
token === 'stETH' || token === 'wstETH',
73+
'[MintFormProvider] token is invalid',
74+
);
7175

7276
return await mint(recipient, amount, token);
7377
},

features/adjustment/repay/hooks/use-burn.ts

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { useEstimateGas, useAccount } from 'wagmi';
44
import { encodeFunctionData } from 'viem';
55

66
import { dashboardAbi } from 'abi/dashboard-abi';
7-
import { useVaultInfo, useVaultPermission } from 'modules/vaults';
7+
import { useVaultInfo, useVaultPermission, vaultTexts } from 'modules/vaults';
88

99
import {
1010
TransactionEntry,
@@ -15,19 +15,20 @@ import {
1515
import { GoToVault } from 'modules/vaults/components/go-to-vault';
1616

1717
export const useBurn = () => {
18-
const { activeVault } = useVaultInfo();
18+
const { activeVault, refetchVaultInfo } = useVaultInfo();
1919
const { stETH, wstETH } = useLidoSDK();
2020
const { sendTX, ...rest } = useSendTransaction();
2121

2222
return {
2323
burn: useCallback(
24-
async (amount: bigint, token: string) => {
24+
async (amount: bigint, token: 'stETH' | 'wstETH') => {
2525
invariant(activeVault?.owner, '[useMint] owner is undefined');
2626

27-
const loadingActionText = `Repaying ${token}`;
28-
const mainActionCompleteText = `Repaid ${token}`;
27+
const loadingActionText = vaultTexts.actions.repay.loading(token);
28+
const mainActionCompleteText =
29+
vaultTexts.actions.repay.completed(token);
2930

30-
const transactions = async () => {
31+
const prepareTransactions = async () => {
3132
const calls: TransactionEntry[] = [];
3233

3334
const isSteth = token === 'stETH';
@@ -43,7 +44,7 @@ export const useBurn = () => {
4344
amount,
4445
to: activeVault.owner,
4546
})),
46-
loadingActionText: `Approving ${token}`,
47+
loadingActionText: vaultTexts.actions.approve.loading(token),
4748
};
4849
calls.push(approveCall);
4950
}
@@ -61,17 +62,21 @@ export const useBurn = () => {
6162

6263
const { success } = await withSuccess(
6364
sendTX({
64-
transactions,
65+
transactions: prepareTransactions,
6566
forceAtomic: true,
6667
mainActionLoadingText: loadingActionText,
6768
mainActionCompleteText,
6869
renderSuccessContent: GoToVault,
6970
}),
7071
);
7172

73+
if (success) {
74+
await refetchVaultInfo();
75+
}
76+
7277
return success;
7378
},
74-
[activeVault?.owner, sendTX, stETH, wstETH],
79+
[activeVault?.owner, refetchVaultInfo, sendTX, stETH, wstETH],
7580
),
7681
...rest,
7782
};

features/adjustment/repay/repay-form-context/repay-form-provider.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,10 @@ export const RepayFormProvider = ({ children }: { children: ReactNode }) => {
9393
if (!amount || !token) return false;
9494

9595
invariant(amount, '[RepayFormProvider] amount is undefined');
96-
invariant(token, '[RepayFormProvider] token is undefined');
96+
invariant(
97+
token === 'stETH' || token === 'wstETH',
98+
'[RepayFormProvider] token is invalid',
99+
);
97100

98101
return await burn(amount, token);
99102
},

features/claim/claim-form/hooks/use-claim.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { useEstimateGas, useAccount } from 'wagmi';
33
import { Address, encodeFunctionData } from 'viem';
44

55
import { dashboardAbi } from 'abi/dashboard-abi';
6-
import { useVaultInfo, useVaultPermission } from 'modules/vaults';
6+
import { useVaultInfo, useVaultPermission, vaultTexts } from 'modules/vaults';
77
import invariant from 'tiny-invariant';
88
import { fallbackedAddress } from 'utils/fallbacked-address';
99
import { useSendTransaction, withSuccess } from 'modules/web3';
1010
import { GoToVault } from 'modules/vaults/components/go-to-vault';
1111

1212
export const useClaim = () => {
13-
const { activeVault } = useVaultInfo();
13+
const { activeVault, refetchVaultInfo } = useVaultInfo();
1414
const owner = activeVault?.owner;
1515
const { sendTX, ...rest } = useSendTransaction();
1616

@@ -19,8 +19,8 @@ export const useClaim = () => {
1919
async (recipient: Address) => {
2020
invariant(owner, '[useClaim] owner is undefined');
2121

22-
const loadingActionText = `Claiming node operator fee`;
23-
const mainActionCompleteText = `Claimed node operator fee`;
22+
const loadingActionText = vaultTexts.actions.claim.loading;
23+
const mainActionCompleteText = vaultTexts.actions.claim.completed;
2424

2525
const claimCall = {
2626
to: owner,
@@ -41,9 +41,13 @@ export const useClaim = () => {
4141
}),
4242
);
4343

44+
if (success) {
45+
await refetchVaultInfo();
46+
}
47+
4448
return success;
4549
},
46-
[owner, sendTX],
50+
[owner, refetchVaultInfo, sendTX],
4751
),
4852
...rest,
4953
};

features/create-vault/consts.ts

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
import { vaultTexts } from 'modules/vaults';
12
import { MainSettingsEntryType } from './types';
23

34
export enum CREATE_VAULT_FORM_STEPS {
45
main = 1,
56
confirm,
67
}
78

8-
const steps = ['Main settings', 'Verify new vault’s settings'];
9+
const steps = vaultTexts.actions.createVault.steps;
910

1011
export const SECTION_NAMES_BY_STEP = steps.reduce(
1112
(acc, step, index) => ({
@@ -17,43 +18,39 @@ export const SECTION_NAMES_BY_STEP = steps.reduce(
1718

1819
export const CREATE_VAULT_STEPS = steps.length;
1920

21+
const texts = vaultTexts.actions.createVault.fields;
22+
2023
export const MAIN_SETTINGS: MainSettingsEntryType[] = [
2124
{
2225
name: 'nodeOperator',
23-
title: 'Node Operator',
24-
label: 'Node Operator address',
25-
notes: 'Node Operator address cannot be changed after the vault is created',
2626
dataType: 'address',
27+
...texts.nodeOperator,
2728
},
2829
{
2930
name: 'nodeOperatorFeeBP',
30-
title: 'Node Operator fee',
31-
label: 'Node Operator fee, %',
3231
dataType: 'percent',
3332
type: 'number',
33+
...texts.nodeOperatorFee,
3434
},
3535
{
3636
name: 'confirmExpiry',
37-
title: 'Confirmation Lifetime',
38-
label: 'Confirmation Lifetime, hours',
3937
dataType: 'time',
4038
type: 'number',
39+
...texts.confirmationLifetime,
4140
},
4241
{
4342
name: 'vaultManager',
44-
title: 'Vault Manager',
45-
label: 'Vault Manager address',
4643
dataType: 'addressArray',
44+
...texts.vaultManager,
4745
},
4846
{
4947
name: 'nodeOperatorManager',
50-
title: 'Node Operator Manager',
51-
label: 'Node Operator Manager address',
5248
dataType: 'address',
49+
...texts.nodeOperatorManager,
5350
},
5451
{
5552
name: 'acceptTerms',
56-
notes: 'Vault creation requires a supply of 1 ETH.',
5753
dataType: 'confirm',
54+
...texts.acceptTerms,
5855
},
5956
];
Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import { FC } from 'react';
1+
import type { FC } from 'react';
22

3-
import { SomeFaqItem, AnotherFaqItem } from './list';
4-
import { Wrapper } from './styles';
3+
import { FAQ } from 'shared/components/faq';
4+
5+
import { FeeStructure, Roles } from './items';
56

67
export const CreateVaultFaq: FC = () => {
78
return (
8-
<Wrapper title="FAQ">
9-
<SomeFaqItem />
10-
<AnotherFaqItem />
11-
</Wrapper>
9+
<FAQ.List>
10+
<Roles defaultExpanded />
11+
<FeeStructure />
12+
</FAQ.List>
1213
);
1314
};
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import type { FC } from 'react';
2+
import { FAQ, FAQComponentProps } from 'shared/components/faq';
3+
4+
export const FeeStructure: FC<FAQComponentProps> = ({ defaultExpanded }) => {
5+
return (
6+
<FAQ.Item title="Fee structure" defaultExpanded={defaultExpanded}>
7+
There are two main fees applied on the vault:
8+
<ul>
9+
<li>Node Operator Fee</li>
10+
<li>Lido Fees</li>
11+
</ul>
12+
<p>
13+
The validation rewards receiving by the vault are subject to the Node
14+
Operator Fee.
15+
</p>
16+
<p>
17+
Node Operator Fee is not therefore deducted from the rewards
18+
automatically, but remain part of validators balance and vault balance
19+
as they are received. The accumulated Node Operator Fee is counted and
20+
reported by the Oracle regularly, and locked for the withdrawn by the
21+
Vault Owner so that only Node Operator representative can claim it.
22+
</p>
23+
Lido fees consist of two potential parts depending on the stVault selected
24+
tier:
25+
<ul>
26+
<li>
27+
Infrastructure fee, charged for using the stVaults infrastructure.
28+
Calculated from the stVault’s total value.
29+
</li>
30+
<li>
31+
Liquidity fee, charged for actual liquidity usage. Calculated from the
32+
stETH liability.
33+
</li>
34+
</ul>
35+
<p>
36+
Lido fees amount is locked for the withdrawn by the Vault Owner and
37+
claimed automatically from the vault contract balance within the Oracle
38+
report applying.
39+
</p>
40+
</FAQ.Item>
41+
);
42+
};
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './roles';
2+
export * from './fee-structure';
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import type { FC } from 'react';
2+
import { FAQ, FAQComponentProps } from 'shared/components/faq';
3+
4+
export const Roles: FC<FAQComponentProps> = ({ defaultExpanded }) => {
5+
return (
6+
<FAQ.Item title="Roles" defaultExpanded={defaultExpanded}>
7+
There are three main roles in the stVault:
8+
<ol>
9+
<li>
10+
<strong>Node Operator:</strong> provides validation service for the
11+
vault: handles depositing ETH from the vault balance to validators and
12+
exiting validators if necessary. Address of the Node Operator can’t be
13+
changed after the vault is created.
14+
</li>
15+
<li>
16+
<strong>Vault Owner:</strong> is one of the two admin roles for the
17+
stVault, allows to manage permissions and change key vault parameters
18+
from the Vault Owner (Staker) perspective. Multiple addresses
19+
supported.
20+
</li>
21+
<li>
22+
<strong>Node Operator Manager:</strong> is another of the two admin
23+
roles for the stVault, allows to manage permissions and change key
24+
vault parameters from the Node Operator perspective. Multiple
25+
addresses supported.
26+
</li>
27+
</ol>
28+
</FAQ.Item>
29+
);
30+
};

0 commit comments

Comments
 (0)