Mento Protocol
Search
K

Pricing Modules

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

Xp+Y=K(X+x)p+Yy=KX * p + Y = K \newline (X +x)*p + Y-y = K
Where
XX
is the bucket size of TokenIn,
YY
is the bucket size of TokenOut,
xx
is the amountIn,
yy
is the amountOut,
KK
is a constant, and
pp
is the value of tokenIn quoted in tokenOut.
ConstantSumPricingModule is an IPricingModule that implements a constant-sum pricing formula for a two-asset pool.

ConstantProductPricingModule

XpY=K(X+x)p(Yy)=KX*p*Y=K \newline (X + x)*p*( Y - y) = K
Where
XX
is the bucket size of TokenIn,
YY
is the bucket size of TokenOut,
xx
is the amountIn,
yy
is the amountOut,
KK
is a constant, and
pp
is the value of tokenIn quoted in tokenOut.
ConstantProductPricingModule is an IPricingModule that implements a constant-product pricing formula for a two-asset pool.