Skip to content

Commit

Permalink
Missed fields in Pools
Browse files Browse the repository at this point in the history
  • Loading branch information
abtestingalpha committed Sep 4, 2024
1 parent 8d60e51 commit 62a1334
Show file tree
Hide file tree
Showing 10 changed files with 143 additions and 33 deletions.
33 changes: 32 additions & 1 deletion packages/synapse-interface/messages/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,38 @@
"Completed withdrawal": "Completed withdrawal",
"Successfully approved on": "Successfully approved on",
"Stake completed": "Stake completed",
"Liquidity added": "Liquidity added"
"Liquidity added": "Liquidity added",
"Your balances": "Your balances",
"DepositButton": {
"insufficientBalance": "Insufficient Balance",
"connectWallet": "Connect Wallet to Bridge",
"switchChain": "Switch to {chainName}",
"switchingChains": "Switching chains",
"approveTokens": "Approve Token(s)",
"approving": "Approving",
"deposit": "Deposit",
"depositing": "Depositing"
},
"WithdrawButton": {
"insufficientBalance": "Insufficient Balance",
"connectWallet": "Connect Wallet to Bridge",
"switchChain": "Switch to {chainName}",
"switchingChains": "Switching chains",
"approveToken": "Approve Token",
"approving": "Approving",
"withdraw": "Withdraw",
"withdrawing": "Withdrawing..."
},
"Other": {
"Bonus": "Bonus",
"Price impact": "Price impact",
"Currency Reserves": "Currency Reserves",
"Pool Info": "Pool Info ",
"Trading Fee": "Trading Fee",
"Virtual Price": "Virtual Price",
"Total Liquidity": "Total Liquidity",
"Total Liquidity USD": "Total Liquidity USD"
}
},
"Portfolio": {
"Portfolio": "Portfolio",
Expand Down
33 changes: 32 additions & 1 deletion packages/synapse-interface/messages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,38 @@
"Completed withdrawal": "Retrait terminé",
"Successfully approved on": "Approuvé avec succès sur",
"Stake completed": "Stake terminé",
"Liquidity added": "Liquidité ajoutée"
"Liquidity added": "Liquidité ajoutée",
"Your balances": "Vos soldes",
"DepositButton": {
"insufficientBalance": "Solde insuffisant",
"connectWallet": "Connecter le portefeuille pour transférer",
"switchChain": "Passer à {chainName}",
"switchingChains": "Changement de chaîne en cours",
"approveTokens": "Approuver le(s) jeton(s)",
"approving": "Approbation en cours",
"deposit": "Déposer",
"depositing": "Dépôt en cours"
},
"WithdrawButton": {
"insufficientBalance": "Solde insuffisant",
"connectWallet": "Connecter le portefeuille pour transférer",
"switchChain": "Passer à {chainName}",
"switchingChains": "Changement de chaîne en cours",
"approveToken": "Approuver le jeton",
"approving": "Approbation en cours",
"withdraw": "Retirer",
"withdrawing": "Retrait en cours..."
},
"Other": {
"Bonus": "Bonus",
"Price impact": "Impact du prix",
"Currency Reserves": "Réserves monétaires",
"Pool Info": "Informations sur le pool",
"Trading Fee": "Frais de trading",
"Virtual Price": "Prix virtuel",
"Total Liquidity": "Liquidité totale",
"Total Liquidity USD": "Liquidité totale USD"
}
},
"Portfolio": {
"Portfolio": "Portefeuille",
Expand Down
33 changes: 32 additions & 1 deletion packages/synapse-interface/messages/lorem-ipsum.json
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,38 @@
"Completed withdrawal": "Retractio perfecta",
"Successfully approved on": "Felix approbatus in",
"Stake completed": "Ponus perfectus",
"Liquidity added": "Liquoritas addita"
"Liquidity added": "Liquoritas addita",
"Your balances": "Tua balanea",
"DepositButton": {
"insufficientBalance": "Lorem ipsum dolor",
"connectWallet": "Connectere crumenam ad pontem",
"switchChain": "Muta ad {chainName}",
"switchingChains": "Mutans catenas",
"approveTokens": "Approbare symbolum(a)",
"approving": "Approbans",
"deposit": "Deponere",
"depositing": "Deponens"
},
"WithdrawButton": {
"insufficientBalance": "Lorem ipsum dolor",
"connectWallet": "Connectere crumenam ad pontem",
"switchChain": "Muta ad {chainName}",
"switchingChains": "Mutans catenas",
"approveToken": "Approbare symbolum",
"approving": "Approbans",
"withdraw": "Retrahere",
"withdrawing": "Retrahens..."
},
"Other": {
"Bonus": "Bonus",
"Price impact": "Impetus Pretii",
"Currency Reserves": "Reservae Monetariae",
"Pool Info": "Piscinae Info",
"Trading Fee": "Trading Fee",
"Virtual Price": "Virtualis Pretium",
"Total Liquidity": "Liquidité totale",
"Total Liquidity USD": "Liquidité totale USD"
}
},
"Portfolio": {
"Portfolio": "Portitio",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import numeral from 'numeral'
import { useSelector } from 'react-redux'
import { useTranslations } from 'next-intl'

import InfoSectionCard from './InfoSectionCard'
import { RootState } from '@/store/store'
Expand Down Expand Up @@ -47,8 +48,10 @@ const TokenLabels = ({ tokens }) => {
const CurrencyReservesCard = () => {
const { poolData } = useSelector((state: RootState) => state.poolData)

const t = useTranslations('Pools.Other')

return (
<InfoSectionCard title="Currency Reserves">
<InfoSectionCard title={t('Currency Reserves')}>
{poolData ? <TokenLabels tokens={poolData.tokens} /> : null}
</InfoSectionCard>
)
Expand Down
14 changes: 9 additions & 5 deletions packages/synapse-interface/pages/pool/PoolInfoSection/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import numeral from 'numeral'
import { useTranslations } from 'next-intl'

import AugmentWithUnits from '../components/AugmentWithUnits'
import InfoSectionCard from './InfoSectionCard'
import CurrencyReservesCard from './CurrencyReservesCard'
Expand All @@ -12,14 +14,16 @@ import { usePoolDataState } from '@/slices/pools/hooks'
const PoolInfoSection = () => {
const { pool, poolData, isLoading } = usePoolDataState()

const t = useTranslations('Pools.Other')

const usdFormat = poolData.totalLockedUSD > 1000000 ? '$0,0.0' : '$0,0'

return (
<div className="space-y-4">
<CurrencyReservesCard />
<InfoSectionCard title="Pool Info">
<InfoSectionCard title={t('Pool Info')}>
<InfoListItem
labelText="Trading Fee"
labelText={t('Trading Fee')}
content={
poolData && poolData.swapFee && !isLoading ? (
formatBigIntToPercentString(poolData.swapFee, 8, 2, false)
Expand All @@ -29,7 +33,7 @@ const PoolInfoSection = () => {
}
/>
<InfoListItem
labelText="Virtual Price"
labelText={t('Virtual Price')}
content={
poolData && poolData?.virtualPrice && !isLoading ? (
<AugmentWithUnits
Expand All @@ -42,7 +46,7 @@ const PoolInfoSection = () => {
}
/>
<InfoListItem
labelText="Total Liquidity"
labelText={t('Total Liquidity')}
content={
poolData && poolData?.totalLocked && !isLoading ? (
<AugmentWithUnits
Expand All @@ -55,7 +59,7 @@ const PoolInfoSection = () => {
}
/>
<InfoListItem
labelText="Total Liquidity USD"
labelText={t('Total Liquidity USD')}
content={
poolData && poolData?.totalLockedUSD && !isLoading ? (
<AugmentWithUnits
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { useMemo } from 'react'
import { useTranslations } from 'next-intl'

import { formatBigIntToString } from '@/utils/bigint/format'

function removeLeadingZeros(inputValue: number): number {
Expand All @@ -16,6 +18,8 @@ const PriceImpactDisplay = ({ priceImpact }: { priceImpact: bigint }) => {
let labelText: string
let content: any

const t = useTranslations('Pools.Other')

const priceImpactValue: number = useMemo(() => {
if (!priceImpact) return 0

Expand All @@ -42,10 +46,10 @@ const PriceImpactDisplay = ({ priceImpact }: { priceImpact: bigint }) => {

if (priceImpactValue > 0) {
colorClassName = 'text-green-500'
labelText = 'Bonus'
labelText = t('Bonus')
} else {
colorClassName = 'text-red-500'
labelText = 'Price Impact'
labelText = t('Price impact')
}

if (priceImpactValue == 0) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { useEffect, useMemo, useState } from 'react'
import { useAccount, useAccountEffect, useSwitchChain } from 'wagmi'
import { useConnectModal } from '@rainbow-me/rainbowkit'
import { useTranslations } from 'next-intl'

import {
usePoolDataState,
usePoolDepositState,
Expand All @@ -12,7 +14,8 @@ import { DEFAULT_DEPOSIT_QUOTE } from './Deposit'
import LoadingDots from '@/components/ui/tailwind/LoadingDots'

const DepositButton = ({ approveTxn, depositTxn }) => {
const [isConnected, setIsConnected] = useState(false) // Initialize to false
const t = useTranslations('Pools.DepositButton')
const [isConnected, setIsConnected] = useState(false)
const { openConnectModal } = useConnectModal()

const { chain, isConnected: isConnectedInit } = useAccount()
Expand Down Expand Up @@ -57,7 +60,6 @@ const DepositButton = ({ approveTxn, depositTxn }) => {
)
}
)

const isEmptyPool = useMemo(() => {
return poolData.totalLocked === 0
}, [poolData])
Expand All @@ -74,7 +76,7 @@ const DepositButton = ({ approveTxn, depositTxn }) => {

if (!isBalanceEnough) {
buttonProperties = {
label: 'Insufficient Balance',
label: t('insufficientBalance'),
onClick: null,
}
} else if (isLoading) {
Expand All @@ -88,29 +90,29 @@ const DepositButton = ({ approveTxn, depositTxn }) => {
}
} else if (!isConnected) {
buttonProperties = {
label: `Connect Wallet to Bridge`,
label: t('connectWallet'),
onClick: openConnectModal,
}
} else if (chain?.id !== pool.chainId) {
const targetChain = chains.find((c) => c.id === pool.chainId)
buttonProperties = {
label: `Switch to ${chains.find((c) => c.id === pool.chainId).name}`,
label: t('switchChain', { chainName: targetChain.name }),
onClick: () => switchChain({ chainId: pool.chainId }),
pendingLabel: 'Switching chains',
pendingLabel: t('switchingChains'),
}
} else if (isApprovalNeeded) {
buttonProperties = {
onClick: approveTxn,
label: `Approve Token(s)`,
pendingLabel: 'Approving',
label: t('approveTokens'),
pendingLabel: t('approving'),
}
} else {
buttonProperties = {
onClick: depositTxn,
label: `Deposit`,
pendingLabel: 'Depositing',
label: t('deposit'),
pendingLabel: t('depositing'),
}
}

return (
pool &&
buttonProperties && (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useEffect, useState } from 'react'
import { useAccount, useAccountEffect, useSwitchChain } from 'wagmi'
import { useConnectModal } from '@rainbow-me/rainbowkit'
import { useTranslations } from 'next-intl'
import { DEFAULT_WITHDRAW_QUOTE } from '@/slices/poolWithdrawSlice'
import {
usePoolDataState,
Expand All @@ -12,10 +13,11 @@ import { TransactionButton } from '@/components/buttons/TransactionButton'
import LoadingDots from '@/components/ui/tailwind/LoadingDots'

const WithdrawButton = ({ approveTxn, withdrawTxn, isApproved }) => {
const t = useTranslations('Pools.WithdrawButton')
const { chain, isConnected: isConnectedInit } = useAccount()
const { chains, switchChain } = useSwitchChain()
const { openConnectModal } = useConnectModal()
const [isConnected, setIsConnected] = useState(false) // Initialize to false
const [isConnected, setIsConnected] = useState(false)

useAccountEffect({
onDisconnect() {
Expand Down Expand Up @@ -45,7 +47,7 @@ const WithdrawButton = ({ approveTxn, withdrawTxn, isApproved }) => {

if (!isBalanceEnough && isValidQuote && isValidInput) {
buttonProperties = {
label: 'Insufficient Balance',
label: t('insufficientBalance'),
onClick: null,
}
} else if (isLoading) {
Expand All @@ -59,26 +61,28 @@ const WithdrawButton = ({ approveTxn, withdrawTxn, isApproved }) => {
}
} else if (!isConnected) {
buttonProperties = {
label: `Connect Wallet to Bridge`,
label: t('connectWallet'),
onClick: openConnectModal,
}
} else if (chain?.id !== pool.chainId) {
buttonProperties = {
label: `Switch to ${chains.find((c) => c.id === pool.chainId).name}`,
label: t('switchChain', {
chainName: chains.find((c) => c.id === pool.chainId).name,
}),
onClick: () => switchChain({ chainId: pool.chainId }),
pendingLabel: 'Switching chains',
pendingLabel: t('switchingChains'),
}
} else if (!isApproved && isValidQuote && isValidInput) {
buttonProperties = {
onClick: approveTxn,
label: `Approve Token`,
pendingLabel: 'Approving',
label: t('approveToken'),
pendingLabel: t('approving'),
}
} else {
buttonProperties = {
onClick: withdrawTxn,
label: `Withdraw`,
pendingLabel: 'Withdrawing...',
label: t('withdraw'),
pendingLabel: t('withdrawing'),
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/synapse-interface/pages/pools/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const PoolsPage = () => {
<div className="flex-wrap justify-between mb-4 md:flex">
<PageHeader
title={t('Incentivized Pools')}
subtitle={t('Contributors are rewarded for balancing asset pools')}
subtitle={t('Contributors are rewarded')}
/>
</div>
<Grid cols={{ xs: 1, sm: 1, md: 2 }} gap={4} className="mb-5">
Expand Down
2 changes: 1 addition & 1 deletion packages/synapse-interface/pages/stake/StakeCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const StakeCard = ({ address, chainId, pool }: StakeCardProps) => {
poolLabel={stakingPoolLabel}
lpTokenBalance={lpTokenBalance}
/>
<InfoSectionCard title="Your balances">
<InfoSectionCard title={t('Your balances')}>
<div className="flex items-center justify-between my-2">
<div className="text-[#EEEDEF]">{t('Unstaked')}</div>
<div className="text-white ">
Expand Down

0 comments on commit 62a1334

Please sign in to comment.