Created
October 12, 2021 06:05
-
-
Save bakasura980/34e1b0ca2f3a266e8e4180aec15ee98a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function removeLiquidityETHWithPermit( | |
address token, | |
uint weight, | |
uint liquidity, | |
uint amountTokenMin, | |
uint amountETHMin, | |
address to, | |
uint deadline, | |
bool approveMax, uint8 v, bytes32 r, bytes32 s | |
) external virtual override returns (uint amountToken, uint amountETH) { | |
uint value = approveMax ? uint(-1) : liquidity; | |
IPool pool = buildETHPool(token, weight); | |
pool.permit(msg.sender, address(this), value, deadline, v, r, s); | |
(amountToken, amountETH) = removeLiquidityETH(token, weight, liquidity, amountTokenMin, amountETHMin, to, deadline); | |
} | |
function buildETHPool(address token, uint weight) internal view returns(IPool pool) { | |
pool = IPool(IPoolFactory(factory).getPool(PoolKey.build(token, WETH, weight))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment