UTILS Contract


This function is used to determine the amount of LP tokens minted by a liquidity add

LPunits=((P(tB+Tb))/(2TB))slipAdjustmentLP units = ((P (t B + T b))/(2 T B)) * slipAdjustment

b = SPARTA units being added

B = SPARTA units already in the pool

t = TOKEN units being added

T = TOKEN units already in the pool

P = Total LP token units in existence (Total supply)

function calcLiquidityUnits(uint b, uint B, uint t, uint T, uint P) external view returns (uint units){
if(P == 0){
return b; // If pool is empty; use b as initial units
} else {
uint slipAdjustment = getSlipAdustment(b, B, t, T);
uint part1 = t*(B);
uint part2 = T*(b);
uint part3 = T*(B)*(2);
uint _units = (P * (part1 + (part2))) / (part3);
return _units * slipAdjustment / one;