diff --git a/shared/images/lp_token_512.png b/shared/images/lp_token_512.png new file mode 100644 index 00000000..1968f160 Binary files /dev/null and b/shared/images/lp_token_512.png differ diff --git a/shared/types/dex.ts b/shared/types/dex.ts index 1862e2e2..f421554e 100644 --- a/shared/types/dex.ts +++ b/shared/types/dex.ts @@ -80,37 +80,65 @@ export interface PoolCreationParams { // Native token ID constant (relay chain HEZ) export const NATIVE_TOKEN_ID = -1; -// Known tokens on testnet +// Known tokens on testnet (assets pallet) export const KNOWN_TOKENS: Record = { [-1]: { id: -1, symbol: 'HEZ', name: 'Native HEZ', decimals: 12, - }, - 0: { - id: 0, - symbol: 'wHEZ', - name: 'Wrapped HEZ', - decimals: 12, + logo: '/shared/images/hez_token_512.png', }, 1: { id: 1, symbol: 'PEZ', name: 'Pezkuwi Token', decimals: 12, + logo: '/shared/images/pez_token_512.png', }, 2: { id: 2, symbol: 'wHEZ', - name: 'Wrapped HEZ (Asset Hub)', + name: 'Wrapped HEZ', decimals: 12, + logo: '/shared/images/hez_token_512.png', }, 1000: { id: 1000, symbol: 'wUSDT', name: 'Wrapped USDT', decimals: 6, + logo: '/shared/images/USDT(hez)logo.png', + }, +}; + +// LP Token info (poolAssets pallet - separate from assets pallet) +export interface LPTokenInfo { + id: number; + symbol: string; + name: string; + decimals: number; + logo: string; + poolPair: [number, number]; // [asset1, asset2] +} + +// Known LP tokens (from poolAssets pallet) +export const LP_TOKENS: Record = { + 0: { + id: 0, + symbol: 'HEZ-PEZ LP', + name: 'HEZ-PEZ Liquidity', + decimals: 12, + logo: '/shared/images/lp_token_512.png', + poolPair: [NATIVE_TOKEN_ID, 1], + }, + 1: { + id: 1, + symbol: 'HEZ-USDT LP', + name: 'HEZ-USDT Liquidity', + decimals: 12, + logo: '/shared/images/lp_token_512.png', + poolPair: [NATIVE_TOKEN_ID, 1000], }, }; diff --git a/web/src/contexts/WalletContext.tsx b/web/src/contexts/WalletContext.tsx index 64d63fed..cec9b764 100644 --- a/web/src/contexts/WalletContext.tsx +++ b/web/src/contexts/WalletContext.tsx @@ -16,7 +16,10 @@ interface TokenBalances { HEZ: string; PEZ: string; wHEZ: string; - USDT: string; // User-facing key for wUSDT (backend uses wUSDT asset ID 2) + USDT: string; // User-facing key for wUSDT (asset ID 1000) + // LP Tokens (from poolAssets pallet) + 'HEZ-PEZ-LP': string; + 'HEZ-USDT-LP': string; } interface WalletContextType { @@ -48,7 +51,14 @@ export const WalletProvider: React.FC<{ children: React.ReactNode }> = ({ childr }); const [balance, setBalance] = useState('0'); - const [balances, setBalances] = useState({ HEZ: '0', PEZ: '0', wHEZ: '0', USDT: '0' }); + const [balances, setBalances] = useState({ + HEZ: '0', + PEZ: '0', + wHEZ: '0', + USDT: '0', + 'HEZ-PEZ-LP': '0', + 'HEZ-USDT-LP': '0', + }); const [error, setError] = useState(null); const [signer, setSigner] = useState(null); @@ -132,14 +142,44 @@ export const WalletProvider: React.FC<{ children: React.ReactNode }> = ({ childr if (import.meta.env.DEV) console.error('❌ Failed to fetch wUSDT balance:', err); } + // Fetch LP Token balances from poolAssets pallet + let hezPezLpBalance = '0'; + let hezUsdtLpBalance = '0'; + try { + // HEZ-PEZ LP Token (ID: 0) + const hezPezLp = await assetApi.query.poolAssets.account(0, address); + if (hezPezLp.isSome) { + hezPezLpBalance = formatBalance(hezPezLp.unwrap().balance.toString()); + if (import.meta.env.DEV) console.log('✅ HEZ-PEZ LP balance:', hezPezLpBalance); + } + + // HEZ-USDT LP Token (ID: 1) + const hezUsdtLp = await assetApi.query.poolAssets.account(1, address); + if (hezUsdtLp.isSome) { + hezUsdtLpBalance = formatBalance(hezUsdtLp.unwrap().balance.toString()); + if (import.meta.env.DEV) console.log('✅ HEZ-USDT LP balance:', hezUsdtLpBalance); + } + } catch (err) { + if (import.meta.env.DEV) console.error('❌ Failed to fetch LP balances:', err); + } + setBalances({ HEZ: hezBalance, PEZ: pezBalance, wHEZ: whezBalance, USDT: wusdtBalance, + 'HEZ-PEZ-LP': hezPezLpBalance, + 'HEZ-USDT-LP': hezUsdtLpBalance, }); - if (import.meta.env.DEV) console.log('✅ Balances updated:', { HEZ: hezBalance, PEZ: pezBalance, wHEZ: whezBalance, wUSDT: wusdtBalance }); + if (import.meta.env.DEV) console.log('✅ Balances updated:', { + HEZ: hezBalance, + PEZ: pezBalance, + wHEZ: whezBalance, + USDT: wusdtBalance, + 'HEZ-PEZ-LP': hezPezLpBalance, + 'HEZ-USDT-LP': hezUsdtLpBalance, + }); } catch (err) { if (import.meta.env.DEV) console.error('Failed to fetch balances:', err); setError('Failed to fetch balances');