Mangrove
Developper
Developper
  • Welcome
  • Protocol
    • Introduction
    • Technical References
      • Overview
      • Ticks, ratios, and prices
      • Offer-list
        • Views on offers
      • Market-order
        • Delegation
      • Creating & Updating offers
        • Maker contract
        • Offer provisions
        • Gas requirement
        • Public data structures
        • Executing offers
      • Cleaning offers
      • Governance-parameters
        • Global variables
        • Local variables
        • Data structures and views
      • Periphery Contracts
        • MgvReader
        • MgvOracle
      • Literate Source Code
    • Background
      • Taking available liquidity
      • Making liquidity available
      • Reneging on offers
  • Strat Lib
    • What is the Strat Library?
    • Getting-started
      • Set Up Your Local Environment
      • Post a Smart Offer
    • Guides
      • Unlocking liquidity
      • Reposting an offer in the posthook
      • Using last look to renege trades
      • Determining gas requirements
      • Creating a Direct contract
      • Deploying your contract
      • Testing a maker contract
      • Safe offer logic guidelines
      • Approvals
    • Technical references
      • Principal hooks
      • Liquidity routing
      • API preferences
        • Core
          • SRC
            • IMangrove
        • Strats
          • SRC
            • Strategies
              • MangroveOffer
              • MangroveOrder
              • Integrations
                • AaveV3Borrower
                • AaveV3BorrowerImplementation
                • AaveV3BorrowerStorage
                • AaveV3Lender
                • CompoundModule
              • Interfaces
                • IForwarder
                • ILiquidityProvider
                • IOfferLogic
                • IOrderLogic
              • Offer_forwarder
                • Abstract
                  • Forwarder
              • Offer_maker
                • Abstract
                  • Direct
                • Market_making
                  • Kandel
                    • AaveKandel
                    • AaveKandelSeeder
                    • KandelSeeder
                    • Abstract
                      • AbstractKandelSeeder
                      • CoreKandel
                      • DirectWithBidsAndAsksDistribution
                      • GeometricKandel
                      • HasIndexedBidsAndAsks
                      • KandelLib
                      • TradesBaseQuotePair
              • Routeurs
                • SimpleRouter
                • Abstract
                  • AbstractRouter
                • Integrations
                  • AavePooledRouter
                  • HasAaveBalanceMemoizer
              • Utils
                • AccessControlled
              • Vendor
                • AAVE
                  • V3
                    • Contracts
                      • Dependencies
                        • Oppenzeppelin
                          • Contracts
                            • IERC20
                      • Interfaces
                        • IAToken
                        • IAaveIncentivesController
                        • IAaveOracle
                        • ICreditDelegationToken
                        • IInitializableAToken
                        • IPool
                        • IPoolAddressesProvider
                        • IPriceOracleGetter
                        • IScaledBalanceToken
                      • Protocol
                        • Libraries
                          • Configurations
                            • ReserveConfiguration
                          • Helpers
                            • Errors
                          • Types
                            • DataTypes
                    • Periphery
                      • Contracts
                        • MISC
                          • Interfaces
                            • IEACAggregatorProxy
                        • Rewards
                          • Interfaces
                            • IRewardsController
                            • IRewardsDistributor
                            • ITransferStrategyBase
                          • Libraries
                            • RewardsDataTypes
                • Compound
                  • CarefulMath
                  • Exponential
                  • ExponentialNoError
                  • ICompound
    • Background
      • Building Blocks
        • MangroveOffer
        • Direct
        • Forwarder
  • Vaults
    • Understanding vaults
      • Oracles
    • Managing a vault (CLI)
      • Deploying an oracle
      • Creating a vault
      • Monitoring the vault
      • Setting the vault position
      • Setting the fee data
      • Rebalancing
      • Adding or removing liquidity
    • Custom interactions
      • Oracles
      • Vault Factory
      • Managing a vault
        • Setting the position
        • Rebalancing
        • Setting a manager
        • Setting fee
  • Keeper Bots
    • Keeper Bots
    • Guides
      • Using borrowed funds for cleaning
    • Backgroud
      • The role of cleaning bots in Mangrove
      • The role of gas price updater bots in Mangrove
  • Adresses
    • Deployment Addresses
  • Quick Links
    • Glossary
    • Website
    • Whitepaper
