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);
Where
is the bucket size of TokenIn,
is the bucket size of TokenOut,
is the amountIn,
is the amountOut,
is a constant, and
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
Where
is the bucket size of TokenIn,
is the bucket size of TokenOut,
is the amountIn,
is the amountOut,
is a constant, and
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
Last modified 1mo ago