Flash Swaps

The Bunicorn stablecoins flash swap functionality works similarly to Uniswap's. You may read more about flash swaps here. We highlight the syntax differences below.

Using buniSwapCall

function buniSwapCall(address sender, uint256 amount0, uint256 amount1, bytes calldata data) {
  IERC20 token0 = IBuniCornPool(msg.sender).token0(); // fetch the address of token0
  IERC20 token1 = IBuniCornPool(msg.sender).token1(); // fetch the address of token1
  assert(IBuniCornFactory(buniCornFactory).isPool(token0, token1, msg.sender)); // ensure that caller can only be Bunicorn pool
  // rest of the function below
}

Interface

IBuniCornCallee.sol

// SPDX-License-Identifier: BUSL-1.1
pragma solidity 0.6.12;

interface IBuniCornCallee {
    function buniSwapCall(
        address sender,
        uint256 amount0,
        uint256 amount1,
        bytes calldata data
    ) external;
}

Last updated