Mento Protocol
  • Mento Protocol
    • Home
    • What, why, who Mento?
    • Quick Links
  • HOW TO SOURCE MENTO STABLES
    • Overview
    • CEXs, DEXs, Pools
    • From other Chains
    • On-ramp Providers
    • Automation via MATE
  • Protocol Concepts
    • Stability
    • Reserve
    • Asset exchanges
      • Broker
      • Trading Limits
      • Exchange Providers
      • BiPoolManager
    • Oracles
    • On-Chain Circuit Breaker
    • Governance
      • Verification
  • Developers
    • Repository Overview
    • Integrate Mento Stables
    • Smart Contracts
      • Broker
      • TradingLimits
      • BiPoolManager
      • Pricing Modules
      • SortedOracles
      • BreakerBox
      • Reserve
      • StableToken
      • Audits
    • Deployments
      • Addresses
      • Verification
      • Parameters
    • Mento SDK
      • Installation
      • Guides
        • Getting Exchange Pairs
        • Getting a Quote
        • Initiating a Swap
    • Oracles
      • Oracle Client
        • Price Sources
      • Becoming an Oracle Provider
  • Economics
    • Stability
    • Risks
    • Research
  • Governance & Token
    • Overview
    • Governance Components
    • Governance Scope
    • MENTO Token
      • Listing information
    • Airdrop
    • Governance Watchdogs
Powered by GitBook
On this page
  • ConstantSumPricingModule
  • ConstantProductPricingModule
Edit on GitHub
  1. Developers
  2. Smart Contracts

Pricing Modules

PreviousBiPoolManagerNextSortedOracles

Last updated 1 year ago

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);

ConstantSumPricingModule

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

ConstantProductPricingModule

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

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.

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.

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