Skip to content

Commit

Permalink
UI bugs (#263)
Browse files Browse the repository at this point in the history
* removing amount pre-population

* ordering active geysers first

* fixed geyser name

* fixed create2Vault tx creation
  • Loading branch information
aalavandhan authored Jan 9, 2025
1 parent 70e1d70 commit 25e0ca0
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 34 deletions.
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

0 comments on commit 25e0ca0

Please sign in to comment.