Skip to content

Latest commit

 

History

History
79 lines (57 loc) · 1.85 KB

MAP.md

File metadata and controls

79 lines (57 loc) · 1.85 KB

data flow

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

overview (Hooks)

  • 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

overview (tools)

application overview

zustand stores

  • 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>
    }

features

  • [wallet]

external:

  • useEffect in PopSystemStack upload pop functions if must access PopSystemStack's state. so can't isolate the function