bancorprotocol / contracts-solidity

Bancor Protocol Contracts
Other
841 stars 391 forks source link

Fix function `addLiquidityReturn` #572

Closed barakman closed 3 years ago

barakman commented 3 years ago

Function addLiquidityReturn is the getter function corresponding to function addLiquidity. However, instead of taking an array of reserve token amounts, it takes a single reserve token amount and "assumes" that the user will provide the equivalent amount of each one of the other reserve tokens, when function addLiquidity is ultimately executed.

Thus, in order for users to know how many pool tokens they are expected to get from function addLiquidity, they need to call function addLiquidityReturn separately for each reserve token amount that they intend to pass to function addLiquidity, and then choose the smallest value that function addLiquidityReturn has returned.

This PR fixes function addLiquidityReturn to take the exact same input as function addLiquidity (excluding the 'min-return' parameter). It is an API-breaking change, under the assumption that there are currently no onchain users of this function (for offchain users, the fix should be fairly simple).