Powered by GitBook
On this page
  • getExp
  • addExp
  • subExp
  • mulScalar
  • mulScalarTruncate
  • mulScalarTruncateAddUInt
  • divScalar
  • divScalarByExp
  • divScalarByExpTruncate
  • mulExp
  • mulExp
  • mulExp3
  • divExp
  1. Strat Lib
  2. Technical references
  3. API preferences
  4. Strats
  5. SRC
  6. Strategies
  7. Vendor
  8. Compound

Exponential

Exp is a struct which stores decimals with a fixed precision of 18 decimal places. Thus, if we wanted to store the 5.1, mantissa would store 5.1e18. That is:Exp({mantissa: 5100000000000000000}).

Legacy contract for compatibility reasons with existing contracts that still use MathError

getExp

function getExp(uint256 num, uint256 denom) internal pure returns (enum CarefulMath.MathError, struct ExponentialNoError.Exp)

Creates an exponential from numerator and denominator values. Note: Returns an error if (num * 10e18) > MAX_INT, or if denom is zero.

addExp

function addExp(struct ExponentialNoError.Exp a, struct ExponentialNoError.Exp b) internal pure returns (enum CarefulMath.MathError, struct ExponentialNoError.Exp)

Adds two exponentials, returning a new exponential.

subExp

function subExp(struct ExponentialNoError.Exp a, struct ExponentialNoError.Exp b) internal pure returns (enum CarefulMath.MathError, struct ExponentialNoError.Exp)

Subtracts two exponentials, returning a new exponential.

mulScalar

function mulScalar(struct ExponentialNoError.Exp a, uint256 scalar) internal pure returns (enum CarefulMath.MathError, struct ExponentialNoError.Exp)

Multiply an Exp by a scalar, returning a new Exp.

mulScalarTruncate

function mulScalarTruncate(struct ExponentialNoError.Exp a, uint256 scalar) internal pure returns (enum CarefulMath.MathError, uint256)

Multiply an Exp by a scalar, then truncate to return an unsigned integer.

mulScalarTruncateAddUInt

function mulScalarTruncateAddUInt(struct ExponentialNoError.Exp a, uint256 scalar, uint256 addend) internal pure returns (enum CarefulMath.MathError, uint256)

Multiply an Exp by a scalar, truncate, then add an to an unsigned integer, returning an unsigned integer.

divScalar

function divScalar(struct ExponentialNoError.Exp a, uint256 scalar) internal pure returns (enum CarefulMath.MathError, struct ExponentialNoError.Exp)

Divide an Exp by a scalar, returning a new Exp.

divScalarByExp

function divScalarByExp(uint256 scalar, struct ExponentialNoError.Exp divisor) internal pure returns (enum CarefulMath.MathError, struct ExponentialNoError.Exp)

Divide a scalar by an Exp, returning a new Exp.

divScalarByExpTruncate

function divScalarByExpTruncate(uint256 scalar, struct ExponentialNoError.Exp divisor) internal pure returns (enum CarefulMath.MathError, uint256)

Divide a scalar by an Exp, then truncate to return an unsigned integer.

mulExp

function mulExp(struct ExponentialNoError.Exp a, struct ExponentialNoError.Exp b) internal pure returns (enum CarefulMath.MathError, struct ExponentialNoError.Exp)

Multiplies two exponentials, returning a new exponential.

mulExp

function mulExp(uint256 a, uint256 b) internal pure returns (enum CarefulMath.MathError, struct ExponentialNoError.Exp)

Multiplies two exponentials given their mantissas, returning a new exponential.

mulExp3

function mulExp3(struct ExponentialNoError.Exp a, struct ExponentialNoError.Exp b, struct ExponentialNoError.Exp c) internal pure returns (enum CarefulMath.MathError, struct ExponentialNoError.Exp)

Multiplies three exponentials, returning a new exponential.

divExp

function divExp(struct ExponentialNoError.Exp a, struct ExponentialNoError.Exp b) internal pure returns (enum CarefulMath.MathError, struct ExponentialNoError.Exp)

Divides two exponentials, returning a new exponential. (a/scale) / (b/scale) = (a/scale) * (scale/b) = a/b, which we can scale as an Exp by calling getExp(a.mantissa, b.mantissa)

PreviousCarefulMathNextExponentialNoError