step1: jsonInfo
basic info from CDN. use fetch()
⬇
step2: sdkParsedInfo
use SDK method: Liquidity.getInfo()
from string
-> publicKey
, number
-> BN
⬇
step3: hydratedInfo
add some costomized computed info
they are helper functions or convenient data for UI
- useLiquidityCache (don't use it in UI)
- store for all liquidity info (jsonInfo, sdkParsedInfo, hydratedInfo)
- useLiquidity
- access hydratedInfo
- refresh info
- useLiquidityInitAction
- fetch json info
- base on user's balance, sdk parse the json info
- base on sdk parsed info, generate hydrated info
-
useWallet
type WalletStore = { // owner owner: PublicKey | null wallets: Wallet[] adapter: WalletAdapter | SignerWalletAdapter | MessageSignerWalletAdapter | null connected: boolean disconnecting: boolean connecting: boolean select(walletName: WalletName): void disconnect(): Promise<unknown> /** HexAddress is token account address */ balances: Record<HexAddress, TokenAmount> /** it's key is [RpcUrl]+[owner] */ tokenAccountsCache: Record<`${RpcUrl}+${WalletOwner}`, TokenAccount[]> tokenAccounts: TokenAccount[] }
-
usePairInfo
type PairInfoStore = { pairInfo: Record<HexAddress, PairInfoResponseItem> lpPrices: Record<HexAddress, Price | null> }
- [wallet]
external:
- useEffect in PopSystemStack
upload pop functions
if must access
PopSystemStack
's state. so can't isolate the function