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

Create a wagmi wrapper so we can move modules under app #389

Closed
wants to merge 1 commit into from
Closed
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
4 changes: 2 additions & 2 deletions apps/beets-frontend-v3/app/(app)/stake/page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use client'

import { Lst } from '@repo/lib/modules/beets/lst/Lst'
import LstProvidersLayout from '@repo/lib/modules/beets/lst/LstProvidersLayout'
import LstProvidersLayout from '@/lib/modules/lst/LstProvidersLayout'
import { Lst } from '@/lib/modules/lst/Lst'

export default function LstPage() {
return (
Expand Down
3 changes: 2 additions & 1 deletion apps/beets-frontend-v3/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ import { DEFAULT_THEME_COLOR_MODE } from '@repo/lib/shared/services/chakra/theme
import { ThemeProvider as ColorThemeProvider } from 'next-themes'
import { ThemeProvider } from '@/lib/services/chakra/ThemeProvider'
import { VebalLockDataProvider } from '@repo/lib/modules/vebal/lock/VebalLockDataProvider'
import { LzBeetsMigrateModal } from '@repo/lib/modules/beets/components/LzBeetsMigrateModal'
import { PoolsNetworkWatcher } from '@/lib/components/navs/PoolsNetworkWatcher'
import { LzBeetsMigrateModal } from '@/lib/components/migrate/LzBeetsMigrateModal'

export const metadata: Metadata = {
title: 'Beets',
description: `The Flagship LST Hub on Sonic. From seamless staking to earning real yield on LST-focused liquidity pools, beets is the ultimate destination for your liquid-staked tokens.`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,15 @@
import { getBlockExplorerTxUrl } from '@repo/lib/shared/hooks/useBlockExplorer'
import { GqlChain } from '@repo/lib/shared/services/api/generated/graphql'
import { bn } from '@repo/lib/shared/utils/numbers'
import { QueryObserverResult } from '@tanstack/react-query'
import Link from 'next/link'
import { useEffect, useState } from 'react'
import { Address, formatUnits } from 'viem'
import { type BaseError, useBalance, useWaitForTransactionReceipt, useWriteContract } from 'wagmi'
import { type BaseError } from 'wagmi'
import {
useBalance,
useWaitForTransactionReceipt,
useWriteContract,
} from '@repo/lib/modules/wagmi/wagmiWrappers'

const sonicChainId = 146
const lzBeetsAddress = '0x1E5fe95fB90ac0530F581C617272cd0864626795'
Expand All @@ -44,7 +48,7 @@
}: {
balance: bigint
isBalancesRefetching: boolean
refetchBalances: () => Promise<QueryObserverResult<unknown, Error>[]>
refetchBalances: () => void
}) {
const { data: hash, writeContract, isPending, error } = useWriteContract()
const { isLoading: isConfirming, isSuccess: isConfirmed } = useWaitForTransactionReceipt({
Expand Down Expand Up @@ -233,7 +237,7 @@
if (hasBalance && !isOpen && shouldShow) {
onOpen()
}
}, [hasBalance, isOpen, shouldShow])

Check warning on line 240 in apps/beets-frontend-v3/lib/components/migrate/LzBeetsMigrateModal.tsx

View workflow job for this annotation

GitHub Actions / Lint

React Hook useEffect has a missing dependency: 'onOpen'. Either include it or remove the dependency array

function handleClose() {
onClose()
Expand All @@ -254,8 +258,8 @@
chain={GqlChain.Sonic}
isLoading={false}
value={balance}
logoURI="https://beethoven-assets.s3.eu-central-1.amazonaws.com/token-stargate-transitonBEETS.svg"

Check warning on line 261 in apps/beets-frontend-v3/lib/components/migrate/LzBeetsMigrateModal.tsx

View workflow job for this annotation

GitHub Actions / Lint

Props should be sorted alphabetically
showZeroAmountAsDash={true}

Check warning on line 262 in apps/beets-frontend-v3/lib/components/migrate/LzBeetsMigrateModal.tsx

View workflow job for this annotation

GitHub Actions / Lint

Props should be sorted alphabetically

Check warning on line 262 in apps/beets-frontend-v3/lib/components/migrate/LzBeetsMigrateModal.tsx

View workflow job for this annotation

GitHub Actions / Lint

Value must be omitted for boolean attributes
/>
</Box>
<Text color="font.secondary">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
import { useGetUserWithdraws, UserWithdraw } from './hooks/useGetUserWithdraws'
import { useGetUserNumWithdraws } from './hooks/useGetUserNumWithdraws'
import { useGetStakedSonicData } from './hooks/useGetStakedSonicData'
import { bn, fNum } from '@repo/lib/shared/utils/numbers'
import { bn, fNum, fNumCustom } from '@repo/lib/shared/utils/numbers'
import { ZenGarden } from '@repo/lib/shared/components/zen/ZenGarden'
import { NoisyCard } from '@repo/lib/shared/components/containers/NoisyCard'
import { LstFaq } from './components/LstFaq'
Expand All @@ -48,8 +48,7 @@
import networkConfigs from '@repo/lib/config/networks'
import { GqlChain } from '@repo/lib/shared/services/api/generated/graphql'
import { Address } from 'viem'
import { TokenIcon } from '../../tokens/TokenIcon'
import numeral from 'numeral'
import { TokenIcon } from '@repo/lib/modules/tokens/TokenIcon'

const CHAIN = GqlChain.Sonic

Expand Down Expand Up @@ -168,7 +167,7 @@
return (
<VStack h="full" w="full">
<CardBody align="start" as={VStack} h="full" w="full">
<Box w="full" h="full">

Check warning on line 170 in apps/beets-frontend-v3/lib/modules/lst/Lst.tsx

View workflow job for this annotation

GitHub Actions / Lint

Props should be sorted alphabetically
<VStack spacing="md" w="full">
<ButtonGroup
currentOption={activeTab}
Expand Down Expand Up @@ -203,15 +202,15 @@
{isStakeTab && !isRateLoading && amountAssets !== '' && (
<LstYouWillReceive
label="You will receive"
amount={getAmountShares(amountAssets)}

Check warning on line 205 in apps/beets-frontend-v3/lib/modules/lst/Lst.tsx

View workflow job for this annotation

GitHub Actions / Lint

Props should be sorted alphabetically
address={stakedAsset?.address || ''}

Check warning on line 206 in apps/beets-frontend-v3/lib/modules/lst/Lst.tsx

View workflow job for this annotation

GitHub Actions / Lint

Props should be sorted alphabetically
symbol={stakedAsset?.symbol || ''}
/>
)}
{isUnstakeTab && !isRateLoading && amountShares !== '' && (
<LstYouWillReceive
label="You can withdraw (after 14 days)"
amount={getAmountAssets(amountShares)}

Check warning on line 213 in apps/beets-frontend-v3/lib/modules/lst/Lst.tsx

View workflow job for this annotation

GitHub Actions / Lint

Props should be sorted alphabetically
address={nativeAsset?.address || ''}
symbol={nativeAsset?.symbol || ''}
/>
Expand Down Expand Up @@ -271,7 +270,7 @@
address: string
symbol: string
}) {
const amountFormatted = numeral(amount).format('0,0.[000000]')
const amountFormatted = fNumCustom(amount, '0,0.[000000]')

return (
<Box w="full">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@ import { useLstStakeStep } from './hooks/useLstStakeStep'
import { GqlChain } from '@repo/lib/shared/services/api/generated/graphql'
import sonicNetworkConfig from '@repo/lib/config/networks/sonic'
import { useLstUnstakeStep } from './hooks/useLstUnstakeStep'
import { useUserAccount } from '../../web3/UserAccountProvider'
import { useUserAccount } from '@repo/lib/modules/web3/UserAccountProvider'
import { LABELS } from '@repo/lib/shared/labels'
import { bn } from '@repo/lib/shared/utils/numbers'
import { isDisabledWithReason } from '@repo/lib/shared/utils/functions/isDisabledWithReason'
import { useTokens } from '../../tokens/TokensProvider'
import { PaginationState } from '@repo/lib/shared/components/pagination/pagination.types'
import { useLstWithdrawStep } from './hooks/useLstWithdrawStep'
import { useTokenInputsValidation } from '../../tokens/TokenInputsValidationProvider'
import { useGetConvertToAssets } from './hooks/useGetConvertToAssets'
import { useGetConvertToShares } from './hooks/useGetConvertToShares'
import { formatUnits, parseUnits } from 'viem'
import { useGetRate } from './hooks/useGetRate'
import { useTokenInputsValidation } from '@repo/lib/modules/tokens/TokenInputsValidationProvider'
import { useTokens } from '@repo/lib/modules/tokens/TokensProvider'

const CHAIN = GqlChain.Sonic
const WITHDRAW_DELAY = 1209600 // 14 days in seconds
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import { getChainId, getNetworkConfig } from '@repo/lib/config/app.config'
import { useChainSwitch } from '@repo/lib/modules/web3/useChainSwitch'
import { useUserAccount } from '@repo/lib/modules/web3/UserAccountProvider'
import { useReadContract } from 'wagmi'
import { sonicStakingAbi } from '@repo/lib/modules/web3/contracts/abi/beets/generated'
import { GqlChain } from '@repo/lib/shared/services/api/generated/graphql'
import { useReadContract } from '@repo/lib/modules/wagmi/wagmiWrappers'

export function useGetConvertToAssets(sharesAmount: bigint, chain: GqlChain) {
const { isConnected } = useUserAccount()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import { getChainId, getNetworkConfig } from '@repo/lib/config/app.config'
import { useChainSwitch } from '@repo/lib/modules/web3/useChainSwitch'
import { useUserAccount } from '@repo/lib/modules/web3/UserAccountProvider'
import { useReadContract } from 'wagmi'
import { sonicStakingAbi } from '@repo/lib/modules/web3/contracts/abi/beets/generated'
import { GqlChain } from '@repo/lib/shared/services/api/generated/graphql'
import { useReadContract } from '@repo/lib/modules/wagmi/wagmiWrappers'

export function useGetConvertToShares(assetAmount: bigint, chain: GqlChain) {
const { isConnected } = useUserAccount()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getChainId, getNetworkConfig } from '@repo/lib/config/app.config'
import { sonicStakingAbi } from '@repo/lib/modules/web3/contracts/abi/beets/generated'
import { useChainSwitch } from '@repo/lib/modules/web3/useChainSwitch'
import { GqlChain } from '@repo/lib/shared/services/api/generated/graphql'
import { useReadContract } from 'wagmi'
import { useReadContract } from '@repo/lib/modules/wagmi/wagmiWrappers'

export function useGetRate(chain: GqlChain) {
const chainId = getChainId(chain)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { getChainId, getNetworkConfig } from '@repo/lib/config/app.config'
import { useChainSwitch } from '@repo/lib/modules/web3/useChainSwitch'
import { useUserAccount } from '@repo/lib/modules/web3/UserAccountProvider'
import { useReadContract } from 'wagmi'
import { useReadContract } from '@repo/lib/modules/wagmi/wagmiWrappers'
import { sonicStakingAbi } from '@repo/lib/modules/web3/contracts/abi/beets/generated'
import { GqlChain } from '@repo/lib/shared/services/api/generated/graphql'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { getChainId, getNetworkConfig } from '@repo/lib/config/app.config'
import { useChainSwitch } from '@repo/lib/modules/web3/useChainSwitch'
import { useUserAccount } from '@repo/lib/modules/web3/UserAccountProvider'
import { useReadContract } from 'wagmi'
import { useReadContract } from '@repo/lib/modules/wagmi/wagmiWrappers'
import { sonicStakingAbi } from '@repo/lib/modules/web3/contracts/abi/beets/generated'
import { GqlChain } from '@repo/lib/shared/services/api/generated/graphql'

Expand Down
3 changes: 3 additions & 0 deletions packages/lib/modules/wagmi/wagmiWrappers.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { useBalance, useWaitForTransactionReceipt, useWriteContract, useReadContract } from 'wagmi'

export { useBalance, useWaitForTransactionReceipt, useWriteContract, useReadContract }
Loading