drop getOutputPrice
This commit is contained in:
@ -48,15 +48,6 @@ contract UniswapERC20 is ERC20 {
|
||||
return numerator / denominator;
|
||||
}
|
||||
|
||||
|
||||
function getOutputPrice(uint256 outputAmount, uint256 inputReserve, uint256 outputReserve) public pure returns (uint256) {
|
||||
require(inputReserve > 0 && outputReserve > 0);
|
||||
uint256 numerator = inputReserve.mul(outputAmount).mul(1000);
|
||||
uint256 denominator = (outputReserve.sub(outputAmount)).mul(997);
|
||||
return (numerator / denominator).add(1);
|
||||
}
|
||||
|
||||
|
||||
//TO: DO msg.sender is wrapper
|
||||
function swapInput(address inputToken, uint256 amountSold, address recipient) public nonReentrant returns (uint256) {
|
||||
address _tokenA = address(tokenA);
|
||||
@ -99,21 +90,6 @@ contract UniswapERC20 is ERC20 {
|
||||
}
|
||||
|
||||
|
||||
function getOutputPrice(address outputToken, uint256 amountBought) public view returns (uint256) {
|
||||
require(amountBought > 0);
|
||||
address _tokenA = address(tokenA);
|
||||
address _tokenB = address(tokenB);
|
||||
require(outputToken == _tokenA || outputToken == _tokenB);
|
||||
address inputToken = _tokenA;
|
||||
if(outputToken == _tokenA) {
|
||||
inputToken = _tokenB;
|
||||
}
|
||||
uint256 inputReserve = IERC20(inputToken).balanceOf(address(this));
|
||||
uint256 outputReserve = IERC20(outputToken).balanceOf(address(this));
|
||||
return getOutputPrice(amountBought, inputReserve, outputReserve);
|
||||
}
|
||||
|
||||
|
||||
function addLiquidity(uint256 amountA, uint256 maxTokenB) public nonReentrant returns (uint256) {
|
||||
require(amountA > 0);
|
||||
uint256 _totalSupply = totalSupply;
|
||||
|
||||
Reference in New Issue
Block a user