Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into rewards-code-review
Browse files Browse the repository at this point in the history
  • Loading branch information
ruslan-concero committed Nov 8, 2024
2 parents 870b00e + dcb3789 commit 21ad6a0
Show file tree
Hide file tree
Showing 339 changed files with 4,314 additions and 8,745 deletions.
19 changes: 19 additions & 0 deletions public/ChartPlaceholder.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 14 additions & 0 deletions public/Line.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/Success.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 12 additions & 5 deletions public/conceroToken.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions src/Navigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,20 @@ import { useAccount } from 'wagmi'
import posthog from 'posthog-js'
import { handleFetchUser } from './web3/handleFetchUser'
import { type IUser } from './api/concero/user/userType'
import { Footer } from './components/rewards/Footer/Footer'

const PoolScreen = lazy(
async () =>
await import('./components/screens/PoolScreen/PoolScreen').then(module => ({ default: module.PoolScreen })),
)

const UsdcPoolScreen = lazy(
async () =>
await import('./components/screens/PoolScreen/UsdcPoolScreen').then(module => ({
default: module.UsdcPoolScreen,
})),
)

const RewardsScreen = lazy(
async () =>
await import('./components/screens/RewardsScreen/RewardsScreen').then(module => ({
Expand Down Expand Up @@ -47,6 +55,22 @@ export const Navigator = () => {
<AppScreen>
<Header user={user} />
<Routes>
<Route
path={routes.pool}
element={
<Suspense fallback={<FullScreenLoader />}>
<PoolScreen />
</Suspense>
}
/>
<Route
path={routes.poolUsdc}
element={
<Suspense fallback={<FullScreenLoader />}>
<UsdcPoolScreen />
</Suspense>
}
/>
<Route
path={routes.pool}
element={
Expand Down Expand Up @@ -74,6 +98,7 @@ export const Navigator = () => {
<Route path={routes.root} element={<Navigate to={routes.pool} />} />
<Route path={'/*'} element={<Navigate to={routes.pool} />} />
</Routes>
<Footer />
</AppScreen>
</BrowserRouter>
)
Expand Down
20 changes: 0 additions & 20 deletions src/api/concero/fetchFees.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/api/concero/fetchParentPoolActionsByLpAddress.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { config } from '../../constants/config'
import { type UserTransaction } from '../../components/cards/UserActionsCard/UserActionsCard'
import { type UserTransaction } from '../../components/pool/UserActions/UserActions'
import { get } from '../client'

export async function fetchParentPoolActionsByLpAddress(lpAddress: string): Promise<UserTransaction[] | []> {
Expand Down
9 changes: 9 additions & 0 deletions src/api/concero/fetchTransactionsCount.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { get } from '../client'

export const fetchTransactionsCount = async (): Promise<number> => {
const url = `${process.env.CONCERO_API_URL}/bridgeTransactionsCount`

const response = await get(url)
if (response.status !== 200) throw new Error('No transactions found')
return response.data.data
}
18 changes: 18 additions & 0 deletions src/api/concero/fetchUserEarnings.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { Address } from 'viem'
import { get } from '../client'
import { type unstable_PatchRoutesOnMissFunction } from 'react-router-dom'

export interface UserEarnings {
earnings: number
percents: number
deposit: number
currentBalance: unstable_PatchRoutesOnMissFunction
}

export const fetchUserEarnings = async (address: Address): Promise<UserEarnings> => {
const url = `${process.env.CONCERO_API_URL}/userPoolEarnings?address=${address}`

const response = await get(url)
if (response.status !== 200) throw new Error('No transactions found')
return response.data.data
}
2 changes: 1 addition & 1 deletion src/api/concero/getUserActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { fetchParentPoolActionsByLpAddress } from './fetchParentPoolActionsByLpA
dayjs.extend(isSameOrBefore)

export const poolEventNamesMap = {
ConceroParentPool_DepositCompleted: 'Liquidity provided',
ConceroParentPool_DepositCompleted: 'Deposit',
ConceroParentPool_WithdrawRequestInitiated: 'Withdrawal Submitted',
ConceroParentPool_Withdrawn: 'Withdrawal Complete',
}
Expand Down
12 changes: 12 additions & 0 deletions src/api/concero/pool/fetchFees.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { get } from '../../client'
import { type Fee } from '../types'

export const fetchFees = async (startTime?: number | null, endTime?: number | null): Promise<Fee[]> => {
const filter = startTime && endTime ? `?startTime=${startTime}&endTime=${endTime}` : ''

const url = `${process.env.CONCERO_API_URL}/bridgeFees${filter}`

const response = await get(url)
if (response.status !== 200) throw new Error('no fees found')
return response.data.data
}
9 changes: 9 additions & 0 deletions src/api/concero/pool/getLpProvidersCount.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { get } from '../../client'

export const getLpProvidersCount = async (): Promise<number> => {
const url = `${process.env.CONCERO_API_URL}/lpProvidersCount`

const response = await get(url)
if (response.status !== 200) throw new Error('no last fee found')
return response.data.data
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { erc20Abi, formatUnits } from 'viem'
import { type IPoolConfig, poolConfigs, poolLoansInUseAbiITem, usdcDecimals } from './poolConfigs'
import { type IPoolConfig, poolConfigs, poolLoansInUseAbiITem, usdcDecimals } from '../poolConfigs'
import { getPublicClient } from '@wagmi/core'
import { config } from '../../web3/wagmi'
import { config } from '../../../web3/wagmi'

export const getLiquidityOnChain = async (poolConfig: IPoolConfig) => {
const { chain, conceroContract, usdcContract } = poolConfig
Expand Down Expand Up @@ -44,6 +44,5 @@ export const getPoolLiquidity = async (childrenOnly = false) => {
return BigInt(totalLiquidity)
}

console.log(totalLiquidity, formatUnits(BigInt(totalLiquidity), usdcDecimals))
return Number(formatUnits(BigInt(totalLiquidity), usdcDecimals))
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { type Address, erc20Abi, formatUnits } from 'viem'
import { base } from 'viem/chains'
import { config, IS_TESTNET } from '../../constants/config'
import { config, IS_TESTNET } from '../../../constants/config'
import { getPoolLiquidity } from './getPoolLiquidity'
import { abi as ParentPool } from '../../abi/ParentPool.json'
import { abi as ParentPool } from '../../../abi/ParentPool.json'
import { getPublicClient } from '@wagmi/core'
import { config as wagmiConfig } from '../../web3/wagmi'
import { config as wagmiConfig } from '../../../web3/wagmi'
import { baseSepolia } from 'wagmi/chains'

const client = getPublicClient(wagmiConfig, { chainId: IS_TESTNET ? baseSepolia.id : base.id })
Expand All @@ -31,24 +31,24 @@ export const getLpTotalSupply = async () => {
return Number(formatUnits(totalSupply, lpTokenDecimals))
}

export const calculateLpAmount = async (amountToDeposit: bigint) => {
export const calculateLpAmount = async (amountToDeposit: bigint): Promise<bigint> => {
const childPoolsBalance = await getPoolLiquidity(true)

return await client.readContract({
return (await client.readContract({
address: config.PARENT_POOL_CONTRACT,
abi: ParentPool,
functionName: 'calculateLpAmount',
args: [childPoolsBalance, amountToDeposit],
})
})) as bigint
}

export const calculateWithdrawableAmount = async (clpAmount: bigint) => {
export const calculateWithdrawableAmount = async (clpAmount: bigint): Promise<bigint> => {
const childPoolsBalance = await getPoolLiquidity(true)

return await client.readContract({
return (await client.readContract({
address: config.PARENT_POOL_CONTRACT,
abi: ParentPool,
functionName: 'calculateWithdrawableAmount',
args: [childPoolsBalance, clpAmount],
})
})) as bigint
}
21 changes: 21 additions & 0 deletions src/assets/icons/ArrowLeftIcon.tsx.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export const ArrowLeftIcon = () => {
return (
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
<rect
x="16"
y="8.79999"
width="14.88"
height="1.6"
rx="0.8"
transform="rotate(-180 16 8.79999)"
fill="#344054"
/>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M6.96588 14.1657C6.65346 14.4781 6.14693 14.4781 5.83451 14.1657L0.23451 8.56571C-0.0779095 8.25329 -0.0779095 7.74676 0.23451 7.43434L5.83451 1.83434C6.14693 1.52192 6.65346 1.52192 6.96588 1.83434C7.2783 2.14676 7.2783 2.65329 6.96588 2.96571L1.93157 8.00002L6.96588 13.0343C7.2783 13.3468 7.2783 13.8533 6.96588 14.1657Z"
fill="#344054"
/>
</svg>
)
}
17 changes: 17 additions & 0 deletions src/assets/icons/ArrowRight.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
interface IconProps {
color?: string
}

export const ArrowRight = ({ color = '#026AA2' }: IconProps) => {
return (
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14" fill="none">
<rect y="6.29999" width="13.02" height="1.4" rx="0.7" fill={color} />
<path
fillRule="evenodd"
clipRule="evenodd"
d="M7.90502 1.60502C8.17839 1.33165 8.6216 1.33165 8.89497 1.60502L13.795 6.50502C14.0683 6.77839 14.0683 7.2216 13.795 7.49497L8.89497 12.395C8.6216 12.6683 8.17839 12.6683 7.90502 12.395C7.63166 12.1216 7.63166 11.6784 7.90502 11.405L12.31 6.99999L7.90502 2.59497C7.63166 2.3216 7.63166 1.87839 7.90502 1.60502Z"
fill={color}
/>
</svg>
)
}
2 changes: 0 additions & 2 deletions src/assets/icons/ArrowRightIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { IconWrapper } from './IconWrapper/IconWrapper'

export const ArrowRightIcon = () => {
return (
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
Expand Down
11 changes: 11 additions & 0 deletions src/assets/icons/ArrowUpIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
export const ArrowUpIcon = () => (
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
<rect x="7.2002" y="16" width="14.88" height="1.6" rx="0.8" transform="rotate(-90 7.2002 16)" fill="#027A48" />
<path
fillRule="evenodd"
clipRule="evenodd"
d="M1.83392 6.9657C1.5215 6.65328 1.5215 6.14675 1.83392 5.83433L7.43393 0.234327C7.74634 -0.0780919 8.25288 -0.0780918 8.5653 0.234328L14.1653 5.83433C14.4777 6.14675 14.4777 6.65328 14.1653 6.9657C13.8529 7.27812 13.3463 7.27812 13.0339 6.9657L7.99961 1.93138L2.96529 6.9657C2.65288 7.27812 2.14634 7.27812 1.83392 6.9657Z"
fill="#027A48"
/>
</svg>
)
10 changes: 10 additions & 0 deletions src/assets/icons/CrossIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const CrossIcon = () => (
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" fill="none">
<path
fillRule="evenodd"
clipRule="evenodd"
d="M2.63471 2.63431C2.94712 2.32189 3.45366 2.32189 3.76608 2.63431L8.00039 6.86862L12.2347 2.63431C12.5471 2.32189 13.0537 2.32189 13.3661 2.63431C13.6785 2.94673 13.6785 3.45326 13.3661 3.76568L9.13176 7.99999L13.3661 12.2343C13.6785 12.5467 13.6785 13.0533 13.3661 13.3657C13.0537 13.6781 12.5471 13.6781 12.2347 13.3657L8.00039 9.13136L3.76608 13.3657C3.45366 13.6781 2.94712 13.6781 2.63471 13.3657C2.32229 13.0533 2.32229 12.5467 2.63471 12.2343L6.86902 7.99999L2.63471 3.76568C2.32229 3.45326 2.32229 2.94673 2.63471 2.63431Z"
fill="#344054"
/>
</svg>
)
20 changes: 20 additions & 0 deletions src/assets/icons/EthIcon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
export const EthIcon = () => (
<svg xmlns="http://www.w3.org/2000/svg" width="21" height="33" viewBox="0 0 21 33" fill="none">
<g clipPath="url(#clip0_2206_13151)">
<path d="M10.4969 0L10.2676 0.751799V22.5673L10.4969 22.788L20.9937 16.8023L10.4969 0Z" fill="#343434" />
<path d="M10.4969 0L0 16.8023L10.4969 22.7881V12.1996V0Z" fill="#8C8C8C" />
<path
d="M10.4969 24.7054L10.3677 24.8574V32.6285L10.4969 32.9926L21 18.7227L10.4969 24.7054Z"
fill="#3C3C3B"
/>
<path d="M10.4969 32.9925V24.7053L0 18.7226L10.4969 32.9925Z" fill="#8C8C8C" />
<path d="M10.4968 22.788L20.9935 16.8024L10.4968 12.1996V22.788Z" fill="#141414" />
<path d="M0 16.8024L10.4967 22.788V12.1996L0 16.8024Z" fill="#393939" />
</g>
<defs>
<clipPath id="clip0_2206_13151">
<rect width="21" height="33" fill="white" />
</clipPath>
</defs>
</svg>
)
Loading

0 comments on commit 21ad6a0

Please sign in to comment.