Sealed Bid Auction Sale

Sealed Bid Auction Sale

Overview

The LegionSealedBidAuctionSale contract executes sealed bid auctions of ERC20 tokens after the Token Generation Event (TGE). It manages the complete auction lifecycle including capital pledging, bid privacy protection, refunds, raised capital withdrawal, token distribution for vesting, and sale cancellation.

LegionSealedBidAuctionSale implements ECIES (Elliptic Curve Integrated Encryption Scheme) for bid privacy. At auction initialization, Legion publishes an elliptic curve public key. Investors use this public key to encrypt their desired token allocation amounts while the invested capital (bidToken amount) remains visible as it is transferred to the contract during capital pledging.

After the auction concludes and results are published by Legion, the corresponding private key is released publicly. This enables all participants to decrypt sealed bids and verify auction integrity.

Every sealed bid auction consists of 6 stages, detailed below:

Sealed Bid Auction Sale Stages

  1. Active Sale Period: The primary auction stage where investors pledge capital with encrypted bid amounts. Duration ranges from 1 hour to 12 weeks as configured during initialization.

  2. Refund Period: Regulatory compliance stage where investors can request capital refunds. Duration ranges from 1 hour to 2 weeks. Sale cancellation becomes locked after this period ends.

  3. Results Initialization: Legion locks sale cancellation functionality and prepares for result publication. This prevents last-minute cancellations during result processing.

  4. Results Publication: Legion publishes final allocation data using Merkle trees, sets total capital raised, and releases the private key for bid decryption verification.

  5. Token Supply: Projects supply allocated tokens to the contract along with calculated fees for Legion and referrers.

  6. Token Distribution: Investors claim allocated tokens through Merkle proof verification. Vesting contracts are deployed for time-locked allocations while immediate distributions are transferred directly.

Key Functions

Sale Management Functions

  • initialize: Initializes the auction with comprehensive configuration parameters including the ECIES public key for bid encryption, timing parameters, addresses, and fee structures.

  • initializePublishSaleResults: Locks sale cancellation functionality and prepares for result publication. Restricted to Legion operators and can only be executed after the refund period.

  • publishSaleResults: Publishes final auction results including claim Merkle root, accepted capital Merkle root, total tokens allocated, total capital raised, and releases the private key for bid decryption. Restricted to Legion operators.

Investment Functions

  • invest: Processes investor capital contributions with encrypted bid amounts during the active sale period. Requires valid signature verification, sealed bid data with ECIES encryption, and enforces minimum investment amounts.

Bid Decryption Functions

  • decryptSealedBid: Allows public decryption of sealed bids using the encrypted amount and salt after the private key has been published. Enables verification of auction integrity and bid accuracy.

Capital Management Functions

  • withdrawRaisedCapital: Allows project administrators to withdraw raised capital after refund period completion and token supply. Automatically distributes fees to Legion and referrer addresses.

  • withdrawExcessInvestedCapital: Enables investors to reclaim excess capital not accepted in final allocations using Merkle proof verification.

Token Distribution Functions

  • claimTokenAllocation: Processes investor token claims using Merkle proof verification. Deploys vesting contracts for time-locked tokens and transfers immediate allocations directly.

  • releaseVestedTokens: Triggers token release from investor vesting contracts according to predefined schedules.

  • supplyTokens: Allows project administrators to supply allocated tokens plus calculated fees to the contract for distribution.

Administrative Functions

  • setAcceptedCapital: Sets accepted capital Merkle root for excess capital withdrawal verification. Restricted to Legion operators.

  • cancel: Enables project administrators to cancel the auction before results initialization, allowing investor capital recovery. Cancellation becomes locked after initializePublishSaleResults is called.

  • withdrawInvestedCapitalIfCanceled: Allows investors to reclaim invested capital from canceled auctions.

Emergency Functions

  • emergencyWithdraw: Enables Legion operators to withdraw specified tokens to designated addresses in emergency situations.

  • pause: Suspends contract operations while preserving investor fund access.

  • unpause: Resumes normal contract operations.

  • syncLegionAddresses: Updates Legion infrastructure addresses from the central registry.

Position Management Functions

  • transferInvestorPosition: Enables Legion operators to transfer investor positions between addresses.

  • transferInvestorPositionWithAuthorization: Allows position transfers with cryptographic authorization from Legion signers.

Technical Specifications

Configuration Parameters

Sealed Bid Auction Configuration

  • publicKey: ECIES public key for bid encryption (Point structure with x, y coordinates)

  • privateKey: ECIES private key for bid decryption (released after auction completion)

  • cancelLocked: Boolean flag preventing sale cancellation after results initialization

Sale Configuration

  • startTime: Active auction period commencement

  • endTime: Active auction period conclusion

  • refundEndTime: Refund period termination

  • minimumInvestAmount: Minimum required investment threshold

Address Configuration

  • bidToken: Token accepted for investments (USDC, USDT, etc.)

  • askToken: Token being distributed in the auction

  • projectAdmin: Administrative address for project operations

  • addressRegistry: Central registry for Legion infrastructure addresses

Encryption Specifications

ECIES Implementation

The contract utilizes Elliptic Curve Integrated Encryption Scheme for bid privacy:

  • Key Generation: Legion generates an elliptic curve key pair during auction initialization

  • Encryption: Investors encrypt desired token amounts using the published public key and their address as salt

  • Decryption: After auction completion, the private key enables public verification of all bids

Sealed Bid Structure

Each sealed bid contains:

  • encryptedAmountOut: Encrypted desired token allocation amount

  • salt: Derivation value (must equal investor's address as uint256)

  • sealedBidPublicKey: Public key used for encryption (must match auction public key)

Access Control

Legion Operators

  • Auction result publication and private key release

  • Cancellation lock management and system administration

  • Emergency intervention and position management

Project Administrators

  • Auction cancellation (before lock) and capital withdrawal

  • Token supply operations and fee management

Authorized Signers

  • Investment signature verification

  • Position transfer authorization validation

State Management

Position Tracking

Each investor position maintains:

  • Total invested capital amount

  • Encrypted bid data and decryption status

  • Refund status and settlement state

  • Vesting contract address assignment

  • Excess capital claim status

Auction Status

Global auction state includes:

  • Total capital invested across all participants

  • Total tokens allocated for distribution

  • Total capital accepted and raised

  • Cancellation lock status

  • Private key publication status

Verification Mechanisms

Cryptographic Validation

  • Signature Verification: Investment operations require valid signatures from authorized Legion signers

  • Public Key Validation: Sealed bids must use the correct auction public key

  • Private Key Verification: Published private key must correspond to the auction public key

  • Salt Validation: Encryption salt must equal investor's address

Merkle Proof Systems

Token claims and excess capital withdrawals utilize Merkle tree verification for efficient validation of allocated amounts and accepted capital.

ECIES Security

  • Point Validation: All elliptic curve points undergo validity checks

  • Encryption Integrity: Bid decryption enables post-auction verification

  • Key Pair Consistency: Private key publication is validated against the original public key

Error Conditions

The contract implements comprehensive error handling for:

  • Invalid ECIES key parameters and encryption data

  • Timing violations across auction phases

  • Cancellation lock violations and unauthorized operations

  • Private key publication and decryption errors

  • State inconsistencies and duplicate operations

Event Emission

The contract emits detailed events for:

  • Investment processing with encrypted bid data and investor information

  • Result initialization and cancellation lock activation

  • Result publication with decryption key release

  • Administrative operations and state changes

  • Error conditions and security alerts

Last updated