showing burn amounts in the redeem all function. ALso adding an isworking flag for staking and ustaking
This commit is contained in:
@@ -7,7 +7,7 @@ import { Input } from '@/components/ui/input';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { ChevronDown, CheckCircle, XCircle, Loader2, ArrowDownUp } from 'lucide-react';
|
||||
import { useAccount, usePublicClient } from 'wagmi';
|
||||
import { useGetAllPools, useTokenDetails, useSwapMintAmounts, useBurnSwapAmounts, useLPTokenBalance, type PoolDetails, type TokenDetails, type BurnSwapAmounts } from '@/hooks/usePartyPlanner';
|
||||
import { useGetAllPools, useTokenDetails, useSwapMintAmounts, useBurnSwapAmounts, useLPTokenBalance, useBurnAmounts, type PoolDetails, type TokenDetails, type BurnSwapAmounts } from '@/hooks/usePartyPlanner';
|
||||
import { useSwapMint, useBurnSwap, useBurn, type ActualSwapMintAmounts, type ActualBurnSwapAmounts, type ActualBurnAmounts } from '@/hooks/usePartyPool';
|
||||
import { formatUnits, parseUnits } from 'viem';
|
||||
import IPartyPoolABI from '@/contracts/IPartyPoolABI';
|
||||
@@ -143,6 +143,12 @@ export function StakeForm({ defaultMode = 'stake' }: StakeFormProps) {
|
||||
mode === 'unstake' && !redeemAll ? inputTokenIndex : undefined
|
||||
);
|
||||
|
||||
// Fetch burn amounts (for unstake mode when redeeming all)
|
||||
const { burnAmounts, loading: burnAmountsLoading } = useBurnAmounts(
|
||||
mode === 'unstake' && redeemAll ? selectedPool?.address : undefined,
|
||||
mode === 'unstake' && redeemAll ? maxAmountIn : undefined
|
||||
);
|
||||
|
||||
// Fetch token details for the selected pool when Redeem All is active
|
||||
useEffect(() => {
|
||||
if (!publicClient || !selectedPool || mode !== 'unstake' || !redeemAll) {
|
||||
@@ -618,15 +624,18 @@ export function StakeForm({ defaultMode = 'stake' }: StakeFormProps) {
|
||||
)}
|
||||
|
||||
{/* Redeem All Tokens Display */}
|
||||
{mode === 'unstake' && redeemAll && poolTokens.length > 0 && (
|
||||
{mode === 'unstake' && redeemAll && poolTokens.length > 0 && !isAmountExceedingBalance && (
|
||||
<div className="px-4 py-3 bg-muted/30 rounded-lg space-y-2">
|
||||
<div className="text-sm font-medium mb-2">You will receive:</div>
|
||||
<div className="space-y-1">
|
||||
{poolTokens.map((token) => (
|
||||
{poolTokens.map((token, index) => (
|
||||
<div key={token.address} className="text-sm flex justify-between">
|
||||
<span className="text-muted-foreground">{token.symbol}</span>
|
||||
<span className="text-xs text-muted-foreground">
|
||||
(proportional to pool composition)
|
||||
<span className="text-muted-foreground">{token.symbol}:</span>
|
||||
<span className="font-medium">
|
||||
{burnAmountsLoading ? 'Calculating...' : burnAmounts && burnAmounts[index]
|
||||
? `${Number(formatUnits(burnAmounts[index], token.decimals)).toLocaleString('en-US', { maximumFractionDigits: 6 })}`
|
||||
: '(proportional to pool composition)'
|
||||
}
|
||||
</span>
|
||||
</div>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user