Skip to content

Commit 6ef3550

Browse files
committed
minor fixes to cabanalytics tvl stats
1 parent 051d907 commit 6ef3550

File tree

6 files changed

+33
-28
lines changed

6 files changed

+33
-28
lines changed

apps/analytics/src/components/Charts/TVLOverTimeChart.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ export const TVLOverTimeChart = (props: TVLOverTimeChartProps) => {
2121
const vaultAddresses = Object.keys(vaultTVLs ?? {}).map(getAddressFromVaultId)
2222
const { data: tokens } = useTokens(prizePool.chainId, vaultAddresses)
2323

24-
const { data: prizeToken } = usePrizeTokenData(prizePool)
25-
2624
const chartData = useMemo(() => {
2725
const data: AreaChartProps['data'] = []
2826

@@ -49,7 +47,7 @@ export const TVLOverTimeChart = (props: TVLOverTimeChartProps) => {
4947
return data
5048
}, [vaultTVLs])
5149

52-
const isReady = !!chartData?.length && !!tokens && !!prizeToken
50+
const isReady = !!chartData?.length && !!tokens
5351

5452
const lastDrawData = chartData[chartData.length - 1]
5553
const vaultIds = Object.keys(vaultTVLs ?? {})
@@ -79,7 +77,7 @@ export const TVLOverTimeChart = (props: TVLOverTimeChartProps) => {
7977

8078
const formattedValue = `${formatNumberForDisplay(value, {
8179
maximumFractionDigits: 3
82-
})} ${prizeToken.symbol}`
80+
})} ETH`
8381
const formattedName =
8482
name === 'total'
8583
? 'Total TVL'

apps/analytics/src/components/Stats/TVLStats.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export const TVLStats = (props: TVLStatsProps) => {
3131
title: 'Median Deposit Transaction',
3232
value:
3333
deposits !== undefined
34-
? formatNumberForDisplay(deposits.medianValue, { maximumFractionDigits: 4 })
34+
? formatNumberForDisplay(deposits.medianValue, { maximumFractionDigits: 5 })
3535
: undefined,
3636
unit: 'ETH'
3737
},
@@ -40,7 +40,7 @@ export const TVLStats = (props: TVLStatsProps) => {
4040
title: 'Average Deposit Transaction',
4141
value:
4242
deposits !== undefined
43-
? formatNumberForDisplay(deposits.avgValue, { maximumFractionDigits: 4 })
43+
? formatNumberForDisplay(deposits.avgValue, { maximumFractionDigits: 5 })
4444
: undefined,
4545
unit: 'ETH'
4646
}

apps/analytics/src/hooks/useDeployedVaultAddresses.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ export const useDeployedVaultAddresses = (prizePool: PrizePool) => {
4040
]
4141
}))
4242
)
43+
} else if (prizePool.chainId === NETWORK.world) {
44+
vaultAddresses.push('0x8ad5959c9245b64173d4c0c3cd3ff66dac3cab0e')
45+
46+
vaultAddresses.push(...(await getVaultAddressesFromFactories(prizePool.publicClient)))
4347
} else {
4448
vaultAddresses.push(...(await getVaultAddressesFromFactories(prizePool.publicClient)))
4549
}

packages/hyperstructure-client-js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@generationsoftware/hyperstructure-client-js",
33
"description": "Lightweight library for interacting with PoolTogether contracts",
4-
"version": "1.22.0",
4+
"version": "1.22.1",
55
"license": "MIT",
66
"main": "./dist/index.mjs",
77
"types": "./dist/index.d.ts",

packages/hyperstructure-react-hooks/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@generationsoftware/hyperstructure-react-hooks",
33
"description": "React hooks library for interacting with PoolTogether contracts",
4-
"version": "1.27.0",
4+
"version": "1.27.1",
55
"license": "MIT",
66
"main": "./dist/index.mjs",
77
"types": "./dist/index.d.ts",

shared/utilities/utils/events.ts

Lines changed: 23 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
11
import { DSKit } from 'dskit-eth'
2-
import { Address, PublicClient } from 'viem'
2+
import { Address, GetLogsReturnType, PublicClient } from 'viem'
33
import {
44
LIQUIDATION_ROUTER_ADDRESSES,
55
POOL_WIDE_TWAB_REWARDS_ADDRESSES,
66
TWAB_REWARDS_ADDRESSES
77
} from '../constants'
88
import { getLiquidationPairAddresses } from './liquidations'
99

10+
const depositEventABI = {
11+
inputs: [
12+
{ indexed: true, internalType: 'address', name: 'sender', type: 'address' },
13+
{ indexed: true, internalType: 'address', name: 'owner', type: 'address' },
14+
{ indexed: false, internalType: 'uint256', name: 'assets', type: 'uint256' },
15+
{ indexed: false, internalType: 'uint256', name: 'shares', type: 'uint256' }
16+
],
17+
name: 'Deposit',
18+
type: 'event'
19+
} as const
20+
1021
/**
1122
* Returns `Deposit` events
1223
* @param publicClient a public Viem client to query through
@@ -18,23 +29,16 @@ export const getDepositEvents = async (
1829
publicClient: PublicClient,
1930
vaultAddresses: Address[],
2031
options?: { sender?: Address[]; owner?: Address[]; fromBlock?: bigint; toBlock?: bigint }
21-
) => {
22-
return await publicClient.getLogs({
32+
): Promise<GetLogsReturnType<typeof depositEventABI, [typeof depositEventABI], true>> => {
33+
// @ts-ignore
34+
const dskit = new DSKit({ viemPublicClient: publicClient })
35+
36+
return await dskit.event.query({
2337
address: vaultAddresses,
24-
event: {
25-
inputs: [
26-
{ indexed: true, internalType: 'address', name: 'sender', type: 'address' },
27-
{ indexed: true, internalType: 'address', name: 'owner', type: 'address' },
28-
{ indexed: false, internalType: 'uint256', name: 'assets', type: 'uint256' },
29-
{ indexed: false, internalType: 'uint256', name: 'shares', type: 'uint256' }
30-
],
31-
name: 'Deposit',
32-
type: 'event'
33-
},
38+
event: depositEventABI,
3439
args: { sender: options?.sender ?? null, owner: options?.owner ?? null },
35-
fromBlock: options?.fromBlock,
36-
toBlock: options?.toBlock ?? 'latest',
37-
strict: true
40+
fromBlock: options?.fromBlock ?? 1n,
41+
toBlock: options?.toBlock ?? 'latest'
3842
})
3943
}
4044

@@ -245,7 +249,7 @@ export const getLiquidationEvents = async (
245249
args: { ...lpEvent.args, liquidationPair: lpEvent.address }
246250
}))
247251

248-
const routerEvents = await publicClient.getLogs({
252+
const routerEvents = await dskit.event.query({
249253
address: liqRouterContractAddress,
250254
event: {
251255
inputs: [
@@ -265,9 +269,8 @@ export const getLiquidationEvents = async (
265269
name: 'SwappedExactAmountOut',
266270
type: 'event'
267271
},
268-
fromBlock: options?.fromBlock,
269-
toBlock: options?.toBlock ?? 'latest',
270-
strict: true
272+
fromBlock: options?.fromBlock ?? 1n,
273+
toBlock: options?.toBlock ?? 'latest'
271274
})
272275

273276
return [...routerEvents, ...formattedLpEvents].sort((a, b) =>

0 commit comments

Comments
 (0)