Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 86 - update liquidity page to read tick state from cosmos #89

Merged
merged 26 commits into from
Jul 26, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
119b262
Add fetching tick query details with JSON string output
dib542 Jun 30, 2022
c62f97c
Only fetch ticks when token pair is defined
dib542 Jul 1, 2022
6d944f1
Fix getting data out of ticks error
dib542 Jul 1, 2022
f246763
Fix resetting ticks fetch error
dib542 Jul 1, 2022
1c36945
Move tick debug output higher for easy visibility
dib542 Jul 1, 2022
414d3b8
Fix on cancelled possible issue
dib542 Jul 1, 2022
a659496
Improve loading state
dib542 Jul 1, 2022
09c5f74
Improve printout of tick state
dib542 Jul 1, 2022
d48bbad
Add reading of events in Pool page
dib542 Jul 1, 2022
369d571
Make query effect more consistent
dib542 Jul 5, 2022
42e12b0
Use Tx event listening instead of generic event listening
dib542 Jul 8, 2022
669396e
Update ticks state inside Pool page
dib542 Jul 8, 2022
2247378
Update dev token addresses to match those in Cosmos mock
dib542 Jul 8, 2022
ba54c02
Update subscription calls with new event subscription manager updates
dib542 Jul 8, 2022
0c73aec
Fix Pool page opening websocket race condition issues
dib542 Jul 8, 2022
5261166
Try to add a subscriptionManager.open to match .close
dib542 Jul 8, 2022
8594db0
Revert "Try to add a subscriptionManager.open to match .close"
dib542 Jul 8, 2022
d0e3c71
Fix onMessage type
dib542 Jul 21, 2022
c483b2f
Make onMessage function type easier to read
dib542 Jul 22, 2022
1d2cbb2
Use environment variables in Pool page
dib542 Jul 22, 2022
a31a6fe
Update to my suggested environment variable names
dib542 Jul 22, 2022
72f9be1
Use useIndexerPairData for Pool page data
dib542 Jul 22, 2022
6ede7c0
Destructure ticks directly from useIndexerPairData
dib542 Jul 22, 2022
2e5d4eb
Fix return type of useIndexerPairData
dib542 Jul 25, 2022
ac2e8d9
Make spaces easier to read
dib542 Jul 26, 2022
3a94c11
Only show tick error label when relevant
dib542 Jul 26, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/components/TokenPicker/mockHooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,18 @@ export interface SwapRequest {
}

const tokens: Array<Token> = [
{ logo: null, symbol: 'Eth', name: 'Ether', address: '0x0001' },
nickzoum marked this conversation as resolved.
Show resolved Hide resolved
{ logo: null, symbol: 'Eth', name: 'Ether', address: 'ETH' },
{
logo: null,
symbol: 'Dai',
name: 'Dai Stablecoin',
address: '0x0002',
address: 'Dai',
},
{
logo: null,
symbol: 'USDC',
name: 'USDCoin',
address: '0x0003',
address: 'USDC',
},
{ logo: null, symbol: 'USDT', name: 'Tether USD', address: '0x0004' },
{ logo: null, symbol: 'WBTC', name: 'Wrapped BTC', address: '0x0005' },
Expand Down
2 changes: 1 addition & 1 deletion src/lib/web3/indexerProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ export function useIndexerPairData(
const [token0, token1] = [tokenA, tokenB].sort();
const pairID = token0 && token1 && getPairID(token0, token1);
return {
data: pairID && pairs?.[pairID],
data: pairID ? pairs?.[pairID] : undefined,
error,
isValidating,
};
Expand Down
20 changes: 19 additions & 1 deletion src/pages/Pool/Pool.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from '../../components/TokenPicker/mockHooks';

import './Pool.scss';
import { useIndexerPairData } from '../../lib/web3/indexerProvider';

export default function Pool() {
const [tokenA, setTokenA] = useState(undefined as Token | undefined);
Expand Down Expand Up @@ -64,6 +65,13 @@ export default function Pool() {
}
});
}, [totalValue, rateData, rangeMin, rangeMax]);

const {
data: { ticks } = {},
error: ticksError,
isValidating: tickFetching,
} = useIndexerPairData(tokenA?.address, tokenB?.address);

return (
<div className="pool-page">
<h2 className="my-3 pt-1">Select Pair</h2>
Expand All @@ -82,20 +90,30 @@ export default function Pool() {
tokenList={tokenList}
exclusion={tokenA}
/>
<div>
Ticks: {tickFetching ? 'loading...' : ''} &nbsp;
{JSON.stringify(ticks, null, 2)}
</div>
{ticksError && (
<div>
TickFetch Error: <span style={{ color: 'red' }}>{ticksError}</span>
</div>
)}
<div className="card fee-group bg-slate-300 my-2 p-3 rounded-xl">
<strong>0.3% fee tier</strong>
</div>
<h2 className="mt-4 mb-3 pt-1">Set price range</h2>
<div className="card fee-group bg-slate-300 my-2 p-3 rounded-xl">
{tokenA && tokenB ? (
<span>
Current Price: {rateData?.price || '...'} {tokenB.name} per{' '}
Current Price: {rateData?.price || '...'} {tokenB.name} per &nbsp;
{tokenA.name}
</span>
) : (
<span>Current Price:</span>
)}
</div>
<br />
<div className="inline-block w-1/2 text-center">Minimum tick</div>
<div className="inline-block w-1/2 text-center">Maximum tick</div>
<br />
Expand Down