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 d53bec9
Show file tree
Hide file tree
Showing 10 changed files with 149 additions and 33 deletions.
35 changes: 34 additions & 1 deletion packages/synapse-interface/messages/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
},
"Pools": {
"Actions": "Actions",
"Approve": "Approve",
"Back to Pool": "Back to Pool",
"Back to Pools": "Back to Pools",
"Switch to": "Switch to",
Expand All @@ -173,6 +174,7 @@
"Withdraw": "Withdraw",
"Stake": "Stake",
"Staked": "Staked",
"Staking": "Staking",
"Unstake": "Unstake",
"Unstaked": "Unstaked",
"Unstaking": "Unstaking",
Expand Down Expand Up @@ -204,7 +206,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
35 changes: 34 additions & 1 deletion packages/synapse-interface/messages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
},
"Pools": {
"Actions": "Actions",
"Approve": "Approuver",
"Back to Pool": "Retour au pool",
"Back to Pools": "Retour aux pools",
"Switch to": "Passer à",
Expand All @@ -173,6 +174,7 @@
"Withdraw": "Retrait",
"Stake": "Staker",
"Staked": "Staké",
"Staking": "Staking",
"Unstake": "Déstaker",
"Unstaked": "Déstaké",
"Unstaking": "Déstakage",
Expand Down Expand Up @@ -204,7 +206,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
35 changes: 34 additions & 1 deletion packages/synapse-interface/messages/lorem-ipsum.json
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@
},
"Pools": {
"Actions": "Actiones",
"Approve": "Probandum",
"Back to Pool": "Retro ad Piscinam",
"Back to Pools": "Retro ad Piscinas",
"Switch to": "Verti ad",
Expand All @@ -173,6 +174,7 @@
"Withdraw": "Retractare",
"Stake": "Ponere",
"Staked": "Ponus",
"Staking": "Ponens",
"Unstake": "Detrahere",
"Unstaked": "Retractatus",
"Unstaking": "Detrahens",
Expand Down Expand Up @@ -204,7 +206,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
Loading

0 comments on commit d53bec9

Please sign in to comment.