fix: tiki score, staking lookup, LP balance, teleport, DOT swap

- Fix tiki: use userTikis storage instead of userRoles
- Add tiki name to score mapping (welati=10, serok=50, etc)
- Improve staking ledger lookup with debug logging
- Fix LP balance fetching using poolId directly
- Change teleport placeholder from 0.5 to empty
- Add DOT token to swap list with 10 decimals
This commit is contained in:
2026-02-07 02:20:04 +03:00
parent c35c538678
commit 67b30daca8
7 changed files with 145 additions and 38 deletions
+3 -3
View File
@@ -45,7 +45,7 @@ export function FundFeesModal({ isOpen, onClose }: Props) {
const { hapticImpact, showAlert } = useTelegram();
const [targetChain, setTargetChain] = useState<TargetChain>('asset-hub');
const [amount, setAmount] = useState('0.5');
const [amount, setAmount] = useState('');
const [isTransferring, setIsTransferring] = useState(false);
const [txStatus, setTxStatus] = useState<'idle' | 'signing' | 'pending' | 'success' | 'error'>(
'idle'
@@ -244,7 +244,7 @@ export function FundFeesModal({ isOpen, onClose }: Props) {
// Reset after success
setTimeout(() => {
setAmount('0.5');
setAmount('');
setTxStatus('idle');
onClose();
}, 2000);
@@ -405,7 +405,7 @@ export function FundFeesModal({ isOpen, onClose }: Props) {
step="0.0001"
value={amount}
onChange={(e) => setAmount(e.target.value)}
placeholder="0.5"
placeholder="Mîqdar"
className="w-full px-4 py-3 bg-muted rounded-xl text-lg font-mono"
disabled={isTransferring}
/>
+15 -7
View File
@@ -67,7 +67,8 @@ export function LPStakingModal({ isOpen, onClose }: LPStakingModalProps) {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const poolData = value.toJSON() as any;
const lpTokenId = poolData.stakedAssetId?.interior?.x2?.[1]?.generalIndex ?? poolId;
// LP token ID in poolAssets pallet matches the pool ID (0, 1, 2)
const lpTokenId = poolId;
let userStaked = '0';
let pendingRewards = '0';
@@ -84,16 +85,23 @@ export function LPStakingModal({ isOpen, onClose }: LPStakingModalProps) {
const stakeData = stakeInfo.unwrap().toJSON();
userStaked = stakeData.amount || '0';
}
} catch (err) {
console.error('Error fetching stake info:', err);
}
// Fetch LP balance
// Fetch LP balance from poolAssets pallet
try {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const lpBal = await (assetHubApi.query.poolAssets as any).account(lpTokenId, address);
if (lpBal && lpBal.isSome) {
const lpData = lpBal.unwrap().toJSON();
lpBalance = lpData.balance || '0';
if (lpBal) {
// Handle both Option<AccountData> and direct AccountData
const lpData = lpBal.isSome ? lpBal.unwrap().toJSON() : lpBal.toJSON();
if (lpData && lpData.balance) {
lpBalance = lpData.balance.toString();
}
}
} catch {
// Ignore errors
} catch (err) {
console.error('Error fetching LP balance for pool', poolId, ':', err);
}
}
+18 -2
View File
@@ -19,6 +19,7 @@ const TOKENS = [
{ symbol: 'HEZ', name: 'Hezkurd', assetId: -1, decimals: 12, icon: '/tokens/HEZ.png' },
{ symbol: 'PEZ', name: 'Pezkuwi', assetId: 1, decimals: 12, icon: '/tokens/PEZ.png' },
{ symbol: 'USDT', name: 'Tether', assetId: 1000, decimals: 6, icon: '/tokens/USDT.png' },
{ symbol: 'DOT', name: 'Polkadot', assetId: 1001, decimals: 10, icon: '/tokens/DOT.png' },
];
// Native token ID for relay chain HEZ
@@ -51,6 +52,7 @@ export function SwapModal({ isOpen, onClose }: SwapModalProps) {
HEZ: '0',
PEZ: '0',
USDT: '0',
DOT: '0',
});
// Fetch balances from Asset Hub (where swaps happen)
@@ -84,11 +86,19 @@ export function SwapModal({ isOpen, onClose }: SwapModalProps) {
? (parseInt(usdtResult.unwrap().balance.toString()) / 1e6).toFixed(2)
: '0.00';
// DOT balance (Asset 1001, 10 decimals)
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const dotResult = await (assetHubApi.query.assets as any).account(1001, keypair.address);
const dotBalance = dotResult.isSome
? (parseInt(dotResult.unwrap().balance.toString()) / 1e10).toFixed(4)
: '0.0000';
// Update all balances at once
setBalances({
HEZ: hezBalance,
PEZ: pezBalance,
USDT: usdtBalance,
DOT: dotBalance,
});
} catch (err) {
console.error('Failed to fetch balances:', err);
@@ -127,8 +137,14 @@ export function SwapModal({ isOpen, onClose }: SwapModalProps) {
if (poolInfo && !poolInfo.isEmpty) {
// Get quote from runtime API
const decimals1 = asset1 === 1000 ? 6 : 12;
const decimals2 = asset2 === 1000 ? 6 : 12;
// USDT has 6 decimals, DOT has 10 decimals, others have 12
const getDecimals = (id: number) => {
if (id === 1000) return 6; // USDT
if (id === 1001) return 10; // DOT
return 12; // HEZ, PEZ
};
const decimals1 = getDecimals(asset1);
const decimals2 = getDecimals(asset2);
const oneUnit = BigInt(Math.pow(10, decimals1));
const quote = await (