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);
IPricingModule.sol

ConstantSumPricingModule

x+y=k(Δx+x)+(Δy+y)=x+yΔx=Δyx+y=k \newline (\Delta x + x )+ (\Delta y + y) = x + y \newline \Delta x = - \Delta y

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

ConstantSumPricingModule.sol

ConstantProductPricingModule

xy=k(Δx+x)(Δy+y)=xyΔxΔy+Δxy+Δyx+xy=xyΔx(Δy+y)=ΔyxΔx=Δyx/(Δy+y)x*y=k \newline (\Delta x + x)*( \Delta y + y) = x * y \newline \Delta x * \Delta y + \Delta x * y + \Delta y * x + x * y = x*y \newline \Delta x ( \Delta y + y ) = - \Delta y * x \newline \Delta x = - \Delta y * x / (\Delta y + y)

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

ConstantProductPricingModule.sol

Last updated

#6: 's Mar 28 changes

Change request updated