Formal Verification of a Token Sale Launchpad: A Compositional Approach in Dafny

Evgeny Ukhanov, Aurora Labs · 2025

Read Formal Verification of a Token Sale Launchpad: A Compositional Approach in Dafny by Evgeny Ukhanov, Aurora Labs (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2510-24798.txt.

Introduction

Evgeny Ukhanov, the sole author, proves core code for a token sale launch pad with math checks, not just tests. Such code sits in open finance systems, where a bug can drain funds at once. He wrote the code in Dafny, a tongue built for proof, and checked it step by step.

The proof work starts with base facts on whole number math, then builds up to sale rules. Those rules cover coin swaps, time based price cuts, and refunds when a sale cap is hit. Key proofs show refunds can never top what a user put in. Loss from round trips in the math is also shown to stay in a strict bound.

Catalog record

CREATOREvgeny Ukhanov, Aurora Labs
YEAR2025
COLLECTIONPAPERS
FORMATTXT
FILE SIZE104 KB
VERSION1.0
LICENSEhttp://creativecommons.org/licenses/by/4.0/
RIGHTSCC BY
SOURCEarXiv

Source: https://arxiv.org/abs/2510-24798

Browse the full library · About the Tower of Babel

Full text

The opening of the work, from the library's hosted text:

Formal Verification of a Token Sale Launchpad: A Compositional Approach in Dafny Evgeny Ukhanov, Aurora Labs Abstract Abstract The proliferation of decentralized financial (DeFi) systems and smart contracts has underscored the critical need for software correctness. Bugs in such systems can lead to catastrophic financial losses. Formal verification offers a path to achieving mathematical certainty about software behavior [ 1 ] . This paper presents the formal verification of the core logic for a token sale launchpad, implemented and proven correct using the Dafny programming language and verification system. We detail a compositional, bottom-up verification strategy, beginning with the proof of fundamental non-linear integer arithmetic properties, and building upon them to verify complex business logic, including asset conversion, time-based discounts, and capped-sale refund mechanics. The principal contributions are the formal proofs of critical safety and lifecycle properties. Most notably, we prove that refunds in a capped sale can never exceed the user’s original deposit amount , and that the precision loss in round-trip financial calculations is strictly bounded. Furthermore, we verify the complete lifecycle logic, including user withdrawals under various sale mechanics and the correctness of post-sale token allocation, vesting, and claiming. This work serves as a comprehensive case study in applying rigorous verification techniques to build high-assurance financial software [ 2 ] . 1. Introduction The domain of financial software, particularly in the context of blockchain and smart contracts, operates under a unique and unforgiving paradigm: deployed code is often immutable, and flaws can be exploited for immediate and irreversible financial gain [ 2 , 3 ] . Traditional software testing, while essential, is inherently incomplete as it can only validate a finite set of execution paths. Formal verification addresses this limitation by using mathematical logic to prove properties about a program’s behavior across all possible inputs that satisfy its preconditions [ 4 , 5 ] . This paper focuses on the formal verification of a token sale launchpad contract. The core challenge lies in reasoning about complex interactions between multiple components: price-based asset conversions, application of percentage-based bonuses (discounts), and state transitions governed by sale mechanics (e.g., fixed-price vs. price discovery), all while handling the subtleties of integer arithmetic. Our tool of choice is Dafny , a verification-aware programming language that integrates specification and implementation [ 6 ] . Dafny allows programmers to annotate their code with formal contracts, such as preconditions ( requires ), postconditions ( ensures ), and loop invariants ( invariant ). These annotations, along with the program code, are translated by the Dafny verifier into logical formulas, which are then dispatched to an automated Satisfiability Modulo Theories (SMT) solver, typically Z3 [ 7 ] . If the solver can prove all formulas, the program is deemed correct with respect to its specification. The primary objective of this work is to construct a fully verified model of the launchpad’s core logic. We demonstrate how a carefully layered architecture enables the verification of a complex system by decomposing the proof effort into manageable, reusable components. We will present the key modules, the mathematical properties they guarantee, and the overarching safety lemmas that emerge from their composition. 2. System Architecture and Verification Strategy The verification effort is structured around a compositional, bottom-up approach , which is crucial for managing complexity [ 8 , 9 ] . The system is decomposed into a hierarchy of modules, where each higher-level module relies on the proven correctness of the modules below it. This isolates reasoning and makes the overall verification problem tractable. The architecture consists of the following layers: 1. MathLemmas : The foundational layer. It provides proofs for fundamental, non-trivial properties of non-linear integer arithmetic (multiplication and division), which are not natively understood by SMT solvers. 2. AssetCalculations & Discounts : The business logic primitives layer. These modules define the core financial calculations (asset conversion, discount application) and use lemmas from MathLemmas to prove their essential properties, such as monotonicity and round-trip safety. 3. Config , Investments : The data modeling layer. These modules define the primary data structures of the system, including the main Config datatype which encapsulates all sale parameters and rules. 4. Deposit , Withdraw , Claim , Distribution : The workflow specification layer. These modules compose primitives from lower layers to define the complete, pure specifications for all user and administrative interactions, including deposits with refund logic, withdrawals, post-sale token claims with vesting, and stakeholder distributions. 5. Launchpad : The top-level state machine. This module defines the complete contract state and models all lifecycle transitions by orchestrating the verified workflows from the layer below. A key pattern employed throughout the codebase is the Specification-Implementation Separation [ 10 ] . For most critical operations, a function ending in ...Spec defines the pure mathematical contract. This allows us to reason about the system’s logic at an abstract, mathematical level. 3. Foundational Layer: Verification of Non-Linear Integer Arithmetic Reasoning about the multiplication and division of integers is a well-known challenge in automated verification [ 11 , 12 ] . SMT solvers are highly effective for linear integer arithmetic, but non-linear properties often require explicit proof guidance. The MathLemmas module provides this guidance by establishing a set of trusted, reusable lemmas for the rest of the system. The core of financial calculations in this system is scaling a value x by a rational factor y/k , implemented using integer arithmetic as (x\cdot y)/k . The following key lemmas were proven from first principles: • Monotonicity with Favorable Scaling ( Lemma_MulDivGreater_From_Scratch ): This lemma proves that if the scaling factor is greater than or equal to 1, the result is no less than the original amount. – Property 1. \forall x,y,k\in\mathbb{N} where x>0 , k>0 , and y\geq k \frac{x\cdot y}{k}\geq x This is crucial for proving that conversions at a stable or favorable price do not result in a loss of principal. • Strict Monotonicity with Highly Favorable Scaling ( Lemma_MulDivStrictlyGreater_From_Scratch ): Due to integer division truncation, y>k is insufficient to guarantee (x\cdot y)/k>x . This lemma establishes a stronger precondition to ensure a strict increase. – Property 2. \forall x,y,k\in\mathbb{N} where x>0 , k>0 , and y\geq 2k : \frac{x\cdot y}{k}>x This is used to prove that a significantly favorable price or a large bonus yields a tangible gain. • Round-trip Truncation and Bounded Loss ( Lemma_DivMul_Bounds ): This lemma formalizes the fundamental property of integer division: information may be lost, but this loss is strictly bounded. – Property 3. \forall x,y\in\mathbb{N} where y>0 : \left(\frac{x}{y}\right)\cdot y\leq x\quad\land\quad x-\left(\frac{x}{y}\right)\cdot y<y This property is the cornerstone for proving the safety of round-trip calculations. It not only guarantees that a reverse operation cannot create value, but also establishes a precise upper bound on the precision loss, which cannot exceed the value of the divisor y . These foundational lemmas abstract away the complexities of integer arithmetic, allowing higher-level modules to reason about calculations in terms of simple inequalities. 4. Core Business Logic Verification Building upon the MathLemmas foundation, we verify the core business logic components. 4.1. Asset Conversion ( AssetCalculations ) This module defines the logic for converting a base amount into assets based on a price fraction saleToken / depositToken . The specification is: CalculateAssetsSpec(amount, dT, sT) := (amount

Read the complete text