lock trading for 1 minute for creator
This commit is contained in:
parent
c729913db0
commit
6c54afc88d
9 changed files with 2324 additions and 8 deletions
|
|
@ -43,6 +43,8 @@
|
|||
let shouldSignIn = $state(false);
|
||||
|
||||
let previousCoinSymbol = $state<string | null>(null);
|
||||
let countdown = $state<number | null>(null);
|
||||
let countdownInterval = $state<NodeJS.Timeout | null>(null);
|
||||
|
||||
const timeframeOptions = [
|
||||
{ value: '1m', label: '1 minute' },
|
||||
|
|
@ -89,6 +91,41 @@
|
|||
}
|
||||
});
|
||||
|
||||
$effect(() => {
|
||||
if (coin?.isLocked && coin?.tradingUnlocksAt) {
|
||||
const unlockTime = new Date(coin.tradingUnlocksAt).getTime();
|
||||
|
||||
const updateCountdown = () => {
|
||||
const now = Date.now();
|
||||
const remaining = Math.max(0, Math.ceil((unlockTime - now) / 1000));
|
||||
countdown = remaining;
|
||||
|
||||
if (remaining === 0 && countdownInterval) {
|
||||
clearInterval(countdownInterval);
|
||||
countdownInterval = null;
|
||||
if (coin) {
|
||||
coin = { ...coin, isLocked: false };
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
updateCountdown();
|
||||
countdownInterval = setInterval(updateCountdown, 1000);
|
||||
} else {
|
||||
countdown = null;
|
||||
if (countdownInterval) {
|
||||
clearInterval(countdownInterval);
|
||||
countdownInterval = null;
|
||||
}
|
||||
}
|
||||
|
||||
return () => {
|
||||
if (countdownInterval) {
|
||||
clearInterval(countdownInterval);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
async function loadCoinData() {
|
||||
try {
|
||||
loading = true;
|
||||
|
|
@ -356,6 +393,17 @@
|
|||
};
|
||||
});
|
||||
}
|
||||
|
||||
function formatCountdown(seconds: number): string {
|
||||
const mins = Math.floor(seconds / 60);
|
||||
const secs = seconds % 60;
|
||||
return `${mins}:${secs.toString().padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
let isCreator = $derived(coin && $USER_DATA && coin.creatorId === Number($USER_DATA.id));
|
||||
let isTradingLocked = $derived(coin?.isLocked && countdown !== null && countdown > 0);
|
||||
let canTrade = $derived(!isTradingLocked || isCreator);
|
||||
|
||||
</script>
|
||||
|
||||
<SEO
|
||||
|
|
@ -419,6 +467,11 @@
|
|||
● LIVE
|
||||
</Badge>
|
||||
{/if}
|
||||
{#if isTradingLocked}
|
||||
<Badge variant="secondary" class="text-xs">
|
||||
🔒 LOCKED {countdown !== null ? formatCountdown(countdown) : ''}
|
||||
</Badge>
|
||||
{/if}
|
||||
{#if !coin.isListed}
|
||||
<Badge variant="destructive">Delisted</Badge>
|
||||
{/if}
|
||||
|
|
@ -529,6 +582,15 @@
|
|||
{coin.symbol}
|
||||
</p>
|
||||
{/if}
|
||||
{#if isTradingLocked}
|
||||
<p class="text-muted-foreground text-sm">
|
||||
{#if isCreator}
|
||||
🔒 Creator-only period: {countdown !== null ? formatCountdown(countdown) : ''} remaining
|
||||
{:else}
|
||||
🔒 Trading unlocks in: {countdown !== null ? formatCountdown(countdown) : ''}
|
||||
{/if}
|
||||
</p>
|
||||
{/if}
|
||||
</Card.Header>
|
||||
<Card.Content>
|
||||
{#if $USER_DATA}
|
||||
|
|
@ -538,7 +600,7 @@
|
|||
variant="default"
|
||||
size="lg"
|
||||
onclick={() => (buyModalOpen = true)}
|
||||
disabled={!coin.isListed}
|
||||
disabled={!coin.isListed || !canTrade}
|
||||
>
|
||||
<TrendingUp class="h-4 w-4" />
|
||||
Buy {coin.symbol}
|
||||
|
|
@ -548,7 +610,7 @@
|
|||
variant="outline"
|
||||
size="lg"
|
||||
onclick={() => (sellModalOpen = true)}
|
||||
disabled={!coin.isListed || userHolding <= 0}
|
||||
disabled={!coin.isListed || userHolding <= 0 || !canTrade}
|
||||
>
|
||||
<TrendingDown class="h-4 w-4" />
|
||||
Sell {coin.symbol}
|
||||
|
|
|
|||
|
|
@ -238,9 +238,9 @@
|
|||
<p>• Starting Price: <span class="font-medium">$0.000001 per token</span></p>
|
||||
<p>• You receive <span class="font-medium">100%</span> of the supply</p>
|
||||
<p>• Initial Market Cap: <span class="font-medium">$1,000</span></p>
|
||||
<p>• Trading Lock: <span class="font-medium">1 minute creator-only period</span></p>
|
||||
<p class="mt-2 text-sm">
|
||||
These settings ensure a fair start for all traders. The price will increase
|
||||
naturally as people buy tokens.
|
||||
After creation, you'll have 1 minute of exclusive trading time before others can trade. This allows you to purchase your initial supply.
|
||||
</p>
|
||||
</div>
|
||||
</AlertDescription>
|
||||
|
|
|
|||
Reference in a new issue