mirror of
https://github.com/Instadapp/dsa-resolvers-deprecated.git
synced 2024-07-29 22:38:16 +00:00
added slippage in withdraw resolver
This commit is contained in:
parent
9c01ed34b1
commit
3c5142d366
|
|
@ -211,11 +211,11 @@ contract Resolver is UniswapHelpers {
|
||||||
function getUniTokenAmount(
|
function getUniTokenAmount(
|
||||||
address tokenA,
|
address tokenA,
|
||||||
address tokenB,
|
address tokenB,
|
||||||
uint uniAmt
|
uint uniAmt,
|
||||||
|
uint slippage
|
||||||
)
|
)
|
||||||
public view returns (uint amtA, uint amtB)
|
public view returns (uint amtA, uint amtB, uint minA, uint minB)
|
||||||
{
|
{
|
||||||
// TODO - shall we return min amtA and amtB?
|
|
||||||
(TokenInterface _tokenA, TokenInterface _tokenB) = changeEthAddress(tokenA, tokenB);
|
(TokenInterface _tokenA, TokenInterface _tokenB) = changeEthAddress(tokenA, tokenB);
|
||||||
IUniswapV2Router01 router = IUniswapV2Router01(getUniswapAddr());
|
IUniswapV2Router01 router = IUniswapV2Router01(getUniswapAddr());
|
||||||
address exchangeAddr = IUniswapV2Factory(router.factory()).getPair(address(_tokenA), address(_tokenB));
|
address exchangeAddr = IUniswapV2Factory(router.factory()).getPair(address(_tokenA), address(_tokenB));
|
||||||
|
|
@ -224,6 +224,8 @@ contract Resolver is UniswapHelpers {
|
||||||
uint share = wdiv(uniAmt, uniToken.totalSupply());
|
uint share = wdiv(uniAmt, uniToken.totalSupply());
|
||||||
amtA = wmul(_tokenA.balanceOf(exchangeAddr), share);
|
amtA = wmul(_tokenA.balanceOf(exchangeAddr), share);
|
||||||
amtB = wmul(_tokenB.balanceOf(exchangeAddr), share);
|
amtB = wmul(_tokenB.balanceOf(exchangeAddr), share);
|
||||||
|
minA = getMinAmount(_tokenA, amtA, slippage);
|
||||||
|
minB = getMinAmount(_tokenB, amtB, slippage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user