@@ -70,13 +70,18 @@ export const GeyserStakeView = () => {
70
70
useEffect ( ( ) => {
71
71
refreshInputAmount ( )
72
72
if ( geyserAction === GeyserAction . STAKE && stakingTokenInfo . price > 0 ) {
73
- const initialStakeAmountUSD = 1000
74
- const stakeAmt = Math . max ( initialStakeAmountUSD / stakingTokenInfo . price , 0.000001 )
75
- const stakeAmtFP = parseUnits ( stakeAmt . toFixed ( stakingTokenInfo . decimals ) , stakingTokenInfo . decimals )
76
- setUserInput ( stakeAmt )
77
- setParsedUserInput ( BigNumber . from ( stakeAmtFP ) )
73
+ if ( stakableAmount . eq ( 0 ) ) {
74
+ const initialStakeAmountUSD = 1000
75
+ const stakeAmt = Math . max ( initialStakeAmountUSD / stakingTokenInfo . price , 0.000001 )
76
+ const stakeAmtFP = parseUnits ( stakeAmt . toFixed ( stakingTokenInfo . decimals ) , stakingTokenInfo . decimals )
77
+ setUserInput ( stakeAmt )
78
+ setParsedUserInput ( BigNumber . from ( stakeAmtFP ) )
79
+ } else {
80
+ setUserInput ( formatUnits ( stakableAmount , stakingTokenDecimals ) )
81
+ setParsedUserInput ( stakableAmount )
82
+ }
78
83
}
79
- } , [ geyserAction ] )
84
+ } , [ geyserAction , stakingTokenBalance , currentStakeable ] )
80
85
81
86
const handleGeyserInteraction = ( ) => {
82
87
if ( geyserAction === GeyserAction . STAKE ) {
@@ -182,7 +187,7 @@ export const GeyserStakeView = () => {
182
187
< EstimatedRewards parsedUserInput = { parsedUserInput } />
183
188
{ ! address && < ConnectWalletWarning onClick = { ( ) => connectWallet ( ) } /> }
184
189
{ address && parsedUserInput . gt ( 0 ) && (
185
- < StakeWarning link = { poolAddress } balance = { stakableAmount } staked = { currentStakeAmount } />
190
+ < StakeWarning link = { poolAddress } balance = { stakableAmount . sub ( parsedUserInput ) } staked = { currentStakeAmount } />
186
191
) }
187
192
< GeyserInteractionButton
188
193
disabled = { ! address || parsedUserInput . isZero ( ) || parsedUserInput . gt ( stakableAmount ) }
0 commit comments