Mento Protocol
  • Overview
    • Getting Started
      • What Is Mento?
      • Quick Start Guides
      • Analytics & Dashboards
    • Core Concepts
      • Stability Mechanisms
      • The Reserve
      • Oracles & Price Feeds
      • Trading Limits & Circuit Breakers
      • The Broker & Virtual AMMs
      • Fixed-Price Market Makers (FPMMs)
      • Research & Economics
    • Governance & the MENTO Token
      • Understanding Mento Governance
      • Participating in Governance
        • veMENTO & Voting Power
        • Creating Proposals
        • Voting Process
      • MENTO Tokenomics
      • Watchdogs & Safety
    • Security & Risk
      • Overview
      • Audit Reports
  • Build On Mento
    • Integration Overview
      • Integrate Stables
      • Integrate the Broker
      • Integrate Oracles
    • Mento SDK
      • Installation
      • Guides
        • Getting Exchange Pairs
        • Getting a Quote
        • Initiating a Swap
    • Smart Contracts
      • Broker
      • TradingLimits
      • BiPoolManager
      • Pricing Modules
      • SortedOracles
      • BreakerBox
      • Reserve
      • StableToken
      • Audits
    • Deployments
      • Addresses
      • Verification
  • Use Mento
    • Getting Mento Stables
      • On Celo
      • On Mobile
      • From Other Chains
      • Via Centralized Exchanges
Powered by GitBook
On this page
Edit on GitHub
  1. Build On Mento
  2. Smart Contracts

Pricing Modules

PreviousBiPoolManagerNextSortedOracles

Last updated 2 years ago

CtrlK
  • ConstantSumPricingModule
  • ConstantProductPricingModule

Pricing Modules are utility contracts that implement the IPricingModule interface and are used by the BiPoolManager during swaps to price the swaps. A pricing module has to implement two functions:

uint256 amountOut = pricingModule.getAmountOut(inBucket, outBucket, spread, amountIn);
uint256 amountIn = pricingModule.getAmountIn(inBucket, outBucket, spread, amountOut);
https://github.com/mento-protocol/mento-core/blob/main/contracts/interfaces/IPricingModule.sol
IPricingModule.sol

ConstantSumPricingModule

X∗p+Y=K(X+x)∗p+Y−y=KX * p + Y = K \newline (X +x)*p + Y-y = KX∗p+Y=K(X+x)∗p+Y−y=K

Where XXXis the bucket size of TokenIn, YYYis the bucket size of TokenOut, xxx is the amountIn, yyy is the amountOut, KKKis a constant, and ppp is the value of tokenIn quoted in tokenOut.

ConstantSumPricingModule is an IPricingModule that implements a constant-sum pricing formula for a two-asset pool.

https://github.com/mento-protocol/mento-core/blob/main/contracts/swap/ConstantSumPricingModule.sol
ConstantSumPricingModule.sol

ConstantProductPricingModule

X∗p∗Y=K(X+x)∗p∗(Y−y)=KX*p*Y=K \newline (X + x)*p*( Y - y) = KX∗p∗Y=K(X+x)∗p∗(Y−y)=K

Where XXXis the bucket size of TokenIn, YYYis the bucket size of TokenOut, xxxis the amountIn, yyy is the amountOut, KKKis a constant, and ppp is the value of tokenIn quoted in tokenOut.

ConstantProductPricingModule is an IPricingModule that implements a constant-product pricing formula for a two-asset pool.

https://github.com/mento-protocol/mento-core/blob/main/contracts/swap/ConstantProductPricingModule.sol
ConstantProductPricingModule.sol