Fixed Price Sale

Overview

The LegionFixedPriceSale contract executes fixed price sales of ERC20 tokens after the Token Generation Event (TGE). It manages the complete sale lifecycle including capital pledging, refunds, raised capital withdrawal, token distribution for vesting, and sale cancellation.

Every fixed price sale consists of 7 stages, detailed below:

Fixed Price Sale Stages

  1. Prefund Stage: During the prefund stage, investors pledge capital with early participation benefits. The duration ranges from 1 hour to 12 weeks as configured during initialization.

  2. Pre-fund Allocation Period: Projects process allocations for prefund participants based on predetermined criteria. This process is facilitated by Legion's backend infrastructure. Investment functionality is suspended during this period. Duration ranges from 1 hour to 2 weeks.

  3. Active Sale Period: The primary sale stage where general investors pledge capital at the fixed token price. All investments during this period are subject to signature verification. Duration ranges from 1 hour to 12 weeks.

  4. Refund Period: Regulatory compliance stage where investors can request capital refunds. After the refund period concludes, Legion publishes sale results and enables project capital withdrawal. Duration ranges from 1 hour to 2 weeks.

  5. Results Publication: Legion publishes final allocation data using Merkle trees for efficient verification. Token allocation amounts and accepted capital are finalized during this stage.

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

  7. 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 sale with comprehensive configuration parameters including pricing, timing, addresses, and fee structures.

  • publishSaleResults: Publishes final sale results including claim Merkle root, accepted capital Merkle root, total tokens allocated, and token decimal configuration. Restricted to Legion operators.

Investment Functions

  • invest: Processes investor capital contributions during prefund and active sale periods. Requires valid signature verification and enforces minimum investment amounts.

  • refund: Enables investors to reclaim invested capital during the designated refund period. Updates position records and decrements total invested capital.

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 sale 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 sale before results publication, allowing investor capital recovery.

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

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

Fixed Price Sale Configuration

  • tokenPrice: Price per token denominated in bid token units

  • prefundStartTime: Timestamp when prefunding begins

  • prefundEndTime: Timestamp when prefunding concludes

Sale Configuration

  • startTime: Active sale period commencement

  • endTime: Active sale 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 sale

  • projectAdmin: Administrative address for project operations

  • addressRegistry: Central registry for Legion infrastructure addresses

Access Control

Legion Operators

  • System administration and emergency intervention

  • Sale result publication and parameter updates

  • Position management and transfer authorization

Project Administrators

  • Sale cancellation 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

  • Refund status and settlement state

  • Vesting contract address assignment

  • Excess capital claim status

Sale Status

Global sale state includes:

  • Total capital invested across all participants

  • Total tokens allocated for distribution

  • Total capital accepted and raised

  • Token supply and capital withdrawal status

Verification Mechanisms

Signature Verification

Investment operations require cryptographic signatures from authorized Legion signers to prevent unauthorized participation and ensure compliance with access controls.

Merkle Proof Systems

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

Error Conditions

The contract implements comprehensive error handling for:

  • Invalid parameter configurations during initialization

  • Timing violations across different sale phases

  • Access control violations and unauthorized operations

  • State inconsistencies and duplicate operations

  • Insufficient balances and transfer failures

Event Emission

The contract emits detailed events for:

  • Investment processing with investor, amount, and timing data

  • Refund operations with transaction details

  • Token distribution including vesting and immediate allocations

  • Administrative operations and state changes

  • Error conditions and system alerts

Last updated