The core contracts make use of several libraries, including ABDK64x64, a fixed point math library.
- CumulativeNormalDistribution: Implements a CDF and Inverse CDF (Quantile) function using approximations and the ABDK Math Library.
- ReplicationMath: Implements the AMM specific math, like the trading function and invariant calculation.
- Margin: Handles data struct and manipulation of internal token balance accounts.
- Reserve: Handles data struct and manipulation of the pool reserves, as well as the TWAP oracle data.
- SafeCast: UInt256 are often casted down to UInt128s, to pack struct data into a single storage slot. This library will perform checks when casting down to ensure the values stay the same.
- Transfers: Implements a
safeTransferhelper function to be used in place of
erc20.transfer, which checks the returnData on calls.
- Units: Helper functions to convert between 64x64 fixed point numbers and units.