Skip to main content

LspUniswapV2Broker

LspUniswapV2Broker#

Helper contract to facilitate batched LSP and UniswapV2 transactions, including Mint+Sell and Mint+LP.

Functions#

atomicMintAddLiquidity(bool callingAsEOA, contract LongShortPair longShortPair, contract IUniswapV2Router01 router, uint256 amountCollateral, uint256 minLpTokens, uint256 deadline) (public)

Mint long and short tokens and deposit them all into a UniV2 Pool.

The caller of this method needs to approve amountCollateral collateral to be spent by this contract.

Parameters:#

  • callingAsEOA: If True, caller has balance of collateral and expects to receive back all LP tokens + dust.
  • longShortPair: LSP contract address to mint position on.
  • router: Contract to call to exchange long and short tokens.
  • amountCollateral: Amount of collateral to deposit and mint long and short tokens against.
  • minLpTokens: Minimum number of LP tokens to mint
  • deadline: Unix timestamp that will force the transaction to revert if minded after this time.
atomicMintSellOneSide(bool callingAsEOA, bool sellLong, contract LongShortPair longShortPair, contract IUniswapV2Router01 router, uint256 amountCollateral, address[] swapPath, uint256 deadline) (public)

and convert all of one side into the other.

The caller of this method needs to approve amountCollateral collateral to be spent by this contract.

Parameters:#

  • callingAsEOA: If True, caller has balance of collateral and expects to receive back all long/short tokens.
  • sellLong: If True, converts all long tokens into short, else the opposite.
  • longShortPair: LSP contract address to mint position on.
  • router: Contract to call to exchange long and short tokens.
  • amountCollateral: Amount of collateral to deposit and mint long and short tokens against.
  • swapPath: Router.swapExactTokensForTokens param: path with which to swap token to sell for the other.
  • deadline: Router.swapExactTokensForTokens param: time before transaction must be mined. / function atomicMintSellOneSide(
getReserves(address factory, address tokenA, address tokenB) → uint256 reserveA, uint256 reserveB (public)
sortTokens(address tokenA, address tokenB) → address token0, address token1 (internal)
pairFor(address factory, address tokenA, address tokenB) → contract IUniswapV2Pair pair (internal)