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

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

Interface

1
// SPDX-License-Identifier: BUSL-1.1
2
pragma solidity 0.6.12;
3
4
interface IBuniCornCallee {
5
function buniSwapCall(
6
address sender,
7
uint256 amount0,
8
uint256 amount1,
9
bytes calldata data
10
) external;
11
}
Copied!
Last modified 3mo ago