mirror of
https://github.com/Instadapp/smart-contract.git
synced 2024-07-29 22:08:07 +00:00
shut pool completed
This commit is contained in:
parent
651ffbd4e5
commit
8bb38b98d4
|
@ -100,6 +100,14 @@ contract Pool is Helper {
|
||||||
address beneficiary
|
address beneficiary
|
||||||
);
|
);
|
||||||
|
|
||||||
|
event LogShutPool(
|
||||||
|
address token,
|
||||||
|
uint tokenReturned,
|
||||||
|
uint ethReturned,
|
||||||
|
uint poolTokenBurned,
|
||||||
|
address beneficiary
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @dev Uniswap's pool basic details
|
* @dev Uniswap's pool basic details
|
||||||
* @param token token address to get pool. Eg:- DAI address, MKR address, etc
|
* @param token token address to get pool. Eg:- DAI address, MKR address, etc
|
||||||
|
@ -163,6 +171,7 @@ contract Pool is Helper {
|
||||||
) public returns (uint ethReturned, uint tokenReturned)
|
) public returns (uint ethReturned, uint tokenReturned)
|
||||||
{
|
{
|
||||||
address poolAddr = getAddressPool(token);
|
address poolAddr = getAddressPool(token);
|
||||||
|
|
||||||
setApproval(poolAddr, amount, poolAddr);
|
setApproval(poolAddr, amount, poolAddr);
|
||||||
(ethReturned, tokenReturned) = UniswapPool(poolAddr).removeLiquidity(
|
(ethReturned, tokenReturned) = UniswapPool(poolAddr).removeLiquidity(
|
||||||
amount,
|
amount,
|
||||||
|
@ -181,6 +190,35 @@ contract Pool is Helper {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @dev to remove all of the user's liquidity from pool. ETH and token quantity is decided as per the exchange token qty to burn
|
||||||
|
* @param token ERC20 address of Uniswap's pool (eg:- DAI address, MKR address, etc)
|
||||||
|
*/
|
||||||
|
function shut(
|
||||||
|
address token
|
||||||
|
) public returns (uint ethReturned, uint tokenReturned)
|
||||||
|
{
|
||||||
|
address poolAddr = getAddressPool(token);
|
||||||
|
uint userPoolBal = IERC20(poolAddr).balanceOf(address(this));
|
||||||
|
|
||||||
|
setApproval(poolAddr, userPoolBal, poolAddr);
|
||||||
|
(ethReturned, tokenReturned) = UniswapPool(poolAddr).removeLiquidity(
|
||||||
|
userPoolBal,
|
||||||
|
uint(1),
|
||||||
|
uint(1),
|
||||||
|
uint(1899063809) // 6th March 2030 GMT // no logic
|
||||||
|
);
|
||||||
|
address(msg.sender).transfer(ethReturned);
|
||||||
|
IERC20(token).transfer(msg.sender, tokenReturned);
|
||||||
|
emit LogShutPool(
|
||||||
|
token,
|
||||||
|
tokenReturned,
|
||||||
|
ethReturned,
|
||||||
|
userPoolBal,
|
||||||
|
msg.sender
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user