vdAMM - Dependencies

SafeMath.sol

The file defines a Solidity library called SafeMath which provides safe mathematical operations that prevent integer overflow. It includes operations such as addition, subtraction, multiplication, division, and modulo. These operations revert the transaction when an overflow occurs, which helps to eliminate a class of bugs that can occur due to overflow.

SafeMath

A library for safe mathematical operations that prevent integer overflow.

add

function add(uint256 a, uint256 b) internal pure returns (uint256)

Returns the sum of two unsigned integers, reverting on overflow.

Parameters

  • a uint256: The first number to add.
  • b uint256: The second number to add.

Return Values

  • uint256: The sum of inputs a and b.

Errors

  • SafeMath: addition overflow: Error is thrown if the addition of input numbers results in overflow.

sub

function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256)

Returns the subtraction of two unsigned integers, reverting on overflow (when the result is negative).

Parameters

  • a uint256: The number from which to subtract.
  • b uint256: The number to subtract.
  • errorMessage string: Custom error message when subtraction results in overflow.

Return Values

  • uint256: The result of a - b.

Errors

  • SafeMath: subtraction overflow: Error is thrown if the subtraction of input numbers results in overflow.

mul

function mul(uint256 a, uint256 b) internal pure returns (uint256)

Returns the multiplication of two unsigned integers, reverting on overflow.

Parameters

  • a uint256: The first number to multiply.
  • b uint256: The second number to multiply.

Return Values

  • uint256: The product of a and b.

Errors

  • SafeMath: multiplication overflow: Error is thrown if the multiplication of input numbers results in overflow.

div

function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256)

Returns the integer division of two unsigned integers, reverting on division by zero.

Parameters

  • a uint256: The number to be divided.
  • b uint256: The number to divide by.
  • errorMessage string: Custom error message when division by zero occurs.

Return Values

  • uint256: The quotient of a divided by b.

Errors

  • SafeMath: division by zero: Error is thrown if division by zero occurs.

mod

function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256)

Returns the remainder of dividing two unsigned integers, reverting when dividing by zero.

Parameters

  • a uint256: The number for which to find the remainder.
  • b uint256: The number to divide by.
  • errorMessage string: Custom error message when division by zero occurs.

Return Values

  • uint256: The remainder of a divided by b.

Errors

  • SafeMath: modulo by zero: Error is thrown if modulo by zero occurs.
Previous
SafeERC20.sol