File tree Expand file tree Collapse file tree
features/adjustment/mint/form/submit-button Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { useVaultInfo , type VAULT_OWNER_ROLES } from 'modules/vaults' ;
2- import { MultiplePermissionedSubmitButton } from 'modules/vaults/components' ;
2+ import {
3+ MultiplePermissionedSubmitButton ,
4+ OracleReportButton ,
5+ } from 'modules/vaults/components' ;
36import { useMemo } from 'react' ;
47import { useFormContext , useWatch } from 'react-hook-form' ;
58
@@ -20,6 +23,7 @@ export const SubmitButton = () => {
2023 name : [ 'amount' , 'token' ] ,
2124 } ) ;
2225
26+ // TODO: move this check to upper context
2327 const roles : VAULT_OWNER_ROLES [ ] = useMemo ( ( ) => {
2428 if ( ! activeVault || ! amount ) return NON_INCREASE_LOCK_ROLES ;
2529 const isSteth = token === 'stETH' ;
@@ -37,12 +41,14 @@ export const SubmitButton = () => {
3741 const disabled = isSubmitting && ! isValid ;
3842
3943 return (
40- < MultiplePermissionedSubmitButton
41- dashboardRoles = { roles }
42- type = "submit"
43- disabled = { disabled }
44- >
45- Mint
46- </ MultiplePermissionedSubmitButton >
44+ < OracleReportButton >
45+ < MultiplePermissionedSubmitButton
46+ dashboardRoles = { roles }
47+ type = "submit"
48+ disabled = { disabled }
49+ >
50+ Mint
51+ </ MultiplePermissionedSubmitButton >
52+ </ OracleReportButton >
4753 ) ;
4854} ;
Original file line number Diff line number Diff line change 22 PermissionedSubmitButton ,
33 MultiplePermissionedSubmitButton ,
44} from './permissioned-submit-button' ;
5+ export { OracleReportButton } from './oracle-report-button' ;
Original file line number Diff line number Diff line change 1+ import { Button } from '@lidofinance/lido-ui' ;
2+ import { useReportStatus } from '../hooks' ;
3+
4+ export type OracleReportButtonProps = React . PropsWithChildren < {
5+ ensureFreshReport ?: boolean ;
6+ } > ;
7+
8+ export const OracleReportButton = ( {
9+ ensureFreshReport = true ,
10+ children,
11+ } : OracleReportButtonProps ) => {
12+ const { shouldApplyReport } = useReportStatus ( ) ;
13+
14+ if ( shouldApplyReport && ensureFreshReport ) {
15+ return < Button > Apply Oracle Report</ Button > ;
16+ }
17+
18+ return < > { children } </ > ;
19+ } ;
Original file line number Diff line number Diff line change @@ -76,12 +76,12 @@ export const useReportStatus = () => {
7676 query : { ...STRATEGY_EAGER } ,
7777 } ) ;
7878
79- const shouldSkipCheck = ! ! ( time == null || report . data ) ;
79+ const shouldSkipCheck = ! ! ( time == null || ! report . data ) ;
8080
8181 // optimistically say the report is fresh if we don't have data just yet
8282 const isReportFresh =
83- shouldSkipCheck &&
84- Number ( report . data ? .timestamp ) + reportFreshnessDelta < time ! ;
83+ shouldSkipCheck ||
84+ time - Number ( report . data . timestamp ) < reportFreshnessDelta ;
8585
8686 const isReportAvailable =
8787 report . data && vaultHubReport . data
@@ -90,12 +90,13 @@ export const useReportStatus = () => {
9090
9191 // when new report is available but old is still fresh
9292 // we can show suggestive reporting UI
93- const shouldApplyReport =
93+ const shouldApplyReport = ! ! (
9494 isReportAvailable &&
9595 time &&
9696 report . data &&
97- ( time - Number ( report . data . timestamp ) ) / reportFreshnessDelta >
98- VAULT_SHOULD_REPORT_THRESHOLD ;
97+ ( time - Number ( report . data . timestamp ) ) / reportFreshnessDelta >=
98+ VAULT_SHOULD_REPORT_THRESHOLD
99+ ) ;
99100
100101 return {
101102 ...report ,
Original file line number Diff line number Diff line change @@ -2,3 +2,4 @@ export * from './consts';
22export * from './hooks' ;
33export * from './contracts/weth' ;
44export * from './vault-context' ;
5+ export * from './components' ;
You can’t perform that action at this time.
0 commit comments