Flash Exercise

Introduction

It is a contract to exercise ACO tokens without sending the amount required to exercise besides the ACO tokens. You send only the ACO tokens and the collateral to be obtained on exercise is partially used to buy the asset and pay the writers the expected amount, the user exercising receives the remaining amount (intrinsic value) This functionality on a unique transaction is possible due to Uniswap Flash Swap. It is only possible to flash exercise an ACO token whether there is the respective pair underlying / strike asset on Uniswap V2.

Code

ACOFlashExercise.sol

Address

ACOFlashExercise.sol is deployed at 0x8992eea8B6D388af1Df04800E69e66b2d8799895 on the Ethereum mainnet.

Read-Only Functions

uniswapFactory

function uniswapFactory() external view returns(address);

The Uniswap V2 factory address.

uniswapRouter

function uniswapRouter() external view returns(address);

The Uniswap V2 router address.

weth

function weth() external view returns(address);

The WETH address used on Uniswap V2.

getUniswapPair

function getUniswapPair(address acoToken) external view returns(address);

Function to get the Uniswap V2 pair for an ACO token.

  • acoToken Address of the ACO token.

getExerciseData

function getExerciseData(address acoToken, uint256 tokenAmount, address[] calldata accounts) external view returns(uint256, uint256);

Function to get the required amount of collateral to be paid to Uniswap V2 as the first return and the expected amount to exercise the ACO token as the second return.

  • acoToken Address of the ACO token.

  • tokenAmount Amount of tokens to be exercised.

  • accounts The array of addresses to be exercised. Whether the array is empty the exercise will be considered as executed using the methods exercise or exerciseFrom.

getEstimatedReturn

function getEstimatedReturn(address acoToken, uint256 tokenAmount) external view returns(uint256);

Function to get the estimated collateral to be received through a flash exercise using the methods exercise or exerciseFrom.

  • acoToken Address of the ACO token.

  • tokenAmount Amount of tokens to be exercised.

State-Changing Functions

flashExercise

function flashExercise(address acoToken, uint256 tokenAmount, uint256 minimumCollateral, uint256 salt) external;

Function to flash exercise ACO tokens. No asset is required to exercise the ACO token because the own collateral redeemed is used to fulfill the terms of the contract. The transaction sender will receive the remaining collateral.

  • acoToken Address of the ACO token.

  • tokenAmount Amount of tokens to be exercised.

  • minimumCollateral The minimum amount of collateral accepted to be received on the flash exercise.

  • salt A random number used to calculate the start index of the array of accounts to be exercised.

Allowance to the flash exercise contract on the ACO tokens is required.

The function only works when the ACO token is NOT expired yet.

flashExerciseAccounts

function flashExerciseAccounts(address acoToken, uint256 tokenAmount, uint256 minimumCollateral, address[] calldata accounts) external;

Function to flash exercise ACO tokens using a list of accounts to be exercised. No asset is required to exercise the ACO token because the own collateral redeemed is used to fulfill the terms of the contract. The transaction sender will receive the remaining collateral.

  • acoToken Address of the ACO token.

  • tokenAmount Amount of tokens to be exercised.

  • minimumCollateral The minimum amount of collateral accepted to be received on the flash exercise.

  • accounts The array of addresses to try to exercise and get collateral from.

Allowance to the flash exercise contract on the ACO tokens is required.

The function only works when the ACO token is NOT expired yet.

ABI

JSON

Last updated