Skip to main content

OpenMevZapper

OpenMevZapper

Optimal UniswapV2Pair Liquidity deposits and withdrawls with a single token / eth (or relevant native currency)

Methods

router

function router() external view returns (contract IOpenMevRouter)

Returns

NameTypeDescription
_0contract IOpenMevRouterundefined

swapAndStakeLiquidity

function swapAndStakeLiquidity(address tokenA, address tokenB, uint256 amountA, uint256 amountBMin) external nonpayable returns (uint256 liquidity)

Adds liquidity to an ERC-20⇄ERC-20 pool from a single token. msg.sender should have already given the router an allowance of at least amountA on tokenA

Parameters

NameTypeDescription
tokenAaddressToken in pool
tokenBaddressToken in pool
amountAuint256Amount of token A desired to add to pool, inclusive of swap half to tokenB
amountBMinuint256Minimum amount of token B on swap, can be 0

Returns

NameTypeDescription
liquidityuint256amount of liquidity token received, sent to msg.sender

swapETHAndStakeLiquidity

function swapETHAndStakeLiquidity(address tokenB, uint256 amountBMin) external payable returns (uint256 liquidity)

Adds liquidity to an ERC-20⇄ERC-20 pool from eth. msg.value is treated as a amountETHDesired. Leftover ETH, if any, is returned to msg.sender

Parameters

NameTypeDescription
tokenBaddressToken in pool
amountBMinuint256Minimum amount of token B on swap, can be 0

Returns

NameTypeDescription
liquidityuint256amount of liquidity token received, sent to msg.sender

withdrawLiquidityAndSwap

function withdrawLiquidityAndSwap(address pairAddress, uint256 withdrawAmount, address desiredToken, uint256 desiredTokenOutMin) external nonpayable returns (uint256 amountOut)

Removes liquidity from an ERC-20⇄ERC-20 pool into a single token / ETH . msg.sender should have already given the zapper an allowance of at least liquidity on the pool.

Parameters

NameTypeDescription
pairAddressaddressAddress of V2 pool
withdrawAmountuint256Amount of liquidity to withdraw
desiredTokenaddressWithdrawl token desired
desiredTokenOutMinuint256Minimum amount of total desiredToken, can be 0

Returns

NameTypeDescription
amountOutuint256Amount of desiredToken received

Errors

IdenticalAddresses

error IdenticalAddresses()

InsufficientAAmount

error InsufficientAAmount()

InsufficientAllowance

error InsufficientAllowance()

InsufficientBAmount

error InsufficientBAmount()

InsufficientLiquidity

error InsufficientLiquidity()

InsufficientOutputAmount

error InsufficientOutputAmount()

InvalidPath

error InvalidPath()

Overflow

error Overflow()

TransferFailed

error TransferFailed()

ZeroAddress

error ZeroAddress()

ZeroAmount

error ZeroAmount()