Skip to content

Commit

Permalink
fix: bmath.sol comments
Browse files Browse the repository at this point in the history
  • Loading branch information
0xAustrian committed May 3, 2024
1 parent b96b58d commit 1f827f7
Showing 1 changed file with 57 additions and 57 deletions.
114 changes: 57 additions & 57 deletions src/contracts/BMath.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ import './BNum.sol';
contract BMath is BBronze, BConst, BNum {
/**
*
* // calcSpotPrice //
* // sP = spotPrice //
* // bI = tokenBalanceIn ( bI / wI ) 1 //
* // bO = tokenBalanceOut sP = ----------- * ---------- //
* // wI = tokenWeightIn ( bO / wO ) ( 1 - sF ) //
* // wO = tokenWeightOut //
* // sF = swapFee //
* calcSpotPrice
* sP = spotPrice
* bI = tokenBalanceIn ( bI / wI ) 1
* bO = tokenBalanceOut sP = ----------- * ----------
* wI = tokenWeightIn ( bO / wO ) ( 1 - sF )
* wO = tokenWeightOut
* sF = swapFee
*
*/
function calcSpotPrice(
Expand All @@ -43,14 +43,14 @@ contract BMath is BBronze, BConst, BNum {

/**
*
* // calcOutGivenIn //
* // aO = tokenAmountOut //
* // bO = tokenBalanceOut //
* // bI = tokenBalanceIn / / bI \ (wI / wO) \ //
* // aI = tokenAmountIn aO = bO * | 1 - | -------------------------- | ^ | //
* // wI = tokenWeightIn \ \ ( bI + ( aI * ( 1 - sF )) / / //
* // wO = tokenWeightOut //
* // sF = swapFee //
* calcOutGivenIn
* aO = tokenAmountOut
* bO = tokenBalanceOut
* bI = tokenBalanceIn / / bI \ (wI / wO) \
* aI = tokenAmountIn aO = bO * | 1 - | -------------------------- | ^ |
* wI = tokenWeightIn \ \ ( bI + ( aI * ( 1 - sF )) / /
* wO = tokenWeightOut
* sF = swapFee
*
*/
function calcOutGivenIn(
Expand All @@ -73,14 +73,14 @@ contract BMath is BBronze, BConst, BNum {

/**
*
* // calcInGivenOut //
* // aI = tokenAmountIn //
* // bO = tokenBalanceOut / / bO \ (wO / wI) \ //
* // bI = tokenBalanceIn bI * | | ------------ | ^ - 1 | //
* // aO = tokenAmountOut aI = \ \ ( bO - aO ) / / //
* // wI = tokenWeightIn -------------------------------------------- //
* // wO = tokenWeightOut ( 1 - sF ) //
* // sF = swapFee //
* calcInGivenOut
* aI = tokenAmountIn
* bO = tokenBalanceOut / / bO \ (wO / wI) \
* bI = tokenBalanceIn bI * | | ------------ | ^ - 1 |
* aO = tokenAmountOut aI = \ \ ( bO - aO ) / /
* wI = tokenWeightIn --------------------------------------------
* wO = tokenWeightOut ( 1 - sF )
* sF = swapFee
*
*/
function calcInGivenOut(
Expand All @@ -103,14 +103,14 @@ contract BMath is BBronze, BConst, BNum {

/**
*
* // calcPoolOutGivenSingleIn //
* // pAo = poolAmountOut / \ //
* // tAi = tokenAmountIn /// / // wI \ \\ \ wI \ //
* // wI = tokenWeightIn //| tAi *| 1 - || 1 - -- | * sF || + tBi \ -- \ //
* // tW = totalWeight pAo=|| \ \ \\ tW / // | ^ tW | * pS - pS //
* // tBi = tokenBalanceIn \\ ------------------------------------- / / //
* // pS = poolSupply \\ tBi / / //
* // sF = swapFee \ / //
* calcPoolOutGivenSingleIn
* pAo = poolAmountOut / \
* tAi = tokenAmountIn /// / // wI \ \\ \ wI \
* wI = tokenWeightIn //| tAi *| 1 - || 1 - -- | * sF || + tBi \ -- \
* tW = totalWeight pAo=|| \ \ \\ tW / // | ^ tW | * pS - pS
* tBi = tokenBalanceIn \\ ------------------------------------- / /
* pS = poolSupply \\ tBi / /
* sF = swapFee \ /
*
*/
function calcPoolOutGivenSingleIn(
Expand Down Expand Up @@ -141,14 +141,14 @@ contract BMath is BBronze, BConst, BNum {

/**
*
* // calcSingleInGivenPoolOut //
* // tAi = tokenAmountIn //(pS + pAo)\ / 1 \\ //
* // pS = poolSupply || --------- | ^ | --------- || * bI - bI //
* // pAo = poolAmountOut \\ pS / \(wI / tW)// //
* // bI = balanceIn tAi = -------------------------------------------- //
* // wI = weightIn / wI \ //
* // tW = totalWeight | 1 - ---- | * sF //
* // sF = swapFee \ tW / //
* calcSingleInGivenPoolOut
* tAi = tokenAmountIn //(pS + pAo)\ / 1 \\
* pS = poolSupply || --------- | ^ | --------- || * bI - bI
* pAo = poolAmountOut \\ pS / \(wI / tW)//
* bI = balanceIn tAi = --------------------------------------------
* wI = weightIn / wI \
* tW = totalWeight | 1 - ---- | * sF
* sF = swapFee \ tW /
*
*/
function calcSingleInGivenPoolOut(
Expand Down Expand Up @@ -178,15 +178,15 @@ contract BMath is BBronze, BConst, BNum {

/**
*
* // calcSingleOutGivenPoolIn //
* // tAo = tokenAmountOut / / \\ //
* // bO = tokenBalanceOut / // pS - (pAi * (1 - eF)) \ / 1 \ \\ //
* // pAi = poolAmountIn | bO - || ----------------------- | ^ | --------- | * b0 || //
* // ps = poolSupply \ \\ pS / \(wO / tW)/ // //
* // wI = tokenWeightIn tAo = \ \ // //
* // tW = totalWeight / / wO \ \ //
* // sF = swapFee * | 1 - | 1 - ---- | * sF | //
* // eF = exitFee \ \ tW / / //
* calcSingleOutGivenPoolIn
* tAo = tokenAmountOut / / \\
* bO = tokenBalanceOut / // pS - (pAi * (1 - eF)) \ / 1 \ \\
* pAi = poolAmountIn | bO - || ----------------------- | ^ | --------- | * b0 ||
* ps = poolSupply \ \\ pS / \(wO / tW)/ //
* wI = tokenWeightIn tAo = \ \ //
* tW = totalWeight / / wO \ \
* sF = swapFee * | 1 - | 1 - ---- | * sF |
* eF = exitFee \ \ tW / /
*
*/
function calcSingleOutGivenPoolIn(
Expand Down Expand Up @@ -219,15 +219,15 @@ contract BMath is BBronze, BConst, BNum {

/**
*
* // calcPoolInGivenSingleOut //
* // pAi = poolAmountIn // / tAo \\ / wO \ \ //
* // bO = tokenBalanceOut // | bO - -------------------------- |\ | ---- | \ //
* // tAo = tokenAmountOut pS - || \ 1 - ((1 - (tO / tW)) * sF)/ | ^ \ tW / * pS | //
* // ps = poolSupply \\ -----------------------------------/ / //
* // wO = tokenWeightOut pAi = \\ bO / / //
* // tW = totalWeight ------------------------------------------------------------- //
* // sF = swapFee ( 1 - eF ) //
* // eF = exitFee //
* calcPoolInGivenSingleOut
* pAi = poolAmountIn // / tAo \\ / wO \ \
* bO = tokenBalanceOut // | bO - -------------------------- |\ | ---- | \
* tAo = tokenAmountOut pS - || \ 1 - ((1 - (tO / tW)) * sF)/ | ^ \ tW / * pS |
* ps = poolSupply \\ -----------------------------------/ /
* wO = tokenWeightOut pAi = \\ bO / /
* tW = totalWeight -------------------------------------------------------------
* sF = swapFee ( 1 - eF )
* eF = exitFee
*
*/
function calcPoolInGivenSingleOut(
Expand Down

0 comments on commit 1f827f7

Please sign in to comment.