Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UI bugs #263

Merged
merged 4 commits into from
Jan 9, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 27 additions & 22 deletions frontend/src/components/GeyserFirst/GeyserStakeView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,31 +66,36 @@ export const GeyserStakeView = () => {
setParsedUserInput(BigNumber.from('0'))
}

const setDefaultInputAmount = () => {
if (stakingTokenInfo.price > 0) {
const initialStakeAmountUSD = 1000
const stakeAmt = Math.max(initialStakeAmountUSD / stakingTokenInfo.price, 0.0000001).toFixed(
stakingTokenInfo.decimals,
)
const stakeAmtFP = parseUnits(stakeAmt, stakingTokenInfo.decimals)
setUserInput(stakeAmt)
setParsedUserInput(BigNumber.from(stakeAmtFP))
}
}
// NOTE: Disabling pre-populating, because some users find it confusing
// TODO: Remove entirely.
// const setDefaultInputAmount = () => {
// if (stakingTokenInfo.price > 0) {
// const initialStakeAmountUSD = 1000
// const stakeAmt = Math.max(initialStakeAmountUSD / stakingTokenInfo.price, 0.0000001).toFixed(
// stakingTokenInfo.decimals,
// )
// const stakeAmtFP = parseUnits(stakeAmt, stakingTokenInfo.decimals)
// setUserInput(stakeAmt)
// setParsedUserInput(BigNumber.from(stakeAmtFP))
// }
// }
// useEffect(() => {
// refreshInputAmount()
// if (geyserAction === GeyserAction.STAKE) {
// if (!ready) {
// setDefaultInputAmount()
// } else if (currentStakeAmount.eq(0) && stakableAmount.eq(0)) {
// setDefaultInputAmount()
// } else if (ready && currentStakeAmount.eq(0) && stakableAmount.gt(0)) {
// setUserInput(formatUnits(stakableAmount, stakingTokenDecimals))
// setParsedUserInput(stakableAmount)
// }
// }
// }, [ready, geyserAction, stakingTokenBalance, currentStakeable])

useEffect(() => {
refreshInputAmount()
if (geyserAction === GeyserAction.STAKE) {
if (!ready) {
setDefaultInputAmount()
} else if (currentStakeAmount.eq(0) && stakableAmount.eq(0)) {
setDefaultInputAmount()
} else if (currentStakeAmount.eq(0) && stakableAmount.gt(0)) {
setUserInput(formatUnits(stakableAmount, stakingTokenDecimals))
setParsedUserInput(stakableAmount)
}
}
}, [ready, geyserAction, stakingTokenBalance, currentStakeable])
}, [geyserAction])

const handleGeyserInteraction = () => {
if (geyserAction === GeyserAction.STAKE) {
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ export const Home = () => {
if (geysersToShow.length === 0) {
geysersToShow = geyserData.slice(0, 3)
}
geysersToShow = geysersToShow.sort((g1, g2) => g2.active - g1.active)

return (
<Container>
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/config/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ const geyserList: AppGeysersList = {
// },

{
name: 'Riverside I (STAMPL)',
name: 'Riverside I (stAMPL)',
address: '0xa19604b951592170DDa857CBE46609B85AB00Dee',
stakingToken: StakingToken.STAMPL,
rewardToken: RewardToken.FORTH,
Expand Down
15 changes: 4 additions & 11 deletions frontend/src/sdk/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -129,16 +129,13 @@ export const approveCreateDepositStake = async (geyserAddress: string, amount: B
const token = new Contract(tokenAddress, ERC20_ABI, signer)

const salt = randomBytes(32)
const vaultAddress = await router.callStatic.create2Vault(
config.VaultFactory.address,
salt,
await signer.getAddress(),
)
const vaultAddress = await router.connect(signer).callStatic.create2Vault(config.VaultFactory.address, salt)

const vault = new Contract(vaultAddress, config.VaultTemplate.abi, signer)
const lockPermission = await signPermission('Lock', vault, signer, geyserAddress, token.address, amount, '0')
const args = [geyserAddress, config.VaultFactory.address, await signer.getAddress(), amount, salt, lockPermission]

const allowance = await token.allowance(signer.getAddress(), router.address)
const allowance = await token.allowance(await signer.getAddress(), router.address)
if (allowance.lt(amount)) {
await (await token.approve(router.address, amount)).wait()
}
Expand Down Expand Up @@ -190,11 +187,7 @@ export const permitCreateDepositStake = async (geyserAddress: string, amount: Bi
}

const salt = randomBytes(32)
const vaultAddress = await router.callStatic.create2Vault(
config.VaultFactory.address,
salt,
await signer.getAddress(),
)
const vaultAddress = await router.connect(signer).callStatic.create2Vault(config.VaultFactory.address, salt)
const vault = new Contract(vaultAddress, config.VaultTemplate.address, signer)

const permit = await signPermitEIP2612(signer, tokenAddress, router.address, amount, deadline)
Expand Down
Loading