# Cream Swap Smart Contract Diff ## Code on etherscan * [Cream Swap](https://etherscan.io/address/0xf8062eedf80d8d2527ce89435f670cb996ab4e54#code) * [Balancer](https://etherscan.io/address/0x9424B1412450D0f8Fc2255FAf6046b98213B76Bd#code) ## Global changes Error messages are removed in the contract to decrease bytecode size. This allows us to keep modifying the contract without changing any existing logic when we reached the maximum bytecode size(~24 KB) on EVM. ## Diff checker * BConst.sol: https://www.diffchecker.com/dvlI1xkx * Added default reserves ratio to be 0.2(i.e. 20%), which means 20% of swap fees are kept by the pool as reserves. * BFactory.sol: https://www.diffchecker.com/7GEfMsPT * Added a switch `_allowNonAdminPool` to [dis]allow non-admin open new pools(admin is the address who deployed the factory contract). * Reserves address: the address where the reserves go. * Added `_reservesAddress` and its getter and setter. Only the admin can change reserves address. * Added `collectTokenReserves(BPool pool)` which allows admin to move all reserves tokens in the pool to the reserves address. * BMath.sol: https://www.diffchecker.com/KpjuuxBc * Added `calcReserves` which calculates the amount of `reserves`. * Changed `calcPoolOutGivenSingleIn` and `calcPoolInGivenSingleOut` to calculate `reserves`, required by `joinswapExternAmountIn` and `exitswapExternAmountOut` respectively. * BNum.sol: https://www.diffchecker.com/LYePwrZK * BPool.sol: https://www.diffchecker.com/xuJD2bdN * Added `totalReserves` to record the reserves for each token in the pool. * Added `seize` to move the unbound tokens to the pool controller. This is useful when the rewards are distributed to the pool(e.g. COMP or CREAM). * Changed `swapExactAmountIn`, `swapExactAmountOut`, `joinswapExternAmountIn`, `joinswapPoolAmountOut`, `exitswapPoolAmountIn`, and `exitswapExternAmountOut`. * To keep track of the reserves from the swap fee. * Added `drainTotalReserves` to allow `BFactory` to move all `totalReserves` from this pool to the factory. This is required by `BFactory.collectTokenReserves`. * BToken.sol: https://www.diffchecker.com/hIccgy4v