Skip to content

Commit

Permalink
Pool fees (#931)
Browse files Browse the repository at this point in the history
* init

* log
  • Loading branch information
nautsimon authored May 18, 2023
1 parent 0a78494 commit d574fed
Show file tree
Hide file tree
Showing 10 changed files with 41 additions and 19 deletions.
1 change: 0 additions & 1 deletion packages/synapse-interface/components/Popup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ const Popup = ({ chainId }) => {
const [active, setActive] = useState(false)

useEffect(() => {
console.log(IMPAIRED_CHAINS[chainId], chainId)
if (chainId && IMPAIRED_CHAINS[chainId]) {
setActive(true)
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@ export function AddToWalletMiniButton({
iconFirst = false,
chainId,
}) {
console.log('METAMASK_ICON', METAMASK_ICON)

return (
<Button
onClick={() => addTokenToWallet({ token, icon, chainId })}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ export const ChainSlideOver = ({
{networks.map(({ id: mapChainId }, idx) => {
let onClickSpecificNetwork
if (chainId === mapChainId) {
onClickSpecificNetwork = () => console.log('INCEPTION')
onClickSpecificNetwork = () => console.log('INCEPTION') // I think this case is obsolete
} else {
onClickSpecificNetwork = () => {
onChangeChain(mapChainId, false, isOrigin ? 'from' : 'to')
Expand Down
1 change: 0 additions & 1 deletion packages/synapse-interface/constants/tokens/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ const getTokenHashMap = () => {
tokenHashMap[CHAINS.AVALANCHE.id][GMX.wrapperAddresses[CHAINS.AVALANCHE.id]] =
GMX
Object.keys(WETH.addresses).map((chain) => {
console.log('CHAIN', chain)
tokenHashMap[chain][WETH.addresses[chain]] = ETH
})
return tokenHashMap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ const BlockCountdown = memo(
if (confirmationDelta === 0 || toEvent) {
return
}
console.log('toEventtoEvent', toEvent)
fetchBlockNumber({
chainId: fromEvent?.chainId,
}).then((newestBlockNumber) => {
Expand All @@ -55,7 +54,6 @@ const BlockCountdown = memo(
(fromEvent.blockNumber - (newestBlockNumber ?? 0))
setConfirmationDelta(delta > 0 ? delta : 0)
if (delta <= 0) {
console.log('setCompletedConf to true')
setCompletedConf(true)
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@ const DestinationTx = memo((fromEvent: BridgeWatcherTx) => {
const { providerMap } = useSynapseContext()

const getToBridgeEvent = async (): Promise<BridgeWatcherTx> => {
console.log('getting logs')

const currentFromBlock = await fetchBlockNumber({
chainId: fromEvent.toChainId,
})
Expand Down Expand Up @@ -111,8 +109,7 @@ const DestinationTx = memo((fromEvent: BridgeWatcherTx) => {
toEvent === undefined &&
attempted
) {
console.log('SJDHKSJHD')
getToBridgeEvent().then((tx) => {
= getToBridgeEvent().then((tx) => {
setToEvent(tx)
})
}
Expand Down
16 changes: 11 additions & 5 deletions packages/synapse-interface/pages/pool/PoolInfoSection/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import { Token } from '@types'
import InfoSectionCard from './InfoSectionCard'
import CurrencyReservesCard from './CurrencyReservesCard'
import LoadingSpinner from '@tw/LoadingSpinner'
import { useEffect, useState } from 'react'
import { getPoolFee } from '@utils/actions/getPoolFee'
const PoolInfoSection = ({
pool,
poolData,
Expand All @@ -20,12 +22,16 @@ const PoolInfoSection = ({
poolData: any
chainId: number
}) => {
// const swapFee = bnPercentFormat('0.02')
// this needs to be fixed, need admin fee

const [swapFee, setSwapFee] = useState('')
useEffect(() => {
if (pool && chainId) {
getPoolFee(pool.swapAddresses[chainId], chainId).then((res) => {
setSwapFee(res?.swapFee)
})
}
}, [pool, chainId])
return (
<div className="space-y-4">
{/* <UserPoolInfoCard data={userData} /> */}
<CurrencyReservesCard
title="Currency Reserves"
chainId={chainId}
Expand All @@ -34,7 +40,7 @@ const PoolInfoSection = ({
<InfoSectionCard title="Pool Info">
<InfoListItem
labelText="Trading Fee"
content={true ? '0.02%' : <LoadingSpinner />}
content={swapFee?.length > 0 ? swapFee : <LoadingSpinner />}
/>
<InfoListItem
labelText="Virtual Price"
Expand Down
1 change: 0 additions & 1 deletion packages/synapse-interface/pages/stake/StakeCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@ const StakeCard = ({ address, chainId, pool }: StakeCardProps) => {
if (!address || !chainId || !stakingPoolId) return
getStakedBalance(`0x${address.slice(2)}`, chainId, stakingPoolId)
.then((data) => {
console.log('data', data)
setUserStakeData(data)
})
.catch((err) => {
Expand Down
27 changes: 27 additions & 0 deletions packages/synapse-interface/utils/actions/getPoolFee.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { readContracts } from '@wagmi/core'
import { Zero } from '@ethersproject/constants'
import SWAP_ABI from '@abis/swap.json'
import { bnPercentFormat } from '@bignumber/format'

export const getPoolFee = async (poolAddress: string, chainId: number) => {
const data: any = await readContracts({
contracts: [
{
address: `0x${poolAddress.slice(2)}`,
abi: SWAP_ABI,
functionName: 'swapStorage',
chainId,
},
{
address: `0x${poolAddress.slice(2)}`,
abi: SWAP_ABI,
functionName: 'getVirtualPrice',
chainId,
},
],
})
const swapFeeRaw = data[0]?.swapFee ?? Zero
const virtualPrice: any = data[1]
const swapFee = bnPercentFormat(swapFeeRaw)
return { swapFee, virtualPrice }
}
3 changes: 1 addition & 2 deletions packages/synapse-interface/utils/bridgeWatcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ export const getLogs = async (
try {
const logs = await provider.send('eth_getLogs', [filter])
return logs
} catch (e) {
console.log(e)
} catch {
return []
}
}
Expand Down

0 comments on commit d574fed

Please sign in to comment.