Skip to content

Token launch #6342

Draft
witmk wants to merge 10 commits intodevelopfrom
tokenlaunch
Draft

Token launch #6342
witmk wants to merge 10 commits intodevelopfrom
tokenlaunch

Conversation

@witmk
Copy link
Copy Markdown
Contributor

@witmk witmk commented Feb 24, 2026

Token launch contracts - support auction mechanism, TGE related functionality

Greptile Summary

Adds token launch auction infrastructure with uniform clearing price mechanism, tiered bidding windows, and TGE orchestration.

Key Changes:

  • TokenLaunchAuction.sol (1786 lines): Core auction contract with batched finalization, bonus token pool for early bidders, distribution retry logic, and unwind mechanism for delayed TGE
  • LpTokenLockVault.sol & PoolLpSeeder.sol: LP management with time-locked vesting and automated liquidity seeding
  • Design documents provide comprehensive specification and operational runbook

Architecture:

  • Uniform clearing price (P*) ensures fairness - all winners pay the same price
  • Batched finalization stages handle large numbers of bids without gas limits
  • Distribution uses push model with retry/vault fallback for failed transfers
  • TGE coordinates LP seeding, transfer lock removal, and fund releases
  • Unwind mechanism handles TGE delays by burning distributed tokens and pro-rata USDST refunds

Critical Dependencies:

  • Requires AdminRegistry whitelisting for transfer and burn on STRATO token (documented in comments at lines 26-34)
  • Transfer lock must be configured correctly or tokens become transferable prematurely

Confidence Score: 4/5

  • Safe to merge with normal risk - complex financial logic requires careful deployment and testing
  • The auction implementation is well-documented with comprehensive design docs and defensive coding patterns (batched operations, retry logic, guarded arithmetic). The main risks are: (1) complex multi-stage allocation logic with multiple price tiers, (2) critical dependency on AdminRegistry whitelisting that could cause silent failures, (3) unwind mechanism with potential for accounting drift. Code shows evidence of careful design for gas optimization and edge case handling.
  • Pay special attention to TokenLaunchAuction.sol - verify AdminRegistry whitelisting is configured before deployment, test all allocation stages with various bid distributions, and validate unwind mechanism with edge cases

Important Files Changed

Filename Overview
mercata/contracts/concrete/Auction/TokenLaunchAuction.sol Implements uniform clearing price auction with tiered bidding, bonus tokens, batched finalization, TGE flow, and unwind mechanism
mercata/contracts/concrete/Auction/LpTokenLockVault.sol Implements time-locked LP token vault with 1-year cliff and 2-year linear vesting
mercata/contracts/concrete/Auction/PoolLpSeeder.sol Seeds liquidity at TGE by adding USDST/STRATO to pool and forwarding LP tokens to vault

Sequence Diagram

sequenceDiagram
    participant Owner
    participant Bidder
    participant Auction as TokenLaunchAuction
    participant USDST
    participant STRATO
    participant LPSeeder as PoolLpSeeder
    participant Vault as LpTokenLockVault
    participant TransferLock

    Owner->>Auction: initialize(tokens, wallets, params)
    Owner->>Auction: escrow STRATO tokens
    Owner->>Auction: startAuction()
    
    Note over Auction: Tier 1 Window (bonus eligible)
    Bidder->>USDST: approve(Auction, budget)
    Bidder->>Auction: placeBid(budget, maxPrice)
    Auction->>USDST: transferFrom(bidder, budget)
    
    Note over Auction: Tier 2 Window
    Bidder->>Auction: placeBid(budget, maxPrice)
    
    Note over Auction: Close Buffer (no new bids)
    Note over Auction: Auction ends
    
    Owner->>Auction: finalizePrice()
    Note over Auction: Computes clearing price P*
    
    Owner->>Auction: finalizeAllocationsBatch(maxCount)
    Note over Auction: Batched allocation stages:<br/>0-Classify bids by price<br/>1-Compute uncapped tokens<br/>2-Apply maxRaise cap<br/>3-Finalize bids<br/>4-Compute bonus demand<br/>5-Allocate bonus tokens
    
    Owner->>Auction: distributeBatch(bidIds)
    Auction->>STRATO: transfer(bidder, tokens+bonus)
    Note over STRATO: Transfers succeed but<br/>tokens non-transferable
    
    Bidder->>Auction: withdrawRefund(bidId)
    Auction->>USDST: transfer(bidder, refund)
    
    Owner->>Auction: setTgeTime(timestamp)
    Owner->>Auction: executeTGE()
    Auction->>USDST: transfer(LPSeeder, lpUSDST)
    Auction->>STRATO: transfer(LPSeeder, lpSTRATO)
    LPSeeder->>LPSeeder: addLiquidity()
    LPSeeder->>Vault: transfer(lpTokens)
    Vault->>Vault: recordLock(lpTokens)
    Auction->>TransferLock: unpause()
    Note over STRATO: Transfers now enabled
    Auction->>USDST: transfer(treasury/reserve)
    
    Note over Bidder,STRATO: Tokens now transferable
Loading

Last reviewed commit: f6058ce

@witmk witmk marked this pull request as draft February 24, 2026 22:41
Copy link
Copy Markdown

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

7 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant