@@ -67,23 +67,29 @@ export const GeyserStakeView = () => {
67
67
setParsedUserInput ( BigNumber . from ( '0' ) )
68
68
}
69
69
70
+ const setDefaultInputAmount = ( ) => {
71
+ if ( stakingTokenInfo . price > 0 ) {
72
+ const initialStakeAmountUSD = 1000
73
+ const stakeAmt = Math . max ( initialStakeAmountUSD / stakingTokenInfo . price , 0.000001 )
74
+ const stakeAmtFP = parseUnits ( stakeAmt . toFixed ( stakingTokenInfo . decimals ) , stakingTokenInfo . decimals )
75
+ setUserInput ( stakeAmt )
76
+ setParsedUserInput ( BigNumber . from ( stakeAmtFP ) )
77
+ }
78
+ }
79
+
70
80
useEffect ( ( ) => {
71
81
refreshInputAmount ( )
72
- if ( geyserAction === GeyserAction . STAKE && stakingTokenInfo . price > 0 ) {
73
- if ( currentStakeAmount . eq ( 0 ) ) {
74
- if ( stakableAmount . gt ( 0 ) ) {
75
- setUserInput ( formatUnits ( stakableAmount , stakingTokenDecimals ) )
76
- setParsedUserInput ( stakableAmount )
77
- } else {
78
- const initialStakeAmountUSD = 1000
79
- const stakeAmt = Math . max ( initialStakeAmountUSD / stakingTokenInfo . price , 0.000001 )
80
- const stakeAmtFP = parseUnits ( stakeAmt . toFixed ( stakingTokenInfo . decimals ) , stakingTokenInfo . decimals )
81
- setUserInput ( stakeAmt )
82
- setParsedUserInput ( BigNumber . from ( stakeAmtFP ) )
83
- }
82
+ if ( geyserAction === GeyserAction . STAKE ) {
83
+ if ( ! address ) {
84
+ setDefaultInputAmount ( )
85
+ } else if ( currentStakeAmount . eq ( 0 ) && stakableAmount . eq ( 0 ) ) {
86
+ setDefaultInputAmount ( )
87
+ } else if ( currentStakeAmount . eq ( 0 ) && stakableAmount . gt ( 0 ) ) {
88
+ setUserInput ( formatUnits ( stakableAmount , stakingTokenDecimals ) )
89
+ setParsedUserInput ( stakableAmount )
84
90
}
85
91
}
86
- } , [ geyserAction , stakingTokenBalance , currentStakeable ] )
92
+ } , [ address , geyserAction , stakingTokenBalance , currentStakeable ] )
87
93
88
94
const handleGeyserInteraction = ( ) => {
89
95
if ( geyserAction === GeyserAction . STAKE ) {
0 commit comments