saddle-finance / saddle-frontend

An open source UI for saddle.finance 🤠
https://saddle.exchange
54 stars 58 forks source link

update swap state logic with useQuery #1305

Closed nkrulikovsky closed 1 year ago

nkrulikovsky commented 1 year ago

Describe

This PR replace fetch logic of swap state using useQuery.

Right now, we get swap state when app load and store on redux. If user don't visit pool page, when we don't need to fetch swap state at first.

useQuery stores data to cache, so we don't need to store this data on redux.

codecov[bot] commented 1 year ago

Codecov Report

Merging #1305 (4e227e4) into master (3b2350d) will increase coverage by 0.00%. The diff coverage is 0.00%.

@@          Coverage Diff           @@
##           master   #1305   +/-   ##
======================================
  Coverage    9.40%   9.41%           
======================================
  Files         182     182           
  Lines        6730    6724    -6     
  Branches     2164    2165    +1     
======================================
  Hits          633     633           
+ Misses       6097    6091    -6     
Impacted Files Coverage Δ
src/components/PoolInfoCard.tsx 0.00% <0.00%> (ø)
src/hooks/usePoolData.ts 0.00% <0.00%> (ø)
src/hooks/useSwapStats.ts 0.00% <0.00%> (ø)
src/pages/App.tsx 0.00% <ø> (ø)
src/state/application.ts 0.00% <ø> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

nkrulikovsky commented 1 year ago

@hammeiam I believe we are fetching swap state on PoolInfoCard, so when we open withdraw or deposit page, fetching will be occured.

hammeiam commented 1 year ago

@hammeiam I believe we are fetching swap state on PoolInfoCard, so when we open withdraw or deposit page, fetching will be occurred.

swapStats is used in PoolInfoCard as well as in usePoolData, where it is used for PoolOverview to display APY and Volume. It would be good to remove swapStats from usePoolData eventually, but for now your new hook needs to make swapStats available to usePoolData as well to avoid regressions.