DragonSwap
  • Getting Started
    • ๐Ÿ‘‹Welcome to DragonSwap
    • ๐Ÿ’ฐHow to Create & Connect a Wallet
    • ๐Ÿช™Approving Tokens
    • ๐Ÿ”ดSei V2 EVM
  • Guides
    • Trading
      • ๐Ÿ’ฑHow to Swap
      • ๐ŸŽHow to Wrap SEI
      • ๐ŸŽ€How to Unwrap SEI
    • Liqudity Providers
      • ๐ŸŒŠHow to Add Liquidity
      • โ˜”How to Remove Liquidity
      • ๐ŸŠHow to Deploy New Pools
      • ๐Ÿ“‰Understanding Impermanent Loss
      • ๐Ÿซ—V2: Concentrated Liquidity Pools
      • ๐Ÿค–Automated Liquidity Managers (ALM)
    • Farms
      • ๐Ÿฅ•Depositing to Farm
      • ๐Ÿง‘โ€๐ŸŒพWithdrawing from Farm
      • ๐Ÿช™Claiming Rewards
      • ๐Ÿš€Boosted Farms
    • Predictions
      • ๐Ÿ”ฎHow to use Predictions
      • ๐ŸงžHow Predictions work?
      • โ“Predictions FAQ
    • Analytics
      • ๐ŸŠPools
      • ๐Ÿฅ•Farms
      • ๐Ÿช™Tokens
  • DragonSwap Token
    • Token & Tokenomics
    • How to Stake
    • DragonSwap Points
    • Protocol Rewards
  • Resources
    • ๐Ÿ’ปDeveloper Resources
      • ๐Ÿ“„Smart Contracts
        • DragonswapV1
          • Factory
          • Pair
          • Pair(ERC-20)
          • Library
          • Router
          • Audit
        • DragonswapV2
          • Core
            • DragonswapV2Factory
            • DragonswapV2Pool
            • DragonswapV2PoolDeployer
            • Interfaces
              • IERC20Minimal
              • IDragonswapV2Factory
              • IDragonswapV2Pool
              • IDragonswapV2PoolDeployer
              • Callbacks
                • IDragonswapV2FlashCallback
                • IDragonswapV2MintCallback
                • IDragonswapV2SwapCallback
              • Pool
                • IDragonswapV2PoolActions
                • IDragonswapV2PoolDerivedState
                • IDragonswapV2PoolEvents
                • IDragonswapV2PoolImmutables
                • IDragonswapV2PoolOwnerActions
                • IDragonswapV2PoolState
            • Libraries
              • BitMath
              • FixedPoint128
              • FixedPoint96
              • FullMath
              • LiquidityMath
              • LowGasSafeMath
              • Oracle
              • Position
              • SafeCast
              • SecondsOutside
              • SqrtPriceMath
              • SwapMath
              • Tick
              • TickBitmap
              • TickMath
              • TransferHelper
              • UnsafeMath
          • Periphery
            • Base
              • BlockTimestamp
              • ERC721Permit
              • LiquidityManagement
              • Multicall
              • PeripheryImmutableState
              • PeripheryPayments
              • PeripheryPaymentsWithFee
              • PoolInitializer
              • SelfPermit
            • Interfaces
              • IERC20Metadata
              • IERC721Permit
              • IMulticall
              • INonfungiblePositionManager
              • INonfungibleTokenPositionDescriptor
              • IPeripheryImmutableState
              • IPeripheryPayments
              • IPeripheryPaymentsWithFee
              • IPoolInitializer
              • IQuoter
              • IQuoterV2
              • ISelfPermit
              • ISwapRouter
              • ITickLens
              • IV2Migrator
              • External
                • IERC1271
                • IERC20PermitAllowed
                • IWSEI
            • Lens
              • Quoter
              • QuoterV2
              • TickLens
            • Libraries
              • Base64
              • BytesLib
              • CallbackValidation
              • ChainId
              • HexStrings
              • LiquidityAmounts
              • NFTDescriptor
              • NFTSVG
              • OracleLibrary
              • Path
              • PoolAddress
              • PoolTicksCounter
              • PositionKey
              • TransferHelper
            • NonfungiblePositionManager
            • NonfungibleTokenPositionDescriptor
            • SwapRouter
            • V2Migrator
            • Error Codes
          • Staker
            • Overview
            • DragonswapV2Staker
            • Interfaces
              • IDragonswapV2Staker
            • Libraries
              • IncentiveId
              • NFTPositionInfo
              • RewardMath
          • Smart Router
            • Base
              • ApproveAndCall
              • ImmutableState
              • MulticallExtended
              • OracleSlippage
              • PeripheryPaymentsExtended
              • PeripheryPaymentsWithFeeExtended
              • PeripheryValidationExtended
            • Interfaces
              • IApproveAndCall
              • IImmutableState
              • IMixedRouteQuoterV1
              • IMulticallExtended
              • IOracleSlippage
              • IPeripheryPaymentsExtended
              • IPeripheryPaymentsWithFeeExtended
              • IQuoter
              • IQuoterV2
              • ISwapRouter02
              • ITokenValidator
              • IV1SwapRouter
              • IV2SwapRouter
            • Lens
              • MixedRouteQuoterV1
              • Quoter
              • QuoterV2
              • TokenValidator
            • Libraries
              • Constants
              • DragonswapLibrary
              • PoolTicksCounter
            • V1SwapRouter
            • V2SwapRouter
            • SwapRouter02
          • Audit
    • โฃ๏ธMarketing Resources
      • ๐ŸšฉBrand Guidelines
      • ๐Ÿ˜‚Meme Library
      • ๐Ÿค—DragonSwap Ambassador Program
  • FAQ
    • ๐Ÿ“ฒOfficial Links
    • ๐Ÿ“„Contract Addresses
      • DragonswapV1
      • DragonswapV2
      • Predictions
    • โœจRoadmap
    • ๐Ÿ“„ Token Listing Policy
    • ๐Ÿ›๏ธToS
Powered by GitBook
On this page
  1. Resources
  2. Developer Resources
  3. Smart Contracts
  4. DragonswapV2
  5. Core
  6. Libraries

FullMath

PreviousFixedPoint96NextLiquidityMath

Last updated 9 months ago

Facilitates multiplication and division that can have overflow of an intermediate value without any loss of precision

Handles "phantom overflow" i.e., allows multiplication and division where an intermediate value overflows 256 bits

Functions

mulDiv

  function mulDiv(
    uint256 a,
    uint256 b,
    uint256 denominator
  ) internal pure returns (uint256 result)

Calculates floor(aร—bรทdenominator) with full precision. Throws if result overflows a uint256 or denominator == 0

Credit to Remco Bloemen under MIT license

Parameters:

Name
Type
Description

a

uint256

The multiplicand

b

uint256

The multiplier

denominator

uint256

The divisor

Return Values:

Name
Type
Description

result

uint256

The 256-bit result

mulDivRoundingUp

  function mulDivRoundingUp(
    uint256 a,
    uint256 b,
    uint256 denominator
  ) internal pure returns (uint256 result)

Calculates ceil(aร—bรทdenominator) with full precision. Throws if result overflows a uint256 or denominator == 0

Name
Type
Description

a

uint256

The multiplicand

b

uint256

The multiplier

denominator

uint256

The divisor

Name
Type
Description

result

uint256

The 256-bit result

Parameters:

Return Values:

๐Ÿ’ป
๐Ÿ“„
โ€‹
โ€‹
https://xn--2-umb.com/21/muldiv
โ€‹
โ€‹
โ€‹
โ€‹
โ€‹