Technical Architecture

LBP Platform Architecture

BioFoundry's LBP platform is built on a modular contract architecture with three primary components:

Factory Contract ──────► LBP Pool Instances ──────► Treasury
     │                         │                      │
     ▼                         ▼                      ▼
Pool Deployment        Trading Execution         Fee Management

The pool implementation uses a proxy pattern with immutable arguments to optimize gas costs while maintaining isolation between pools.

Core Components

  1. Factory Contract: Handles pool creation, initializes parameters, and manages deployment

  2. LBP Pool Implementation: Core logic for handling trades, calculating weights, and managing lifecycle

  3. Treasury System: Collects and distributes platform fees

For concepts and mathematical foundations, see our LBP as Funding Engine document.

Weight Calculation Implementation

The internal weight calculation algorithm linearly interpolates between the start and end weights based on the current timestamp:

function _currentAssetWeight() internal view returns (uint256) {
    uint256 _saleStart = saleStart();
    uint256 _saleEnd = saleEnd();
    uint256 _now = block.timestamp;
    
    if (_now <= _saleStart) return weightStart();
    if (_now >= _saleEnd) return weightEnd();
    
    return weightStart() + 
           ((_now - _saleStart) * (weightEnd() - weightStart())) / 
           (_saleEnd - _saleStart);
}

When executing a swap, the implementation follows this flow:

  1. Validate constraints (timing, amounts, caps)

  2. Calculate current weights based on timestamp

  3. Compute trade amounts using weighted math formulas

  4. Apply fees to the calculated amounts

  5. Transfer tokens and update reserves

  6. Emit swap events

Advanced Features

The platform supports several advanced features:

  • Merkle-based Whitelisting: Configurable access control using merkle proofs

  • Vesting Integration: Optional linear vesting for purchased tokens

  • Redemption Controls: Configurable delay periods for token redemption

Integration Guide

Trading Functions

The pool supports multiple trading functions depending on what parameters are being specified:

Price Estimation Functions

The pool provides functions to estimate trade outcomes before execution:

Reading Pool State

Events

The LBP protocol emits events for all major operations to enable proper tracking and integration:

These events provide a complete record of all trading activity and lifecycle changes for LBP pools.

Last updated