I'm not sure how to ask this and I may mess up my mathematical terms, if you think I have then please correct me.
When I call
addLiquidity on the CPMM, I know that I will be sending tez, and that based on how much tez I send, a certain amount of tzBTC will be taken from me and given to the CPMM. I also know that the calculated amount of tzBTC will be rounded up. I know that the CPMM will then give me LQT tokens, and the amount of tokens I receive will be rounded down, as the CPMM is greedy and wants the most value from me while giving me the least LQT possible. Sophia was kind enough to explain all of this to me.
I know that the formula for determining how much tzBTC will be taken, and how much LQT I will receive, is as follows:
tezAmount = amount of tez to add to CPMM Amount of tzBTC that will be taken/deposited = tezAmount * tokenPool / xtzPool tzBTC (with division rounding up) Amount of LQT you will receive = tezAmount * lqtTotal / xtzPool LQT (with division rounding down)
What I don't understand is how this rounding works in real life. For example,
If the CPMM contract has the following storage values: tokenPool: 161159696 xtzPool: 41578018471 lqtTotal: 51962
Then If I add tezAmount = 12000 xtz (12000000000 mutez) Amount of tzBTC that will be taken/deposited = 12000000000 * 161159696 / 41578018471 tzBTC (with division rounding up) (46512951.3892 expected) Amount of LQT you will receive = 12000000000 * 51962 / 41578018471 LQT (with division rounding down) (14996.9628888 expected)
Am I correct in my understanding that, given the contract storage totals stated above, when I send 12000 xtz, I will have 46512951.3892 Satoshi's taken (rounded up to 46512952), and I will receive 14996.9628888 LQT, rounded down to 14996?