Skip to content

The Flash Open - Connector Update

Compare
Choose a tag to compare
@Alexangelj Alexangelj released this 30 Oct 04:10
4594738

Description

Minor update with many changes.

  • Adds UniswapConnector02 contract.
  • Adds UniswapConnector02Lib library.
  • Adds WethConnector01 contract.
  • Adds WethConnector01Lib library.
  • Adds test_uni_flash test file.
  • New comment styling using /// for natspec and // for comments.
  • Adds getName() and getVersion() version to connector contracts for clarity, not responsible for any logic, pure view functions.

WethConnector

Not any significant changes to the contract logic. The contract's business logic was separated into its own library so that the functions logic can be used in other periphery contracts.

UniswapConnector

Major Addition - The Flash Open

Users can get longOptionToken exposure by paying in underlyingTokens through the interaction of a shortOptionToken<>underlyingToken Uniswap V2 Pair. UnderlyingTokens are received from the Uniswap V2 swap function call as a flash borrow. Those underlyingTokens are used to mint longOptionTokens + shortOptionTokens. To have long exposure, we need to get rid of the shortOptionTokens. Since the pair is underlyingTokens and shortOptionTokens, the shortOptionTokens are sent back to the pair as partial (up to full) repayment of the flash borrow. If the pair's ratio between reserves is 1:1, then only the swap fee has to be paid. If the shortOptionTokens are worth less than the underlyingTokens, the remaining balance of the flash loan is paid by the user in underlyingTokens. This remaining flash loan balance is effectively the premium of the longOptionToken, denominated in underlyingTokens.

Other Additions and Updates

Added significant business logic and a test suite to support it. Adds two functions that combine Primitive's mintOptions() function with Uniswap V2's swapExactTokensForTokens function. Can mint long + short tokens and swap either of those to a desired token in a single transaction. This means that a user can use underlying tokens, mint long + short tokens, and sell either the long or short token for dai or any other token.

Adds two functions that combine Primitive's mintOptions() function and Uniswap V2's addLiquidity function. This means users can use underlyingTokens to mint optionTokens, which are then provided as liquidity to a optionToken pair. This is done in the same transaction. The second function lets minted shortOptionTokens to be provided as liquidity instead of the longOptionTokens.

Adds two functions that combine Uniswap V2's removeLiquidity function with Primitive's closeOptions() function. This means users can remove longOptionToken or shortOptionToken pair liquidity and close the positions in the same transaction.