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);
{% embed url="https://github.com/mento-protocol/mento-core/blob/main/contracts/interfaces/IPricingModule.sol" %} IPricingModule.sol {% endembed %}
Where $$X$$is the bucket size of TokenIn, $$Y$$is the bucket size of TokenOut,
ConstantSumPricingModule is an IPricingModule that implements a constant-sum pricing formula for a two-asset pool.
{% embed url="https://github.com/mento-protocol/mento-core/blob/main/contracts/swap/ConstantSumPricingModule.sol" %} ConstantSumPricingModule.sol {% endembed %}
$$ XpY=K \newline (X + x)p( Y - y) = K $$
Where $$X$$is the bucket size of TokenIn, $$Y$$is the bucket size of TokenOut, $$x$$is the amountIn,
ConstantProductPricingModule is an IPricingModule that implements a constant-product pricing formula for a two-asset pool.
{% embed url="https://github.com/mento-protocol/mento-core/blob/main/contracts/swap/ConstantProductPricingModule.sol" %} ConstantProductPricingModule.sol {% endembed %}