mirror of
https://github.com/Instadapp/dsa-connectors-old.git
synced 2024-07-29 22:47:46 +00:00
Added uint(-1) for remove liquidity
This commit is contained in:
parent
6bafbdfece
commit
e5eb533a31
|
|
@ -235,12 +235,15 @@ contract LiquidityHelpers is UniswapHelpers {
|
||||||
uint _amt,
|
uint _amt,
|
||||||
uint[] memory slippages,
|
uint[] memory slippages,
|
||||||
uint deadline
|
uint deadline
|
||||||
) internal returns (uint _amtA, uint _amtB) {
|
) internal returns (uint _amtA, uint _amtB, uint _uniAmt) {
|
||||||
IUniswapV2Router01 router = IUniswapV2Router01(getUniswapAddr());
|
IUniswapV2Router01 router = IUniswapV2Router01(getUniswapAddr());
|
||||||
TokenInterface[] memory _tokens = changeEthToWeth(tokens);
|
TokenInterface[] memory _tokens = changeEthToWeth(tokens);
|
||||||
address exchangeAddr = IUniswapV2Factory(router.factory()).getPair(address(_tokens[0]), address(_tokens[1]));
|
address exchangeAddr = IUniswapV2Factory(router.factory()).getPair(address(_tokens[0]), address(_tokens[1]));
|
||||||
require(exchangeAddr != address(0), "pair-not-found.");
|
require(exchangeAddr != address(0), "pair-not-found.");
|
||||||
TokenInterface(exchangeAddr).approve(address(router), _amt);
|
|
||||||
|
TokenInterface uniToken = TokenInterface(exchangeAddr);
|
||||||
|
_uniAmt = _amt == uint(-1) ? uniToken.balanceOf(address(this)) : _amt;
|
||||||
|
uniToken.approve(address(router), _uniAmt);
|
||||||
|
|
||||||
(_amtA, _amtB) = router.removeLiquidity(
|
(_amtA, _amtB) = router.removeLiquidity(
|
||||||
address(_tokens[0]),
|
address(_tokens[0]),
|
||||||
|
|
@ -372,9 +375,9 @@ contract UniswapLiquidity is LiquidityHelpers {
|
||||||
uint[] calldata setIds
|
uint[] calldata setIds
|
||||||
) external payable {
|
) external payable {
|
||||||
require(tokens.length == 2, "length-is-not-two");
|
require(tokens.length == 2, "length-is-not-two");
|
||||||
uint _uniAmt = getUint(getId, amt);
|
uint _amt = getUint(getId, amt);
|
||||||
|
|
||||||
(uint _amtA, uint _amtB) = _removeLiquidity(tokens, _uniAmt, slippages, deadline);
|
(uint _amtA, uint _amtB, uint _uniAmt) = _removeLiquidity(tokens, _amt, slippages, deadline);
|
||||||
|
|
||||||
setUint(setIds[0], _amtA);
|
setUint(setIds[0], _amtA);
|
||||||
setUint(setIds[1], _amtB);
|
setUint(setIds[1], _amtB);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user