sponsor logo

First Flight #8

Completed

First Flight #8: Math Master

The math MASTERS are titans of the algebraic and gas efficient. This small library of hyper-optimized functions hopes to allow developers to make better codebases!

Start Date Jan 25th, 2024 (12:00)
End Date Feb 2nd, 2024 (12:00)
Time Left 0d/0h/0m
Rewards

math-master

Contest Details

Prize Pool

  • High - 100xp

  • Medium - 20xp

  • Low - 2xp

  • Starts: January 25, 2024 Noon UTC

  • Ends: February 02, 2024 Noon UTC

Stats

  • nSLOC: 46
  • Complexity Score: 276

Math Master

This codebase was inspired by the solady, obront.eth, and solmate codebases. Huge thanks to karma for the help on FV with Halmos.... which may be a hint.

We will teach how to do Formal Verification and assembly in the upcoming Cyfrin Updraft course.

About

Welcome to the future of web3! We, the math MASTERS are titans of the algebraic and gas efficient. We have created a small library called MathMasters where we have the following functions/terms defined:

  • WAD: fixed point decimal with 18 decimals (for basic quantities, e.g. balances)
  • mulWad: Equivalent to (x * y) / WAD rounded down.
  • mulWadUp: Equivalent to (x * y) / WAD rounded up.
  • sqrt: Returns the square root of x.

We hope that people will use our hype optimized functions to make better codebases.

We are especially concerned with any function doing something "weird" at the EVM/assembly level. We would consider any of the following a valid LOW severity rating:

We expect any solidity project using version ^0.8.3 or above should be able to use our codebase. If not, that should be considered a vulnerability as well.

This is a great chance to test out your fuzzing and Formal Verification skills.

Getting Started

Requirements

  • git
    • You'll know you did it right if you can run git --version and you see a response like git version x.x.x
  • foundry
    • You'll know you did it right if you can run forge --version and you see a response like forge 0.2.0 (816e00b 2023-03-16T00:05:26.396218Z)
  • Halmos
    • To know you've installed it run halmos --version and you should see something like `halmos 0.1.0 (816e00b 2023-03-16T00:05:26.396218Z)

Quickstart

git clone https://github.com/Cyfrin/2024-01-math-master
cd 2024-01-math-master
make

Usage

Testing

forge test

Test Coverage

forge coverage

and for coverage based testing:

forge coverage --report debug

Audit Scope Details

  • Commit Hash:
  • In Scope: (For this contest, just use the main branch)
Hash:

Compatibilities

  • Solc Version: 0.8.3 < 0.9.0
  • Chain(s) to deploy contract to:
    • Ethereum
  • Tokens:
    • None

Roles

None

Known Issues

None