Source Code
Overview
ETH Balance
0 ETH
ETH Value
$0.00View more zero value Internal Transactions in Advanced View mode
Advanced mode:
Cross-Chain Transactions
Loading...
Loading
Contract Name:
FlashRedeemer_UniswapV3
Compiler Version
v0.8.13+commit.abaa5c0e
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
import {ReentrancyGuard} from "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IUniswapV3Pool} from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import {IUniswapV3FlashCallback} from "@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3FlashCallback.sol";
import {IUniswapV3SwapCallback} from "@uniswap/v3-core/contracts/interfaces/callback/IUniswapV3SwapCallback.sol";
import {IOptionTokenV3} from "../IOptionTokenV3.sol";
import {IDynamicTwapOracle} from "../DynamicTwapOracle/IDynamicTwapOracle.sol";
import {IFlashRedeemer} from "./IFlashRedeemer.sol";
import {IFlashRedeemer_UniswapV3} from "./IFlashRedeemer_UniswapV3.sol";
/// @title FlashRedeemer_UniswapV3
/// @notice Flash loan redemption system for OptionTokenV3
/// @dev Allows users to redeem option tokens without upfront payment using UniswapV3 flash loans
contract FlashRedeemer_UniswapV3 is IFlashRedeemer_UniswapV3, IUniswapV3FlashCallback, IUniswapV3SwapCallback, ReentrancyGuard {
using SafeERC20 for IERC20;
/// -----------------------------------------------------------------------
/// Constants
/// -----------------------------------------------------------------------
/// @notice UniswapV3 fee denominator (fees are in hundredths of a bip, so 1000000 = 100%)
uint256 private constant UNISWAP_V3_FEE_DENOMINATOR = 1000000;
uint160 private constant MIN_SQRT_RATIO = 4295128739;
uint160 private constant MAX_SQRT_RATIO = 1461446703485210103287273052203988822378723970342;
/// -----------------------------------------------------------------------
/// Structs
/// -----------------------------------------------------------------------
/// @notice Flash loan callback data structure
struct FlashCallbackData {
address optionToken;
uint256 amount;
uint256 paymentAmount;
uint256 minUnderlyingOut;
address recipient;
address caller;
}
/// -----------------------------------------------------------------------
/// Immutable parameters
/// -----------------------------------------------------------------------
/// @notice The option token contract
IOptionTokenV3 public immutable override optionToken;
/// @notice The UniswapV3 pool used for flash loans
IUniswapV3Pool public immutable override flashPool;
/// @notice The UniswapV3 pool used for the swap leg
IUniswapV3Pool public immutable override swapPool;
/// -----------------------------------------------------------------------
/// Events
/// -----------------------------------------------------------------------
event FlashRedemptionExecuted(
address indexed optionToken,
address indexed recipient,
uint256 amount,
uint256 underlyingOut,
uint256 profit
);
event FlashRedemptionFailed(
address indexed optionToken,
address indexed recipient,
uint256 amount,
string reason
);
event ProfitDistributed(
address indexed recipient,
uint256 underlyingAmount,
uint256 paymentAmount
);
/// -----------------------------------------------------------------------
/// Errors
/// -----------------------------------------------------------------------
error FlashRedeemer_Unauthorized();
error FlashRedeemer_InsufficientOutput();
error FlashRedeemer_InvalidOptionToken();
error FlashRedeemer_InvalidPool();
error FlashRedeemer_InvalidAmount();
error FlashRedeemer_InvalidRecipient();
error FlashRedeemer_RedemptionFailed();
error FlashRedeemer_SwapFailed();
error FlashRedeemer_InvalidCallbackData();
/// -----------------------------------------------------------------------
/// Constructor
/// -----------------------------------------------------------------------
/// @notice Initializes the FlashRedeemer with option token and flash pool
/// @dev The constructor performs comprehensive validation:
/// 1. Validates option token address and interfaces
/// 2. Extracts swap pool from option token's TWAP oracle
/// 3. Validates both flash pool and swap pool configurations
/// 4. Ensures all required tokens are present in the pools
/// @param _optionToken The option token address (must implement IOptionTokenV3)
/// @param _flashPool The UniswapV3 pool to use for flash loans (must contain payment token)
constructor(
address _optionToken,
address _flashPool
) {
if (_optionToken == address(0)) revert FlashRedeemer_InvalidOptionToken();
if (_flashPool == address(0)) revert FlashRedeemer_InvalidPool();
optionToken = IOptionTokenV3(_optionToken);
flashPool = IUniswapV3Pool(_flashPool);
// Resolve and validate the pool from the option's TWAP oracle
try optionToken.twapOracle() returns (IDynamicTwapOracle oracle) {
try oracle.pool() returns (address twapPool) {
if (twapPool == address(0)) revert FlashRedeemer_InvalidPool();
swapPool = IUniswapV3Pool(twapPool);
} catch {
revert FlashRedeemer_InvalidOptionToken();
}
} catch {
revert FlashRedeemer_InvalidOptionToken();
}
_validateFlashPool(flashPool);
_validateSwapPool(swapPool);
// Sanity check option token interfaces
try optionToken.paymentToken() returns (IERC20) {
// ok
} catch {
revert FlashRedeemer_InvalidOptionToken();
}
try optionToken.UNDERLYING_TOKEN() returns (IERC20) {
// ok
} catch {
revert FlashRedeemer_InvalidOptionToken();
}
}
/// -----------------------------------------------------------------------
/// View functions
/// -----------------------------------------------------------------------
/// @notice Gets the payment token from the option token
/// @dev This is a convenience function that delegates to the option token's paymentToken() method
/// @return The payment token contract used for option redemptions
function paymentToken() public view override returns (IERC20) {
return optionToken.paymentToken();
}
/// @notice Gets the underlying token from the option token
/// @dev This is a convenience function that delegates to the option token's UNDERLYING_TOKEN() method
/// @return The underlying token contract that option tokens can be redeemed for
function underlyingToken() public view override returns (IERC20) {
return optionToken.UNDERLYING_TOKEN();
}
/// -----------------------------------------------------------------------
/// Estimate functions
/// -----------------------------------------------------------------------
/// @notice Estimates flash loan redemption parameters
/// @dev This function calculates all the parameters needed for a flash loan redemption:
/// 1. Payment amount needed (using option token's discounted price)
/// 2. Flash loan fee (based on pool fee)
/// 3. Underlying tokens received from exercise (1:1 with option tokens)
/// 4. Underlying tokens needed for swap (using current pool price)
/// 5. Final profit calculation (underlying received - underlying needed for swap)
/// @param optionAmount The amount of option tokens to redeem
/// @return estimation The redemption estimation containing all calculated parameters
function estimateFlashRedemption(
uint256 optionAmount
) external view override returns (IFlashRedeemer.FlashRedemptionEstimation memory estimation) {
if (optionAmount == 0) {
return estimation; // Returns zero values
}
// Step 1: Basic values
estimation.optionAmount = optionAmount;
estimation.paymentAmount = optionToken.getDiscountedPrice(optionAmount);
// Step 2: Flash loan fee
estimation.flashLoanFee = (estimation.paymentAmount * flashPool.fee()) / UNISWAP_V3_FEE_DENOMINATOR;
uint256 totalPaymentNeeded = estimation.paymentAmount + estimation.flashLoanFee;
// Step 3: Underlying tokens from exercise (1:1 ratio with option tokens)
uint256 underlyingFromExercise = optionAmount;
// Step 4: Estimate underlying tokens needed to swap for repayment
uint256 underlyingNeededForSwap = _estimateUnderlyingNeededForSwap(totalPaymentNeeded);
// Step 5: Calculate final underlying received (profit)
if (underlyingFromExercise > underlyingNeededForSwap) {
estimation.underlyingReceived = underlyingFromExercise - underlyingNeededForSwap;
} else {
estimation.underlyingReceived = 0; // Not profitable
}
}
/// @notice Estimates underlying tokens needed to swap for a specific payment token amount
/// @dev Uses current spot price with robust handling of extreme cases
/// @param paymentTokensNeeded The amount of payment tokens needed
/// @return underlyingNeeded The estimated underlying tokens needed for the swap
function _estimateUnderlyingNeededForSwap(uint256 paymentTokensNeeded) internal view returns (uint256 underlyingNeeded) {
if (paymentTokensNeeded == 0) {
return 0;
}
address underlyingAddr = address(underlyingToken());
// Get current price from swap pool
(uint160 sqrtPriceX96, , , , , , ) = swapPool.slot0();
// Calculate price ratio based on token order
bool underlyingIsToken0 = underlyingAddr == swapPool.token0();
uint256 priceRatio;
// Calculate the actual spot price from Uniswap V3 pool
// In Uniswap V3: sqrtPriceX96 = sqrt(price_token1_token0) * 2^96
// So price_token1_token0 = (sqrtPriceX96)^2 / 2^192
// We want: payment_per_underlying
if (underlyingIsToken0) {
// underlying = token0, payment = token1
// priceRatio = payment_per_underlying = price_token1_token0
// Calculate: (sqrtPriceX96)^2 / 2^192
uint256 sqrtPriceSquared = uint256(sqrtPriceX96) * uint256(sqrtPriceX96);
uint256 twoPow192 = 1 << 192;
if (sqrtPriceSquared >= twoPow192) {
priceRatio = sqrtPriceSquared / twoPow192;
} else {
// Price < 1, use minimum ratio
priceRatio = 1;
}
} else {
// underlying = token1, payment = token0
// priceRatio = payment_per_underlying = 1 / price_token1_token0
uint256 sqrtPriceSquared = uint256(sqrtPriceX96) * uint256(sqrtPriceX96);
uint256 twoPow192 = 1 << 192;
if (sqrtPriceSquared > 0) {
priceRatio = twoPow192 / sqrtPriceSquared;
} else {
priceRatio = type(uint256).max;
}
}
// Handle edge cases
if (priceRatio == 0) {
uint128 liquidity = swapPool.liquidity();
if (liquidity > 0) {
priceRatio = 1e12; // 1 underlying = 1e-12 payment
} else {
return type(uint256).max;
}
} else if (priceRatio > 1e18) {
priceRatio = 1e18; // Cap extremely high ratios
}
// Calculate underlying needed: paymentTokensNeeded / priceRatio
if (priceRatio > 0) {
underlyingNeeded = paymentTokensNeeded / priceRatio;
} else {
underlyingNeeded = type(uint256).max;
}
// Cap extreme values
if (underlyingNeeded > type(uint256).max / 1e18) {
underlyingNeeded = type(uint256).max;
}
}
/// -----------------------------------------------------------------------
/// Flash functions
/// -----------------------------------------------------------------------
/// @notice Executes a flash loan redemption
/// @dev This is the main entry point for flash loan redemptions. The process works as follows:
/// 1. Validates the estimation parameters
/// 2. Determines which token to flash loan (token0 or token1) based on pool configuration
/// 3. Encodes callback data with all necessary parameters
/// 4. Initiates the flash loan from the flash pool
/// 5. The flash loan callback handles the actual redemption and swap logic
/// @param estimation The flash redemption estimation containing all parameters (from estimateFlashRedemption)
function flashRedeem(
IFlashRedeemer.FlashRedemptionEstimation memory estimation
) external override nonReentrant {
if (estimation.optionAmount == 0) revert FlashRedeemer_InvalidAmount();
if (estimation.paymentAmount == 0) revert FlashRedeemer_InvalidAmount();
// Determine which token to flash loan based on pool configuration
uint256 amount0 = 0;
uint256 amount1 = 0;
IERC20 paymentToken_ = paymentToken();
if (flashPool.token0() == address(paymentToken_)) {
amount0 = estimation.paymentAmount;
} else if (flashPool.token1() == address(paymentToken_)) {
amount1 = estimation.paymentAmount;
} else {
revert FlashRedeemer_InvalidOptionToken();
}
// Encode callback data
bytes memory data = abi.encode(
FlashCallbackData({
optionToken: address(optionToken),
amount: estimation.optionAmount,
paymentAmount: estimation.paymentAmount,
minUnderlyingOut: estimation.underlyingReceived,
recipient: msg.sender,
caller: msg.sender
})
);
// Execute flash loan
flashPool.flash(address(this), amount0, amount1, data);
}
/// @notice UniswapV3 flash loan callback
/// @dev This is called by the flash pool after initiating a flash loan. It handles the core
/// redemption logic: exercising option tokens, swapping underlying for payment tokens,
/// repaying the flash loan, and distributing any remaining profit to the user.
/// @param fee0 The fee amount in token0 (if flash loan was in token0)
/// @param fee1 The fee amount in token1 (if flash loan was in token1)
/// @param data The encoded callback data containing redemption parameters
function uniswapV3FlashCallback(
uint256 fee0,
uint256 fee1,
bytes calldata data
) external override {
if (msg.sender != address(flashPool)) revert FlashRedeemer_Unauthorized();
FlashCallbackData memory decoded = abi.decode(data, (FlashCallbackData));
try this.self_executeFlashRedemption(decoded, fee0, fee1) {
// Success - events emitted in _executeFlashRedemption
} catch Error(string memory reason) {
emit FlashRedemptionFailed(
decoded.optionToken,
decoded.recipient,
decoded.amount,
reason
);
revert(reason);
}
}
/// @notice Internal function to execute flash redemption
/// @dev This function contains the core redemption logic that runs within the flash loan callback.
/// It performs the following steps:
/// 1. Transfers option tokens from user to this contract
/// 2. Approves payment tokens to the option contract
/// 3. Exercises the option tokens to receive underlying tokens
/// 4. Swaps underlying tokens for payment tokens (to repay flash loan)
/// 5. Repays the flash loan with payment tokens
/// 6. Transfers remaining underlying tokens (profit) to the user
/// @param data The flash callback data containing redemption parameters
/// @param fee0 The fee amount in token0 (if flash loan was in token0)
/// @param fee1 The fee amount in token1 (if flash loan was in token1)
function self_executeFlashRedemption(
FlashCallbackData memory data,
uint256 fee0,
uint256 fee1
) external {
// This function must be called from the flash callback
if (msg.sender != address(this)) revert FlashRedeemer_Unauthorized();
IOptionTokenV3 option = IOptionTokenV3(data.optionToken);
if (address(option) != address(optionToken)) revert FlashRedeemer_InvalidOptionToken();
// Transfer option tokens from caller to this contract
option.transferFrom(data.caller, address(this), data.amount);
// Approve payment tokens to the option so it can pull funds during exercise
IERC20 paymentToken_ = paymentToken();
paymentToken_.safeApprove(address(option), 0);
paymentToken_.safeApprove(address(option), data.paymentAmount);
// Execute the redemption using the pre-calculated payment amount
option.exercise(data.amount, data.paymentAmount, address(this));
paymentToken_.safeApprove(address(option), 0);
// Check if we received enough underlying tokens
IERC20 underlyingToken_ = underlyingToken();
uint256 underlyingRedeemed = underlyingToken_.balanceOf(address(this));
// Calculate how much we need to swap back to payment tokens
uint256 totalPaymentNeeded = data.paymentAmount + (flashPool.token0() == address(paymentToken_) ? fee0 : fee1);
// Use a more generous maximum swap amount to account for price impact
// We'll validate the final output meets user expectations at the end
uint256 maxUnderlyingForSwap = (underlyingRedeemed * 99) / 100; // Allow up to 99% to be swapped
// Swap underlying tokens to payment tokens to repay the flash loan
_swapUnderlyingForPayment(
totalPaymentNeeded,
maxUnderlyingForSwap
);
// Repay the flash loan
paymentToken_.safeTransfer(address(flashPool), totalPaymentNeeded);
// Calculate profit (remaining underlying tokens)
uint256 remainingUnderlying = underlyingToken_.balanceOf(address(this));
if (remainingUnderlying < data.minUnderlyingOut) {
revert FlashRedeemer_InsufficientOutput();
}
// Transfer remaining underlying tokens to recipient
if (remainingUnderlying > 0) {
underlyingToken_.safeTransfer(data.recipient, remainingUnderlying);
}
// Transfer any remaining payment tokens to recipient
uint256 remainingPayment = paymentToken_.balanceOf(address(this));
if (remainingPayment > 0) {
paymentToken_.safeTransfer(data.recipient, remainingPayment);
}
emit FlashRedemptionExecuted(
data.optionToken,
data.recipient,
data.amount,
underlyingRedeemed,
remainingUnderlying
);
}
/// @notice UniswapV3 swap callback for direct pool swaps
/// @dev This callback is called by the swap pool during a direct pool swap. It handles
/// the token transfer required to complete the swap. The callback validates:
/// 1. The caller is the authorized swap pool
/// 2. The amount doesn't exceed the maximum allowed (slippage protection)
/// 3. The token being paid is either underlying or payment token
/// @param amount0Delta The amount of token0 to be paid (positive) or received (negative)
/// @param amount1Delta The amount of token1 to be paid (positive) or received (negative)
/// @param data The encoded data containing maxAmountIn for slippage protection
function uniswapV3SwapCallback(
int256 amount0Delta,
int256 amount1Delta,
bytes calldata data
) external override {
if (msg.sender != address(swapPool)) revert FlashRedeemer_Unauthorized();
uint256 maxAmountIn = abi.decode(data, (uint256));
uint256 amountToPay;
address tokenToPay;
if (amount0Delta > 0) {
amountToPay = uint256(amount0Delta);
tokenToPay = swapPool.token0();
} else if (amount1Delta > 0) {
amountToPay = uint256(amount1Delta);
tokenToPay = swapPool.token1();
} else {
return;
}
if (amountToPay > maxAmountIn) revert FlashRedeemer_SwapFailed();
if (tokenToPay != address(underlyingToken()) && tokenToPay != address(paymentToken())) {
revert FlashRedeemer_InvalidCallbackData();
}
IERC20(tokenToPay).safeTransfer(msg.sender, amountToPay);
}
/// -----------------------------------------------------------------------
/// Swap functions
/// -----------------------------------------------------------------------
/// @notice Internal function to swap underlying tokens for payment tokens using direct pool interaction
/// @dev This function performs an exactOutput swap using the swap pool directly (not through a router).
/// It uses the same pool that was used for price estimation to ensure consistency.
/// The swap is protected by maxAmountIn to prevent excessive slippage.
/// @param amountOut The exact amount of payment tokens needed (for flash loan repayment)
/// @param maxAmountIn The maximum amount of underlying tokens to spend (slippage protection)
/// @return amountIn The actual amount of underlying tokens spent in the swap
function _swapUnderlyingForPayment(
uint256 amountOut,
uint256 maxAmountIn
) internal returns (uint256 amountIn) {
if (amountOut == 0) {
return 0;
}
if (maxAmountIn == 0) {
revert FlashRedeemer_SwapFailed();
}
address underlyingAddr = address(underlyingToken());
address paymentAddr = address(paymentToken());
bool zeroForOne;
{
address token0 = swapPool.token0();
address token1 = swapPool.token1();
if (underlyingAddr == token0 && paymentAddr == token1) {
zeroForOne = true;
} else if (underlyingAddr == token1 && paymentAddr == token0) {
zeroForOne = false;
} else {
revert FlashRedeemer_SwapFailed();
}
}
(int256 amount0Delta, int256 amount1Delta) = swapPool.swap(
address(this),
zeroForOne,
-int256(amountOut),
zeroForOne ? MIN_SQRT_RATIO + 1 : MAX_SQRT_RATIO - 1,
abi.encode(maxAmountIn)
);
if (zeroForOne) {
if (amount0Delta <= 0) revert FlashRedeemer_SwapFailed();
amountIn = uint256(amount0Delta);
} else {
if (amount1Delta <= 0) revert FlashRedeemer_SwapFailed();
amountIn = uint256(amount1Delta);
}
if (amountIn > maxAmountIn) {
revert FlashRedeemer_SwapFailed();
}
}
/// @notice Validates that a pool is suitable for flash loans
/// @dev Checks that the pool exists, has valid tokens, includes the payment token,
/// has a reasonable fee, and can be queried for state information.
/// @param _pool The pool to validate
function _validateFlashPool(IUniswapV3Pool _pool) internal view {
try _pool.factory() returns (address) {} catch {
revert FlashRedeemer_InvalidPool();
}
address token0;
address token1;
try _pool.token0() returns (address t0) {
token0 = t0;
token1 = _pool.token1();
} catch {
revert FlashRedeemer_InvalidPool();
}
if (token0 == address(0) || token1 == address(0) || token0 == token1) {
revert FlashRedeemer_InvalidPool();
}
IERC20 paymentToken_ = optionToken.paymentToken();
if (address(paymentToken_) != token0 && address(paymentToken_) != token1) {
revert FlashRedeemer_InvalidPool();
}
try _pool.fee() returns (uint24 poolFee) {
if (poolFee >= UNISWAP_V3_FEE_DENOMINATOR) {
revert FlashRedeemer_InvalidPool();
}
} catch {
revert FlashRedeemer_InvalidPool();
}
try _pool.slot0() returns (uint160, int24, uint16, uint16, uint16, uint8, bool) {} catch {
revert FlashRedeemer_InvalidPool();
}
}
/// @notice Validates that a pool is suitable for swaps between underlying and payment tokens
/// @dev Checks that the pool exists, has valid tokens, includes both underlying and payment tokens,
/// has a reasonable fee, and can be queried for state information.
/// @param _pool The pool to validate
function _validateSwapPool(IUniswapV3Pool _pool) internal view {
try _pool.factory() returns (address) {} catch {
revert FlashRedeemer_InvalidPool();
}
address token0;
address token1;
try _pool.token0() returns (address t0) {
token0 = t0;
token1 = _pool.token1();
} catch {
revert FlashRedeemer_InvalidPool();
}
if (token0 == address(0) || token1 == address(0) || token0 == token1) {
revert FlashRedeemer_InvalidPool();
}
IERC20 paymentToken_ = optionToken.paymentToken();
IERC20 underlyingToken_ = optionToken.UNDERLYING_TOKEN();
if (address(paymentToken_) != token0 && address(paymentToken_) != token1) {
revert FlashRedeemer_InvalidPool();
}
if (address(underlyingToken_) != token0 && address(underlyingToken_) != token1) {
revert FlashRedeemer_InvalidPool();
}
if (address(paymentToken_) == address(underlyingToken_)) {
revert FlashRedeemer_InvalidPool();
}
try _pool.fee() returns (uint24 poolFee) {
if (poolFee >= UNISWAP_V3_FEE_DENOMINATOR) {
revert FlashRedeemer_InvalidPool();
}
} catch {
revert FlashRedeemer_InvalidPool();
}
try _pool.slot0() returns (uint160, int24, uint16, uint16, uint16, uint8, bool) {} catch {
revert FlashRedeemer_InvalidPool();
}
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*
* _Available since v3.1._
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) external;
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
* https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
*
* Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
* presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
* need to send a transaction, and thus is not required to hold Ether at all.
*
* ==== Security Considerations
*
* There are two important considerations concerning the use of `permit`. The first is that a valid permit signature
* expresses an allowance, and it should not be assumed to convey additional meaning. In particular, it should not be
* considered as an intention to spend the allowance in any specific way. The second is that because permits have
* built-in replay protection and can be submitted by anyone, they can be frontrun. A protocol that uses permits should
* take this into consideration and allow a `permit` call to fail. Combining these two aspects, a pattern that may be
* generally recommended is:
*
* ```solidity
* function doThingWithPermit(..., uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public {
* try token.permit(msg.sender, address(this), value, deadline, v, r, s) {} catch {}
* doThing(..., value);
* }
*
* function doThing(..., uint256 value) public {
* token.safeTransferFrom(msg.sender, address(this), value);
* ...
* }
* ```
*
* Observe that: 1) `msg.sender` is used as the owner, leaving no ambiguity as to the signer intent, and 2) the use of
* `try/catch` allows the permit to fail and makes the code tolerant to frontrunning. (See also
* {SafeERC20-safeTransferFrom}).
*
* Additionally, note that smart contract wallets (such as Argent or Safe) are not able to produce permit signatures, so
* contracts should have entry points that don't rely on permit.
*/
interface IERC20Permit {
/**
* @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
* given ``owner``'s signed approval.
*
* IMPORTANT: The same issues {IERC20-approve} has related to transaction
* ordering also apply here.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `deadline` must be a timestamp in the future.
* - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
* over the EIP712-formatted function arguments.
* - the signature must use ``owner``'s current nonce (see {nonces}).
*
* For more information on the signature format, see the
* https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
* section].
*
* CAUTION: See Security Considerations above.
*/
function permit(
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) external;
/**
* @dev Returns the current nonce for `owner`. This value must be
* included whenever a signature is generated for {permit}.
*
* Every successful call to {permit} increases ``owner``'s nonce by one. This
* prevents a signature from being used multiple times.
*/
function nonces(address owner) external view returns (uint256);
/**
* @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
*/
// solhint-disable-next-line func-name-mixedcase
function DOMAIN_SEPARATOR() external view returns (bytes32);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 amount) external returns (bool);
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../extensions/IERC20Permit.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(IERC20 token, address spender, uint256 value) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.
* Revert on invalid signature.
*/
function safePermit(
IERC20Permit token,
address owner,
address spender,
uint256 value,
uint256 deadline,
uint8 v,
bytes32 r,
bytes32 s
) internal {
uint256 nonceBefore = token.nonces(owner);
token.permit(owner, spender, value, deadline, v, r, s);
uint256 nonceAfter = token.nonces(owner);
require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
require(returndata.length == 0 || abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false
// and not revert is the subcall reverts.
(bool success, bytes memory returndata) = address(token).call(data);
return
success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
*
* Furthermore, `isContract` will also return true if the target contract within
* the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
* which only has an effect at the end of a transaction.
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResultFromTarget(target, success, returndata, errorMessage);
}
/**
* @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
* the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
*
* _Available since v4.8._
*/
function verifyCallResultFromTarget(
address target,
bool success,
bytes memory returndata,
string memory errorMessage
) internal view returns (bytes memory) {
if (success) {
if (returndata.length == 0) {
// only check isContract if the call was successful and the return data is empty
// otherwise we already know that it was a contract
require(isContract(target), "Address: call to non-contract");
}
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
/**
* @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason or using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function _revert(bytes memory returndata, string memory errorMessage) private pure {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Callback for IUniswapV3PoolActions#flash
/// @notice Any contract that calls IUniswapV3PoolActions#flash must implement this interface
interface IUniswapV3FlashCallback {
/// @notice Called to `msg.sender` after transferring to the recipient from IUniswapV3Pool#flash.
/// @dev In the implementation you must repay the pool the tokens sent by flash plus the computed fee amounts.
/// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.
/// @param fee0 The fee amount in token0 due to the pool by the end of the flash
/// @param fee1 The fee amount in token1 due to the pool by the end of the flash
/// @param data Any data passed through by the caller via the IUniswapV3PoolActions#flash call
function uniswapV3FlashCallback(
uint256 fee0,
uint256 fee1,
bytes calldata data
) external;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Callback for IUniswapV3PoolActions#swap
/// @notice Any contract that calls IUniswapV3PoolActions#swap must implement this interface
interface IUniswapV3SwapCallback {
/// @notice Called to `msg.sender` after executing a swap via IUniswapV3Pool#swap.
/// @dev In the implementation you must pay the pool tokens owed for the swap.
/// The caller of this method must be checked to be a UniswapV3Pool deployed by the canonical UniswapV3Factory.
/// amount0Delta and amount1Delta can both be 0 if no tokens were swapped.
/// @param amount0Delta The amount of token0 that was sent (negative) or must be received (positive) by the pool by
/// the end of the swap. If positive, the callback must send that amount of token0 to the pool.
/// @param amount1Delta The amount of token1 that was sent (negative) or must be received (positive) by the pool by
/// the end of the swap. If positive, the callback must send that amount of token1 to the pool.
/// @param data Any data passed through by the caller via the IUniswapV3PoolActions#swap call
function uniswapV3SwapCallback(
int256 amount0Delta,
int256 amount1Delta,
bytes calldata data
) external;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
import './pool/IUniswapV3PoolImmutables.sol';
import './pool/IUniswapV3PoolState.sol';
import './pool/IUniswapV3PoolDerivedState.sol';
import './pool/IUniswapV3PoolActions.sol';
import './pool/IUniswapV3PoolOwnerActions.sol';
import './pool/IUniswapV3PoolEvents.sol';
/// @title The interface for a Uniswap V3 Pool
/// @notice A Uniswap pool facilitates swapping and automated market making between any two assets that strictly conform
/// to the ERC20 specification
/// @dev The pool interface is broken up into many smaller pieces
interface IUniswapV3Pool is
IUniswapV3PoolImmutables,
IUniswapV3PoolState,
IUniswapV3PoolDerivedState,
IUniswapV3PoolActions,
IUniswapV3PoolOwnerActions,
IUniswapV3PoolEvents
{
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Permissionless pool actions
/// @notice Contains pool methods that can be called by anyone
interface IUniswapV3PoolActions {
/// @notice Sets the initial price for the pool
/// @dev Price is represented as a sqrt(amountToken1/amountToken0) Q64.96 value
/// @param sqrtPriceX96 the initial sqrt price of the pool as a Q64.96
function initialize(uint160 sqrtPriceX96) external;
/// @notice Adds liquidity for the given recipient/tickLower/tickUpper position
/// @dev The caller of this method receives a callback in the form of IUniswapV3MintCallback#uniswapV3MintCallback
/// in which they must pay any token0 or token1 owed for the liquidity. The amount of token0/token1 due depends
/// on tickLower, tickUpper, the amount of liquidity, and the current price.
/// @param recipient The address for which the liquidity will be created
/// @param tickLower The lower tick of the position in which to add liquidity
/// @param tickUpper The upper tick of the position in which to add liquidity
/// @param amount The amount of liquidity to mint
/// @param data Any data that should be passed through to the callback
/// @return amount0 The amount of token0 that was paid to mint the given amount of liquidity. Matches the value in the callback
/// @return amount1 The amount of token1 that was paid to mint the given amount of liquidity. Matches the value in the callback
function mint(
address recipient,
int24 tickLower,
int24 tickUpper,
uint128 amount,
bytes calldata data
) external returns (uint256 amount0, uint256 amount1);
/// @notice Collects tokens owed to a position
/// @dev Does not recompute fees earned, which must be done either via mint or burn of any amount of liquidity.
/// Collect must be called by the position owner. To withdraw only token0 or only token1, amount0Requested or
/// amount1Requested may be set to zero. To withdraw all tokens owed, caller may pass any value greater than the
/// actual tokens owed, e.g. type(uint128).max. Tokens owed may be from accumulated swap fees or burned liquidity.
/// @param recipient The address which should receive the fees collected
/// @param tickLower The lower tick of the position for which to collect fees
/// @param tickUpper The upper tick of the position for which to collect fees
/// @param amount0Requested How much token0 should be withdrawn from the fees owed
/// @param amount1Requested How much token1 should be withdrawn from the fees owed
/// @return amount0 The amount of fees collected in token0
/// @return amount1 The amount of fees collected in token1
function collect(
address recipient,
int24 tickLower,
int24 tickUpper,
uint128 amount0Requested,
uint128 amount1Requested
) external returns (uint128 amount0, uint128 amount1);
/// @notice Burn liquidity from the sender and account tokens owed for the liquidity to the position
/// @dev Can be used to trigger a recalculation of fees owed to a position by calling with an amount of 0
/// @dev Fees must be collected separately via a call to #collect
/// @param tickLower The lower tick of the position for which to burn liquidity
/// @param tickUpper The upper tick of the position for which to burn liquidity
/// @param amount How much liquidity to burn
/// @return amount0 The amount of token0 sent to the recipient
/// @return amount1 The amount of token1 sent to the recipient
function burn(
int24 tickLower,
int24 tickUpper,
uint128 amount
) external returns (uint256 amount0, uint256 amount1);
/// @notice Swap token0 for token1, or token1 for token0
/// @dev The caller of this method receives a callback in the form of IUniswapV3SwapCallback#uniswapV3SwapCallback
/// @param recipient The address to receive the output of the swap
/// @param zeroForOne The direction of the swap, true for token0 to token1, false for token1 to token0
/// @param amountSpecified The amount of the swap, which implicitly configures the swap as exact input (positive), or exact output (negative)
/// @param sqrtPriceLimitX96 The Q64.96 sqrt price limit. If zero for one, the price cannot be less than this
/// value after the swap. If one for zero, the price cannot be greater than this value after the swap
/// @param data Any data to be passed through to the callback
/// @return amount0 The delta of the balance of token0 of the pool, exact when negative, minimum when positive
/// @return amount1 The delta of the balance of token1 of the pool, exact when negative, minimum when positive
function swap(
address recipient,
bool zeroForOne,
int256 amountSpecified,
uint160 sqrtPriceLimitX96,
bytes calldata data
) external returns (int256 amount0, int256 amount1);
/// @notice Receive token0 and/or token1 and pay it back, plus a fee, in the callback
/// @dev The caller of this method receives a callback in the form of IUniswapV3FlashCallback#uniswapV3FlashCallback
/// @dev Can be used to donate underlying tokens pro-rata to currently in-range liquidity providers by calling
/// with 0 amount{0,1} and sending the donation amount(s) from the callback
/// @param recipient The address which will receive the token0 and token1 amounts
/// @param amount0 The amount of token0 to send
/// @param amount1 The amount of token1 to send
/// @param data Any data to be passed through to the callback
function flash(
address recipient,
uint256 amount0,
uint256 amount1,
bytes calldata data
) external;
/// @notice Increase the maximum number of price and liquidity observations that this pool will store
/// @dev This method is no-op if the pool already has an observationCardinalityNext greater than or equal to
/// the input observationCardinalityNext.
/// @param observationCardinalityNext The desired minimum number of observations for the pool to store
function increaseObservationCardinalityNext(uint16 observationCardinalityNext) external;
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Pool state that is not stored
/// @notice Contains view functions to provide information about the pool that is computed rather than stored on the
/// blockchain. The functions here may have variable gas costs.
interface IUniswapV3PoolDerivedState {
/// @notice Returns the cumulative tick and liquidity as of each timestamp `secondsAgo` from the current block timestamp
/// @dev To get a time weighted average tick or liquidity-in-range, you must call this with two values, one representing
/// the beginning of the period and another for the end of the period. E.g., to get the last hour time-weighted average tick,
/// you must call it with secondsAgos = [3600, 0].
/// @dev The time weighted average tick represents the geometric time weighted average price of the pool, in
/// log base sqrt(1.0001) of token1 / token0. The TickMath library can be used to go from a tick value to a ratio.
/// @param secondsAgos From how long ago each cumulative tick and liquidity value should be returned
/// @return tickCumulatives Cumulative tick values as of each `secondsAgos` from the current block timestamp
/// @return secondsPerLiquidityCumulativeX128s Cumulative seconds per liquidity-in-range value as of each `secondsAgos` from the current block
/// timestamp
function observe(uint32[] calldata secondsAgos)
external
view
returns (int56[] memory tickCumulatives, uint160[] memory secondsPerLiquidityCumulativeX128s);
/// @notice Returns a snapshot of the tick cumulative, seconds per liquidity and seconds inside a tick range
/// @dev Snapshots must only be compared to other snapshots, taken over a period for which a position existed.
/// I.e., snapshots cannot be compared if a position is not held for the entire period between when the first
/// snapshot is taken and the second snapshot is taken.
/// @param tickLower The lower tick of the range
/// @param tickUpper The upper tick of the range
/// @return tickCumulativeInside The snapshot of the tick accumulator for the range
/// @return secondsPerLiquidityInsideX128 The snapshot of seconds per liquidity for the range
/// @return secondsInside The snapshot of seconds per liquidity for the range
function snapshotCumulativesInside(int24 tickLower, int24 tickUpper)
external
view
returns (
int56 tickCumulativeInside,
uint160 secondsPerLiquidityInsideX128,
uint32 secondsInside
);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Events emitted by a pool
/// @notice Contains all events emitted by the pool
interface IUniswapV3PoolEvents {
/// @notice Emitted exactly once by a pool when #initialize is first called on the pool
/// @dev Mint/Burn/Swap cannot be emitted by the pool before Initialize
/// @param sqrtPriceX96 The initial sqrt price of the pool, as a Q64.96
/// @param tick The initial tick of the pool, i.e. log base 1.0001 of the starting price of the pool
event Initialize(uint160 sqrtPriceX96, int24 tick);
/// @notice Emitted when liquidity is minted for a given position
/// @param sender The address that minted the liquidity
/// @param owner The owner of the position and recipient of any minted liquidity
/// @param tickLower The lower tick of the position
/// @param tickUpper The upper tick of the position
/// @param amount The amount of liquidity minted to the position range
/// @param amount0 How much token0 was required for the minted liquidity
/// @param amount1 How much token1 was required for the minted liquidity
event Mint(
address sender,
address indexed owner,
int24 indexed tickLower,
int24 indexed tickUpper,
uint128 amount,
uint256 amount0,
uint256 amount1
);
/// @notice Emitted when fees are collected by the owner of a position
/// @dev Collect events may be emitted with zero amount0 and amount1 when the caller chooses not to collect fees
/// @param owner The owner of the position for which fees are collected
/// @param tickLower The lower tick of the position
/// @param tickUpper The upper tick of the position
/// @param amount0 The amount of token0 fees collected
/// @param amount1 The amount of token1 fees collected
event Collect(
address indexed owner,
address recipient,
int24 indexed tickLower,
int24 indexed tickUpper,
uint128 amount0,
uint128 amount1
);
/// @notice Emitted when a position's liquidity is removed
/// @dev Does not withdraw any fees earned by the liquidity position, which must be withdrawn via #collect
/// @param owner The owner of the position for which liquidity is removed
/// @param tickLower The lower tick of the position
/// @param tickUpper The upper tick of the position
/// @param amount The amount of liquidity to remove
/// @param amount0 The amount of token0 withdrawn
/// @param amount1 The amount of token1 withdrawn
event Burn(
address indexed owner,
int24 indexed tickLower,
int24 indexed tickUpper,
uint128 amount,
uint256 amount0,
uint256 amount1
);
/// @notice Emitted by the pool for any swaps between token0 and token1
/// @param sender The address that initiated the swap call, and that received the callback
/// @param recipient The address that received the output of the swap
/// @param amount0 The delta of the token0 balance of the pool
/// @param amount1 The delta of the token1 balance of the pool
/// @param sqrtPriceX96 The sqrt(price) of the pool after the swap, as a Q64.96
/// @param liquidity The liquidity of the pool after the swap
/// @param tick The log base 1.0001 of price of the pool after the swap
event Swap(
address indexed sender,
address indexed recipient,
int256 amount0,
int256 amount1,
uint160 sqrtPriceX96,
uint128 liquidity,
int24 tick
);
/// @notice Emitted by the pool for any flashes of token0/token1
/// @param sender The address that initiated the swap call, and that received the callback
/// @param recipient The address that received the tokens from flash
/// @param amount0 The amount of token0 that was flashed
/// @param amount1 The amount of token1 that was flashed
/// @param paid0 The amount of token0 paid for the flash, which can exceed the amount0 plus the fee
/// @param paid1 The amount of token1 paid for the flash, which can exceed the amount1 plus the fee
event Flash(
address indexed sender,
address indexed recipient,
uint256 amount0,
uint256 amount1,
uint256 paid0,
uint256 paid1
);
/// @notice Emitted by the pool for increases to the number of observations that can be stored
/// @dev observationCardinalityNext is not the observation cardinality until an observation is written at the index
/// just before a mint/swap/burn.
/// @param observationCardinalityNextOld The previous value of the next observation cardinality
/// @param observationCardinalityNextNew The updated value of the next observation cardinality
event IncreaseObservationCardinalityNext(
uint16 observationCardinalityNextOld,
uint16 observationCardinalityNextNew
);
/// @notice Emitted when the protocol fee is changed by the pool
/// @param feeProtocol0Old The previous value of the token0 protocol fee
/// @param feeProtocol1Old The previous value of the token1 protocol fee
/// @param feeProtocol0New The updated value of the token0 protocol fee
/// @param feeProtocol1New The updated value of the token1 protocol fee
event SetFeeProtocol(uint8 feeProtocol0Old, uint8 feeProtocol1Old, uint8 feeProtocol0New, uint8 feeProtocol1New);
/// @notice Emitted when the collected protocol fees are withdrawn by the factory owner
/// @param sender The address that collects the protocol fees
/// @param recipient The address that receives the collected protocol fees
/// @param amount0 The amount of token0 protocol fees that is withdrawn
/// @param amount0 The amount of token1 protocol fees that is withdrawn
event CollectProtocol(address indexed sender, address indexed recipient, uint128 amount0, uint128 amount1);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Pool state that never changes
/// @notice These parameters are fixed for a pool forever, i.e., the methods will always return the same values
interface IUniswapV3PoolImmutables {
/// @notice The contract that deployed the pool, which must adhere to the IUniswapV3Factory interface
/// @return The contract address
function factory() external view returns (address);
/// @notice The first of the two tokens of the pool, sorted by address
/// @return The token contract address
function token0() external view returns (address);
/// @notice The second of the two tokens of the pool, sorted by address
/// @return The token contract address
function token1() external view returns (address);
/// @notice The pool's fee in hundredths of a bip, i.e. 1e-6
/// @return The fee
function fee() external view returns (uint24);
/// @notice The pool tick spacing
/// @dev Ticks can only be used at multiples of this value, minimum of 1 and always positive
/// e.g.: a tickSpacing of 3 means ticks can be initialized every 3rd tick, i.e., ..., -6, -3, 0, 3, 6, ...
/// This value is an int24 to avoid casting even though it is always positive.
/// @return The tick spacing
function tickSpacing() external view returns (int24);
/// @notice The maximum amount of position liquidity that can use any tick in the range
/// @dev This parameter is enforced per tick to prevent liquidity from overflowing a uint128 at any point, and
/// also prevents out-of-range liquidity from being used to prevent adding in-range liquidity to a pool
/// @return The max amount of liquidity per tick
function maxLiquidityPerTick() external view returns (uint128);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Permissioned pool actions
/// @notice Contains pool methods that may only be called by the factory owner
interface IUniswapV3PoolOwnerActions {
/// @notice Set the denominator of the protocol's % share of the fees
/// @param feeProtocol0 new protocol fee for token0 of the pool
/// @param feeProtocol1 new protocol fee for token1 of the pool
function setFeeProtocol(uint8 feeProtocol0, uint8 feeProtocol1) external;
/// @notice Collect the protocol fee accrued to the pool
/// @param recipient The address to which collected protocol fees should be sent
/// @param amount0Requested The maximum amount of token0 to send, can be 0 to collect fees in only token1
/// @param amount1Requested The maximum amount of token1 to send, can be 0 to collect fees in only token0
/// @return amount0 The protocol fee collected in token0
/// @return amount1 The protocol fee collected in token1
function collectProtocol(
address recipient,
uint128 amount0Requested,
uint128 amount1Requested
) external returns (uint128 amount0, uint128 amount1);
}// SPDX-License-Identifier: GPL-2.0-or-later
pragma solidity >=0.5.0;
/// @title Pool state that can change
/// @notice These methods compose the pool's state, and can change with any frequency including multiple times
/// per transaction
interface IUniswapV3PoolState {
/// @notice The 0th storage slot in the pool stores many values, and is exposed as a single method to save gas
/// when accessed externally.
/// @return sqrtPriceX96 The current price of the pool as a sqrt(token1/token0) Q64.96 value
/// tick The current tick of the pool, i.e. according to the last tick transition that was run.
/// This value may not always be equal to SqrtTickMath.getTickAtSqrtRatio(sqrtPriceX96) if the price is on a tick
/// boundary.
/// observationIndex The index of the last oracle observation that was written,
/// observationCardinality The current maximum number of observations stored in the pool,
/// observationCardinalityNext The next maximum number of observations, to be updated when the observation.
/// feeProtocol The protocol fee for both tokens of the pool.
/// Encoded as two 4 bit values, where the protocol fee of token1 is shifted 4 bits and the protocol fee of token0
/// is the lower 4 bits. Used as the denominator of a fraction of the swap fee, e.g. 4 means 1/4th of the swap fee.
/// unlocked Whether the pool is currently locked to reentrancy
function slot0()
external
view
returns (
uint160 sqrtPriceX96,
int24 tick,
uint16 observationIndex,
uint16 observationCardinality,
uint16 observationCardinalityNext,
uint8 feeProtocol,
bool unlocked
);
/// @notice The fee growth as a Q128.128 fees of token0 collected per unit of liquidity for the entire life of the pool
/// @dev This value can overflow the uint256
function feeGrowthGlobal0X128() external view returns (uint256);
/// @notice The fee growth as a Q128.128 fees of token1 collected per unit of liquidity for the entire life of the pool
/// @dev This value can overflow the uint256
function feeGrowthGlobal1X128() external view returns (uint256);
/// @notice The amounts of token0 and token1 that are owed to the protocol
/// @dev Protocol fees will never exceed uint128 max in either token
function protocolFees() external view returns (uint128 token0, uint128 token1);
/// @notice The currently in range liquidity available to the pool
/// @dev This value has no relationship to the total liquidity across all ticks
function liquidity() external view returns (uint128);
/// @notice Look up information about a specific tick in the pool
/// @param tick The tick to look up
/// @return liquidityGross the total amount of position liquidity that uses the pool either as tick lower or
/// tick upper,
/// liquidityNet how much liquidity changes when the pool price crosses the tick,
/// feeGrowthOutside0X128 the fee growth on the other side of the tick from the current tick in token0,
/// feeGrowthOutside1X128 the fee growth on the other side of the tick from the current tick in token1,
/// tickCumulativeOutside the cumulative tick value on the other side of the tick from the current tick
/// secondsPerLiquidityOutsideX128 the seconds spent per liquidity on the other side of the tick from the current tick,
/// secondsOutside the seconds spent on the other side of the tick from the current tick,
/// initialized Set to true if the tick is initialized, i.e. liquidityGross is greater than 0, otherwise equal to false.
/// Outside values can only be used if the tick is initialized, i.e. if liquidityGross is greater than 0.
/// In addition, these values are only relative and must be used only in comparison to previous snapshots for
/// a specific position.
function ticks(int24 tick)
external
view
returns (
uint128 liquidityGross,
int128 liquidityNet,
uint256 feeGrowthOutside0X128,
uint256 feeGrowthOutside1X128,
int56 tickCumulativeOutside,
uint160 secondsPerLiquidityOutsideX128,
uint32 secondsOutside,
bool initialized
);
/// @notice Returns 256 packed tick initialized boolean values. See TickBitmap for more information
function tickBitmap(int16 wordPosition) external view returns (uint256);
/// @notice Returns the information about a position by the position's key
/// @param key The position's key is a hash of a preimage composed by the owner, tickLower and tickUpper
/// @return _liquidity The amount of liquidity in the position,
/// Returns feeGrowthInside0LastX128 fee growth of token0 inside the tick range as of the last mint/burn/poke,
/// Returns feeGrowthInside1LastX128 fee growth of token1 inside the tick range as of the last mint/burn/poke,
/// Returns tokensOwed0 the computed amount of token0 owed to the position as of the last mint/burn/poke,
/// Returns tokensOwed1 the computed amount of token1 owed to the position as of the last mint/burn/poke
function positions(bytes32 key)
external
view
returns (
uint128 _liquidity,
uint256 feeGrowthInside0LastX128,
uint256 feeGrowthInside1LastX128,
uint128 tokensOwed0,
uint128 tokensOwed1
);
/// @notice Returns data about a specific observation index
/// @param index The element of the observations array to fetch
/// @dev You most likely want to use #observe() instead of this method to get an observation as of some amount of time
/// ago, rather than at a specific index in the array.
/// @return blockTimestamp The timestamp of the observation,
/// Returns tickCumulative the tick multiplied by seconds elapsed for the life of the pool as of the observation timestamp,
/// Returns secondsPerLiquidityCumulativeX128 the seconds per in range liquidity for the life of the pool as of the observation timestamp,
/// Returns initialized whether the observation has been initialized and the values are safe to use
function observations(uint256 index)
external
view
returns (
uint32 blockTimestamp,
int56 tickCumulative,
uint160 secondsPerLiquidityCumulativeX128,
bool initialized
);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
interface IPair {
function metadata() external view returns (uint dec0, uint dec1, uint r0, uint r1, bool st, address t0, address t1);
function claimFees() external returns (uint, uint);
function tokens() external view returns (address, address);
function token0() external view returns (address);
function token1() external view returns (address);
function fees() external view returns (address);
function transferFrom(address src, address dst, uint amount) external returns (bool);
function permit(address owner, address spender, uint value, uint deadline, uint8 v, bytes32 r, bytes32 s) external;
function swap(uint amount0Out, uint amount1Out, address to, bytes calldata data) external;
function burn(address to) external returns (uint amount0, uint amount1);
function mint(address to) external returns (uint liquidity);
function getReserves() external view returns (uint _reserve0, uint _reserve1, uint _blockTimestampLast);
function getAmountOut(uint amountIn, address tokenIn) external view returns (uint);
function name() external view returns(string memory);
function symbol() external view returns(string memory);
function totalSupply() external view returns (uint);
function decimals() external view returns (uint8);
function claimable0(address _user) external view returns (uint);
function claimable1(address _user) external view returns (uint);
function isStable() external view returns(bool);
function quote(address tokenIn, uint amountIn, uint granularity) external view returns (uint amountOut);
}// SPDX-License-Identifier: GPL-3.0-only
pragma solidity >=0.7.0;
interface IDynamicTwapOracle {
/**
* @notice Get the address of the pool
* @return The address of the pool
*/
function pool() external view returns (address);
/**
* @notice Get the address of the first token in the pool
* @return The address of the first token
*/
function token0() external view returns (address);
/**
* @notice Get the address of the second token in the pool
* @return The address of the second token
*/
function token1() external view returns (address);
/**
* @notice Estimate the output amount of a trade
* @param tokenIn The address of the input token
* @param amountIn The amount of the input token
* @param secondsAgo The number of seconds ago to start the TWAP
* @return amountOut The estimated output amount
*/
function estimateAmountOut(
address tokenIn,
uint128 amountIn,
uint32 secondsAgo
) external view returns (uint amountOut);
}// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {IFlashRedeemer} from "./IFlashRedeemer.sol";
import {IUniswapV3Pool} from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
/// @title IFlashRedeemer_UniswapV3
/// @notice UniswapV3-specific flash loan redemption interface
/// @dev Extends the base IFlashRedeemer with UniswapV3-specific functionality
interface IFlashRedeemer_UniswapV3 is IFlashRedeemer {
/// @notice Gets the UniswapV3 pool used for the flash loan
function flashPool() external view returns (IUniswapV3Pool);
/// @notice Gets the UniswapV3 pool used for the underlying→payment swap leg
function swapPool() external view returns (IUniswapV3Pool);
}// SPDX-License-Identifier: MIT
pragma solidity 0.8.13;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IUniswapV3Pool} from "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
import {IOptionTokenV3} from "../IOptionTokenV3.sol";
/// @title IFlashRedeemer
/// @notice Generic interface for flash loan redemption systems
/// @dev Base interface that can be extended for different DEX implementations
interface IFlashRedeemer {
/// @notice Estimates flash loan redemption parameters
/// @param amount The amount of option tokens to redeem
/// @return estimation The redemption estimation
function estimateFlashRedemption(
uint256 amount
) external view returns (FlashRedemptionEstimation memory estimation);
/// @notice Simple estimation structure for flash redemption
struct FlashRedemptionEstimation {
uint256 optionAmount; // Amount of option tokens to redeem
uint256 paymentAmount; // Payment tokens needed for redemption
uint256 underlyingReceived; // Underlying tokens received from redemption
uint256 flashLoanFee; // Flash loan fee
}
/// @notice Executes a flash loan redemption
/// @param estimation The flash redemption estimation containing all parameters
function flashRedeem(
FlashRedemptionEstimation memory estimation
) external;
function optionToken() external view returns (IOptionTokenV3);
/// @notice Gets the payment token
/// @return The payment token contract
function paymentToken() external view returns (IERC20);
/// @notice Gets the underlying token
/// @return The underlying token contract
function underlyingToken() external view returns (IERC20);
}// SPDX-License-Identifier: GPL-3.0-only
pragma solidity 0.8.13;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
interface IOption is IAccessControl {
function paymentToken() external view returns (IERC20);
function getPaymentAmount(uint256 _amount, bytes calldata _data) external view returns (uint256);
function exercise(uint256 _amount, address sender, bytes calldata _data) external returns (uint256);
}// SPDX-License-Identifier: GPL-3.0-only
pragma solidity 0.8.13;
interface IOptionFeeDistributor {
function distribute(address token, uint256 amount) external;
}// SPDX-License-Identifier: GPL-3.0-only
pragma solidity 0.8.13;
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {IAccessControl} from "@openzeppelin/contracts/access/IAccessControl.sol";
import {IDynamicTwapOracle} from "./DynamicTwapOracle/IDynamicTwapOracle.sol";
import {IOptionFeeDistributor} from "./IOptionFeeDistributor.sol";
import {IPair} from "../interfaces/IPair.sol";
import {IOption} from "./IOption.sol";
interface IOptionTokenV3 is IERC20, IAccessControl {
function ADMIN_ROLE() external view returns (bytes32);
function MINTER_ROLE() external view returns (bytes32);
function PAUSER_ROLE() external view returns (bytes32);
function paymentToken() external view returns (IERC20);
function UNDERLYING_TOKEN() external view returns (IERC20);
function voter() external view returns (address);
function twapOracle() external view returns (IDynamicTwapOracle);
function mint(address _to, uint256 _amount) external;
function exercise(uint256 _amount, uint256 _maxPaymentAmount, address _recipient) external returns (uint256);
function exercise(uint256 _amount, uint256 _maxPaymentAmount, address _recipient, uint256 _deadline) external returns (uint256);
function exerciseVe(uint256 _amount, uint256 _maxPaymentAmount, address _recipient, uint256 _discount, uint256 _deadline) external returns (uint256, uint256);
function exerciseLp(uint256 _amount, uint256 _maxPaymentAmount, uint256 _maxLPAmount, address _recipient, uint256 _discount, uint256 _deadline) external returns (uint256, uint256);
function exerciseExternal(IOption _option, uint256 _amount, uint256 _deadline, bytes calldata _data) external returns (uint256);
function getVotingEscrow() external view returns (address votingEscrow);
function getLockDurationForVeDiscount(uint256 _discount) external view returns (uint256 duration);
function getSlopeInterceptForVeDiscount() external view returns (int256 slope, int256 intercept);
function togglePermissionedMint() external;
function toggleOption(address option, bool enabled) external;
function getDiscountedPrice(uint256 _amount) external view returns (uint256);
function getDiscountedPrice(uint256 _amount, uint256 _discount) external view returns (uint256);
function getLockDurationForLpDiscount(uint256 _amount) external view returns (uint256);
function getPaymentTokenAmountForExerciseLp(
uint256 _amount,
uint256 _discount
) external view returns (uint256, uint256);
function getSlopeInterceptForLpDiscount() external view returns (int256, int256);
function getTimeWeightedAveragePrice(uint256 _amount) external view returns (uint256);
function setTwapOracleAndPaymentToken(IDynamicTwapOracle _twapOracle, address _paymentToken) external;
function setPairAndPaymentToken(IPair _pair, address _paymentToken) external;
function setFeeDistributor(IOptionFeeDistributor _feeDistributor) external;
function setDiscount(uint256 _discount) external;
function setVeDiscount(uint256 _veDiscount) external;
function setMinLPDiscount(uint256 _lpMinDiscount) external;
function setMaxLPDiscount(uint256 _lpMaxDiscount) external;
function setLockDurationForMaxLpDiscount(uint256 _duration) external;
function setLockDurationForMinLpDiscount(uint256 _duration) external;
function setTwapSeconds(uint32 _twapSeconds) external;
function burn(uint256 _amount) external;
function updateGauge() external;
function setGauge(address _gauge) external;
function setRouter(address _router) external;
function unPause() external;
function pause() external;
}{
"optimizer": {
"enabled": true,
"runs": 200
},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"inputs":[{"internalType":"address","name":"_optionToken","type":"address"},{"internalType":"address","name":"_flashPool","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"FlashRedeemer_InsufficientOutput","type":"error"},{"inputs":[],"name":"FlashRedeemer_InvalidAmount","type":"error"},{"inputs":[],"name":"FlashRedeemer_InvalidCallbackData","type":"error"},{"inputs":[],"name":"FlashRedeemer_InvalidOptionToken","type":"error"},{"inputs":[],"name":"FlashRedeemer_InvalidPool","type":"error"},{"inputs":[],"name":"FlashRedeemer_InvalidRecipient","type":"error"},{"inputs":[],"name":"FlashRedeemer_RedemptionFailed","type":"error"},{"inputs":[],"name":"FlashRedeemer_SwapFailed","type":"error"},{"inputs":[],"name":"FlashRedeemer_Unauthorized","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"optionToken","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"underlyingOut","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"profit","type":"uint256"}],"name":"FlashRedemptionExecuted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"optionToken","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"string","name":"reason","type":"string"}],"name":"FlashRedemptionFailed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"underlyingAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"paymentAmount","type":"uint256"}],"name":"ProfitDistributed","type":"event"},{"inputs":[{"internalType":"uint256","name":"optionAmount","type":"uint256"}],"name":"estimateFlashRedemption","outputs":[{"components":[{"internalType":"uint256","name":"optionAmount","type":"uint256"},{"internalType":"uint256","name":"paymentAmount","type":"uint256"},{"internalType":"uint256","name":"underlyingReceived","type":"uint256"},{"internalType":"uint256","name":"flashLoanFee","type":"uint256"}],"internalType":"struct IFlashRedeemer.FlashRedemptionEstimation","name":"estimation","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"flashPool","outputs":[{"internalType":"contract IUniswapV3Pool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"optionAmount","type":"uint256"},{"internalType":"uint256","name":"paymentAmount","type":"uint256"},{"internalType":"uint256","name":"underlyingReceived","type":"uint256"},{"internalType":"uint256","name":"flashLoanFee","type":"uint256"}],"internalType":"struct IFlashRedeemer.FlashRedemptionEstimation","name":"estimation","type":"tuple"}],"name":"flashRedeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"optionToken","outputs":[{"internalType":"contract IOptionTokenV3","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"paymentToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"optionToken","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"paymentAmount","type":"uint256"},{"internalType":"uint256","name":"minUnderlyingOut","type":"uint256"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"caller","type":"address"}],"internalType":"struct FlashRedeemer_UniswapV3.FlashCallbackData","name":"data","type":"tuple"},{"internalType":"uint256","name":"fee0","type":"uint256"},{"internalType":"uint256","name":"fee1","type":"uint256"}],"name":"self_executeFlashRedemption","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"swapPool","outputs":[{"internalType":"contract IUniswapV3Pool","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"underlyingToken","outputs":[{"internalType":"contract IERC20","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"fee0","type":"uint256"},{"internalType":"uint256","name":"fee1","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"uniswapV3FlashCallback","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"int256","name":"amount0Delta","type":"int256"},{"internalType":"int256","name":"amount1Delta","type":"int256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"uniswapV3SwapCallback","outputs":[],"stateMutability":"nonpayable","type":"function"}]Contract Creation Code
60e06040523480156200001157600080fd5b5060405162002f0d38038062002f0d833981016040819052620000349162000b49565b60016000556001600160a01b03821662000061576040516382c6b5f760e01b815260040160405180910390fd5b6001600160a01b03811662000089576040516383a7901960e01b815260040160405180910390fd5b6001600160a01b03808316608081905290821660a05260408051634821949560e11b81529051639043292a916004808201926020929091908290030181865afa925050508015620000f9575060408051601f3d908101601f19168201909252620000f69181019062000b88565b60015b62000117576040516382c6b5f760e01b815260040160405180910390fd5b806001600160a01b03166316f0115b6040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801562000174575060408051601f3d908101601f19168201909252620001719181019062000b88565b60015b62000192576040516382c6b5f760e01b815260040160405180910390fd5b6001600160a01b038116620001ba576040516383a7901960e01b815260040160405180910390fd5b6001600160a01b031660c0525060a051620001d590620002e7565b60c051620001e39062000692565b6080516001600160a01b0316633013ce296040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801562000242575060408051601f3d908101601f191682019092526200023f9181019062000b88565b60015b62000260576040516382c6b5f760e01b815260040160405180910390fd5b506080516001600160a01b03166329db1be66040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015620002c0575060408051601f3d908101601f19168201909252620002bd9181019062000b88565b60015b620002de576040516382c6b5f760e01b815260040160405180910390fd5b50505062000c9e565b806001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801562000344575060408051601f3d908101601f19168201909252620003419181019062000b88565b60015b62000362576040516383a7901960e01b815260040160405180910390fd5b50600080826001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015620003c3575060408051601f3d908101601f19168201909252620003c09181019062000b88565b60015b620003e1576040516383a7901960e01b815260040160405180910390fd5b809250836001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000423573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000449919062000b88565b9150506001600160a01b03821615806200046a57506001600160a01b038116155b80620004875750806001600160a01b0316826001600160a01b0316145b15620004a6576040516383a7901960e01b815260040160405180910390fd5b60006080516001600160a01b0316633013ce296040518163ffffffff1660e01b8152600401602060405180830381865afa158015620004e9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906200050f919062000b88565b9050826001600160a01b0316816001600160a01b031614158015620005465750816001600160a01b0316816001600160a01b031614155b1562000565576040516383a7901960e01b815260040160405180910390fd5b836001600160a01b031663ddca3f436040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015620005c2575060408051601f3d908101601f19168201909252620005bf9181019062000baf565b60015b620005e0576040516383a7901960e01b815260040160405180910390fd5b620f42408162ffffff161062000609576040516383a7901960e01b815260040160405180910390fd5b50836001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa92505050801562000667575060408051601f3d908101601f19168201909252620006649181019062000bee565b60015b62000685576040516383a7901960e01b815260040160405180910390fd5b5050505050505050505050565b806001600160a01b031663c45a01556040518163ffffffff1660e01b8152600401602060405180830381865afa925050508015620006ef575060408051601f3d908101601f19168201909252620006ec9181019062000b88565b60015b6200070d576040516383a7901960e01b815260040160405180910390fd5b50600080826001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa9250505080156200076e575060408051601f3d908101601f191682019092526200076b9181019062000b88565b60015b6200078c576040516383a7901960e01b815260040160405180910390fd5b809250836001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015620007ce573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620007f4919062000b88565b9150506001600160a01b03821615806200081557506001600160a01b038116155b80620008325750806001600160a01b0316826001600160a01b0316145b1562000851576040516383a7901960e01b815260040160405180910390fd5b60006080516001600160a01b0316633013ce296040518163ffffffff1660e01b8152600401602060405180830381865afa15801562000894573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190620008ba919062000b88565b905060006080516001600160a01b03166329db1be66040518163ffffffff1660e01b8152600401602060405180830381865afa158015620008ff573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019062000925919062000b88565b9050836001600160a01b0316826001600160a01b0316141580156200095c5750826001600160a01b0316826001600160a01b031614155b156200097b576040516383a7901960e01b815260040160405180910390fd5b836001600160a01b0316816001600160a01b031614158015620009b05750826001600160a01b0316816001600160a01b031614155b15620009cf576040516383a7901960e01b815260040160405180910390fd5b806001600160a01b0316826001600160a01b03160362000a02576040516383a7901960e01b815260040160405180910390fd5b846001600160a01b031663ddca3f436040518163ffffffff1660e01b8152600401602060405180830381865afa92505050801562000a5f575060408051601f3d908101601f1916820190925262000a5c9181019062000baf565b60015b62000a7d576040516383a7901960e01b815260040160405180910390fd5b620f42408162ffffff161062000aa6576040516383a7901960e01b815260040160405180910390fd5b50846001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa92505050801562000b04575060408051601f3d908101601f1916820190925262000b019181019062000bee565b60015b62000b22576040516383a7901960e01b815260040160405180910390fd5b505050505050505050505050565b6001600160a01b038116811462000b4657600080fd5b50565b6000806040838503121562000b5d57600080fd5b825162000b6a8162000b30565b602084015190925062000b7d8162000b30565b809150509250929050565b60006020828403121562000b9b57600080fd5b815162000ba88162000b30565b9392505050565b60006020828403121562000bc257600080fd5b815162ffffff8116811462000ba857600080fd5b805161ffff8116811462000be957600080fd5b919050565b600080600080600080600060e0888a03121562000c0a57600080fd5b875162000c178162000b30565b8097505060208801518060020b811462000c3057600080fd5b955062000c406040890162000bd6565b945062000c506060890162000bd6565b935062000c606080890162000bd6565b925060a088015160ff8116811462000c7757600080fd5b60c0890151909250801515811462000c8e57600080fd5b8091505092959891949750929550565b60805160a05160c0516121ad62000d606000396000818161011101528181610b0101528181610b6001528181610bf50152818161116c015281816111f201528181611314015281816114da01528181611566015261168c01526000818161013801528181610512015281816105ee0152818161089e0152818161099b01528181610d6201528181610e080152610f5101526000818160cd015281816101dd01528181610266015281816102e60152818161081c0152610ecf01526121ad6000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c8063aa7f0ceb11610066578063aa7f0ceb14610133578063cf81276c1461015a578063e9cbafb0146101a0578063fa461e33146101b3578063fe48430a146101c657600080fd5b80632495a599146100a35780632bab754b146100c85780633013ce29146100ef5780638659c009146100f7578063982697dd1461010c575b600080fd5b6100ab6101d9565b6040516001600160a01b0390911681526020015b60405180910390f35b6100ab7f000000000000000000000000000000000000000000000000000000000000000081565b6100ab610262565b61010a610105366004611b52565b6102c2565b005b6100ab7f000000000000000000000000000000000000000000000000000000000000000081565b6100ab7f000000000000000000000000000000000000000000000000000000000000000081565b61016d610168366004611b87565b6107cb565b6040516100bf91908151815260208083015190820152604080830151908201526060918201519181019190915260800190565b61010a6101ae366004611be9565b610990565b61010a6101c1366004611be9565b610af6565b61010a6101d4366004611c3c565b610cf8565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03166329db1be66040518163ffffffff1660e01b8152600401602060405180830381865afa158015610239573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061025d9190611cb0565b905090565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633013ce296040518163ffffffff1660e01b8152600401602060405180830381865afa158015610239573d6000803e3d6000fd5b3330146102e25760405163e252986960e01b815260040160405180910390fd5b82517f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0390811690821614610331576040516382c6b5f760e01b815260040160405180910390fd5b60a084015160208501516040516323b872dd60e01b81526001600160a01b0392831660048201523060248201526044810191909152908216906323b872dd906064016020604051808303816000875af1158015610392573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103b69190611ce9565b5060006103c1610262565b90506103d86001600160a01b038216836000610fcf565b60408501516103f3906001600160a01b038316908490610fcf565b60208501516040808701519051636b1bcdb960e11b8152600481019290925260248201523060448201526001600160a01b0383169063d6379b72906064016020604051808303816000875af1158015610450573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104749190611d04565b5061048a6001600160a01b038216836000610fcf565b60006104946101d9565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa1580156104de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105029190611d04565b90506000836001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa15801561056e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105929190611cb0565b6001600160a01b0316146105a657856105a8565b865b88604001516105b79190611d33565b9050600060646105c8846063611d4b565b6105d29190611d6a565b90506105de828261111c565b506106136001600160a01b0386167f000000000000000000000000000000000000000000000000000000000000000084611488565b6040516370a0823160e01b81523060048201526000906001600160a01b038616906370a0823190602401602060405180830381865afa15801561065a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067e9190611d04565b905089606001518110156106a55760405163113999b160e21b815260040160405180910390fd5b80156106c55760808a01516106c5906001600160a01b0387169083611488565b6040516370a0823160e01b81523060048201526000906001600160a01b038816906370a0823190602401602060405180830381865afa15801561070c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107309190611d04565b905080156107525760808b0151610752906001600160a01b0389169083611488565b8a608001516001600160a01b03168b600001516001600160a01b03167f04ba039dfde9e4c1a73889a9d1fa4fd72845f4c03533d3e5a7d35e65dc43009d8d6020015188866040516107b6939291909283526020830191909152604082015260600190565b60405180910390a35050505050505050505050565b6107f66040518060800160405280600081526020016000815260200160008152602001600081525090565b8160000361080357919050565b8181526040516319ce656f60e11b8152600481018390527f00000000000000000000000000000000000000000000000000000000000000006001600160a01b03169063339ccade90602401602060405180830381865afa15801561086b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061088f9190611d04565b816020018181525050620f42407f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663ddca3f436040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061091e9190611d8c565b62ffffff1682602001516109329190611d4b565b61093c9190611d6a565b60608201819052602082015160009161095491611d33565b9050826000610962836114b8565b905080821115610980576109768183611db1565b6040850152610988565b600060408501525b505050919050565b336001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016146109d95760405163e252986960e01b815260040160405180910390fd5b60006109e782840184611dc8565b604051638659c00960e01b81529091503090638659c00990610a1190849089908990600401611e29565b600060405180830381600087803b158015610a2b57600080fd5b505af1925050508015610a3c575060015b610aef57610a48611e49565b806308c379a003610ae35750610a5c611e65565b80610a675750610ae5565b81608001516001600160a01b031682600001516001600160a01b03167f7d14f00d1a9f979262535a6d3dbc9dcb543e3d7110df00763d921d11ef4452ba846020015184604051610ab8929190611f47565b60405180910390a38060405162461bcd60e51b8152600401610ada9190611f60565b60405180910390fd5b505b3d6000803e3d6000fd5b5050505050565b336001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614610b3f5760405163e252986960e01b815260040160405180910390fd5b6000610b4d82840184611b87565b90506000806000871315610be7578691507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015610bbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610be09190611cb0565b9050610c59565b6000861315610c51578591507f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015610bbc573d6000803e3d6000fd5b505050610cf2565b82821115610c7a57604051633245138160e21b815260040160405180910390fd5b610c826101d9565b6001600160a01b0316816001600160a01b031614158015610cbc5750610ca6610262565b6001600160a01b0316816001600160a01b031614155b15610cda57604051631a6ae4bd60e01b815260040160405180910390fd5b610cee6001600160a01b0382163384611488565b5050505b50505050565b610d006117a0565b8051600003610d2257604051632a045c0f60e11b815260040160405180910390fd5b8060200151600003610d4757604051632a045c0f60e11b815260040160405180910390fd5b6000806000610d54610262565b9050806001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015610dbe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610de29190611cb0565b6001600160a01b031603610dfc5783602001519250610ebb565b806001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e889190611cb0565b6001600160a01b031603610ea25783602001519150610ebb565b6040516382c6b5f760e01b815260040160405180910390fd5b6040805160c0810182526001600160a01b037f000000000000000000000000000000000000000000000000000000000000000016815285516020808301919091528681015182840152868301516060830152336080830181905260a08301529151600092610f2a929101611f73565b60408051601f19818403018152908290526312439b2f60e21b825291506001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000169063490e6cbc90610f8c903090889088908790600401611f81565b600060405180830381600087803b158015610fa657600080fd5b505af1158015610fba573d6000803e3d6000fd5b5050505050505050610fcc6001600055565b50565b8015806110495750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015611023573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110479190611d04565b155b6110b45760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610ada565b6040516001600160a01b03831660248201526044810182905261111790849063095ea7b360e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526117f9565b505050565b60008260000361112e57506000611482565b8160000361114f57604051633245138160e21b815260040160405180910390fd5b60006111596101d9565b90506000611165610262565b90506000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ec9190611cb0565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa15801561124e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112729190611cb0565b9050816001600160a01b0316856001600160a01b03161480156112a65750806001600160a01b0316846001600160a01b0316145b156112b4576001925061130d565b806001600160a01b0316856001600160a01b03161480156112e65750816001600160a01b0316846001600160a01b0316145b156112f4576000925061130d565b604051633245138160e21b815260040160405180910390fd5b50506000807f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663128acb0830858b61134d90611fb8565b8761137657611371600173fffd8963efd1fc6a506488495d951d5263988d26611fd4565b611386565b6113866401000276a36001611ffc565b60408051602081018f9052016040516020818303038152906040526040518663ffffffff1660e01b81526004016113c1959493929190612027565b60408051808303816000875af11580156113df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114039190612062565b915091508215611436576000821361142e57604051633245138160e21b815260040160405180910390fd5b81955061145b565b6000811361145757604051633245138160e21b815260040160405180910390fd5b8095505b8686111561147c57604051633245138160e21b815260040160405180910390fd5b50505050505b92915050565b6040516001600160a01b03831660248201526044810182905261111790849063a9059cbb60e01b906064016110e0565b6000816000036114ca57506000919050565b60006114d46101d9565b905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa158015611536573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061155a9190612098565b505050505050905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115e69190611cb0565b6001600160a01b0316836001600160a01b0316149050600081156116445760006116196001600160a01b03851680611d4b565b9050600160c01b808210611638576116318183611d6a565b925061163d565b600192505b5050611680565b60006116596001600160a01b03851680611d4b565b9050600160c01b8115611677576116708282611d6a565b925061167d565b60001992505b50505b8060000361173e5760007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316631a6865026040518163ffffffff1660e01b8152600401602060405180830381865afa1580156116e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061170c9190612132565b90506001600160801b0381161561172a5764e8d4a510009150611738565b506000199695505050505050565b50611759565b670de0b6b3a76400008111156117595750670de0b6b3a76400005b8015611770576117698187611d6a565b9450611776565b60001994505b61178a670de0b6b3a7640000600019611d6a565b8511156117975760001994505b50505050919050565b6002600054036117f25760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610ada565b6002600055565b600061184e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166118ce9092919063ffffffff16565b905080516000148061186f57508080602001905181019061186f9190611ce9565b6111175760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610ada565b60606118dd84846000856118e5565b949350505050565b6060824710156119465760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610ada565b600080866001600160a01b03168587604051611962919061215b565b60006040518083038185875af1925050503d806000811461199f576040519150601f19603f3d011682016040523d82523d6000602084013e6119a4565b606091505b50915091506119b5878383876119c0565b979650505050505050565b60608315611a2f578251600003611a28576001600160a01b0385163b611a285760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610ada565b50816118dd565b6118dd8383815115611a445781518083602001fd5b8060405162461bcd60e51b8152600401610ada9190611f60565b601f8201601f1916810167ffffffffffffffff81118282101715611a9257634e487b7160e01b600052604160045260246000fd5b6040525050565b6001600160a01b0381168114610fcc57600080fd5b600060c08284031215611ac057600080fd5b60405160c0810181811067ffffffffffffffff82111715611af157634e487b7160e01b600052604160045260246000fd5b6040529050808235611b0281611a99565b808252506020830135602082015260408301356040820152606083013560608201526080830135611b3281611a99565b608082015260a0830135611b4581611a99565b60a0919091015292915050565b60008060006101008486031215611b6857600080fd5b611b728585611aae565b9560c0850135955060e0909401359392505050565b600060208284031215611b9957600080fd5b5035919050565b60008083601f840112611bb257600080fd5b50813567ffffffffffffffff811115611bca57600080fd5b602083019150836020828501011115611be257600080fd5b9250929050565b60008060008060608587031215611bff57600080fd5b8435935060208501359250604085013567ffffffffffffffff811115611c2457600080fd5b611c3087828801611ba0565b95989497509550505050565b600060808284031215611c4e57600080fd5b6040516080810181811067ffffffffffffffff82111715611c7f57634e487b7160e01b600052604160045260246000fd5b8060405250823581526020830135602082015260408301356040820152606083013560608201528091505092915050565b600060208284031215611cc257600080fd5b8151611ccd81611a99565b9392505050565b80518015158114611ce457600080fd5b919050565b600060208284031215611cfb57600080fd5b611ccd82611cd4565b600060208284031215611d1657600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b60008219821115611d4657611d46611d1d565b500190565b6000816000190483118215151615611d6557611d65611d1d565b500290565b600082611d8757634e487b7160e01b600052601260045260246000fd5b500490565b600060208284031215611d9e57600080fd5b815162ffffff81168114611ccd57600080fd5b600082821015611dc357611dc3611d1d565b500390565b600060c08284031215611dda57600080fd5b611ccd8383611aae565b80516001600160a01b03908116835260208083015190840152604080830151908401526060808301519084015260808083015182169084015260a09182015116910152565b6101008101611e388286611de4565b60c082019390935260e00152919050565b600060033d1115611e625760046000803e5060005160e01c5b90565b600060443d1015611e735790565b6040516003193d81016004833e81513d67ffffffffffffffff8160248401118184111715611ea357505050505090565b8285019150815181811115611ebb5750505050505090565b843d8701016020828501011115611ed55750505050505090565b611ee460208286010187611a5e565b509095945050505050565b60005b83811015611f0a578181015183820152602001611ef2565b83811115610cf25750506000910152565b60008151808452611f33816020860160208601611eef565b601f01601f19169290920160200192915050565b8281526040602082015260006118dd6040830184611f1b565b602081526000611ccd6020830184611f1b565b60c081016114828284611de4565b60018060a01b0385168152836020820152826040820152608060608201526000611fae6080830184611f1b565b9695505050505050565b6000600160ff1b8201611fcd57611fcd611d1d565b5060000390565b60006001600160a01b0383811690831681811015611ff457611ff4611d1d565b039392505050565b60006001600160a01b0382811684821680830382111561201e5761201e611d1d565b01949350505050565b6001600160a01b0386811682528515156020830152604082018590528316606082015260a0608082018190526000906119b590830184611f1b565b6000806040838503121561207557600080fd5b505080516020909101519092909150565b805161ffff81168114611ce457600080fd5b600080600080600080600060e0888a0312156120b357600080fd5b87516120be81611a99565b8097505060208801518060020b81146120d657600080fd5b95506120e460408901612086565b94506120f260608901612086565b935061210060808901612086565b925060a088015160ff8116811461211657600080fd5b915061212460c08901611cd4565b905092959891949750929550565b60006020828403121561214457600080fd5b81516001600160801b0381168114611ccd57600080fd5b6000825161216d818460208701611eef565b919091019291505056fea2646970667358221220a51d1235c75504e517c172b6f0eb277cc4ef32a527a16c853b1aed12ae0b7bf064736f6c634300080d0033000000000000000000000000ed67a6cbf4b9f3d0d818e158f5e7f4dfb3166783000000000000000000000000d49174dba635489c67fa628864c2d0d04824ebd8
Deployed Bytecode
0x608060405234801561001057600080fd5b506004361061009e5760003560e01c8063aa7f0ceb11610066578063aa7f0ceb14610133578063cf81276c1461015a578063e9cbafb0146101a0578063fa461e33146101b3578063fe48430a146101c657600080fd5b80632495a599146100a35780632bab754b146100c85780633013ce29146100ef5780638659c009146100f7578063982697dd1461010c575b600080fd5b6100ab6101d9565b6040516001600160a01b0390911681526020015b60405180910390f35b6100ab7f000000000000000000000000ed67a6cbf4b9f3d0d818e158f5e7f4dfb316678381565b6100ab610262565b61010a610105366004611b52565b6102c2565b005b6100ab7f00000000000000000000000097e4442bca2c069f9060f3b8eef52eb25c98c24581565b6100ab7f000000000000000000000000d49174dba635489c67fa628864c2d0d04824ebd881565b61016d610168366004611b87565b6107cb565b6040516100bf91908151815260208083015190820152604080830151908201526060918201519181019190915260800190565b61010a6101ae366004611be9565b610990565b61010a6101c1366004611be9565b610af6565b61010a6101d4366004611c3c565b610cf8565b60007f000000000000000000000000ed67a6cbf4b9f3d0d818e158f5e7f4dfb31667836001600160a01b03166329db1be66040518163ffffffff1660e01b8152600401602060405180830381865afa158015610239573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061025d9190611cb0565b905090565b60007f000000000000000000000000ed67a6cbf4b9f3d0d818e158f5e7f4dfb31667836001600160a01b0316633013ce296040518163ffffffff1660e01b8152600401602060405180830381865afa158015610239573d6000803e3d6000fd5b3330146102e25760405163e252986960e01b815260040160405180910390fd5b82517f000000000000000000000000ed67a6cbf4b9f3d0d818e158f5e7f4dfb31667836001600160a01b0390811690821614610331576040516382c6b5f760e01b815260040160405180910390fd5b60a084015160208501516040516323b872dd60e01b81526001600160a01b0392831660048201523060248201526044810191909152908216906323b872dd906064016020604051808303816000875af1158015610392573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103b69190611ce9565b5060006103c1610262565b90506103d86001600160a01b038216836000610fcf565b60408501516103f3906001600160a01b038316908490610fcf565b60208501516040808701519051636b1bcdb960e11b8152600481019290925260248201523060448201526001600160a01b0383169063d6379b72906064016020604051808303816000875af1158015610450573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104749190611d04565b5061048a6001600160a01b038216836000610fcf565b60006104946101d9565b6040516370a0823160e01b81523060048201529091506000906001600160a01b038316906370a0823190602401602060405180830381865afa1580156104de573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105029190611d04565b90506000836001600160a01b03167f000000000000000000000000d49174dba635489c67fa628864c2d0d04824ebd86001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa15801561056e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105929190611cb0565b6001600160a01b0316146105a657856105a8565b865b88604001516105b79190611d33565b9050600060646105c8846063611d4b565b6105d29190611d6a565b90506105de828261111c565b506106136001600160a01b0386167f000000000000000000000000d49174dba635489c67fa628864c2d0d04824ebd884611488565b6040516370a0823160e01b81523060048201526000906001600160a01b038616906370a0823190602401602060405180830381865afa15801561065a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061067e9190611d04565b905089606001518110156106a55760405163113999b160e21b815260040160405180910390fd5b80156106c55760808a01516106c5906001600160a01b0387169083611488565b6040516370a0823160e01b81523060048201526000906001600160a01b038816906370a0823190602401602060405180830381865afa15801561070c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107309190611d04565b905080156107525760808b0151610752906001600160a01b0389169083611488565b8a608001516001600160a01b03168b600001516001600160a01b03167f04ba039dfde9e4c1a73889a9d1fa4fd72845f4c03533d3e5a7d35e65dc43009d8d6020015188866040516107b6939291909283526020830191909152604082015260600190565b60405180910390a35050505050505050505050565b6107f66040518060800160405280600081526020016000815260200160008152602001600081525090565b8160000361080357919050565b8181526040516319ce656f60e11b8152600481018390527f000000000000000000000000ed67a6cbf4b9f3d0d818e158f5e7f4dfb31667836001600160a01b03169063339ccade90602401602060405180830381865afa15801561086b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061088f9190611d04565b816020018181525050620f42407f000000000000000000000000d49174dba635489c67fa628864c2d0d04824ebd86001600160a01b031663ddca3f436040518163ffffffff1660e01b8152600401602060405180830381865afa1580156108fa573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061091e9190611d8c565b62ffffff1682602001516109329190611d4b565b61093c9190611d6a565b60608201819052602082015160009161095491611d33565b9050826000610962836114b8565b905080821115610980576109768183611db1565b6040850152610988565b600060408501525b505050919050565b336001600160a01b037f000000000000000000000000d49174dba635489c67fa628864c2d0d04824ebd816146109d95760405163e252986960e01b815260040160405180910390fd5b60006109e782840184611dc8565b604051638659c00960e01b81529091503090638659c00990610a1190849089908990600401611e29565b600060405180830381600087803b158015610a2b57600080fd5b505af1925050508015610a3c575060015b610aef57610a48611e49565b806308c379a003610ae35750610a5c611e65565b80610a675750610ae5565b81608001516001600160a01b031682600001516001600160a01b03167f7d14f00d1a9f979262535a6d3dbc9dcb543e3d7110df00763d921d11ef4452ba846020015184604051610ab8929190611f47565b60405180910390a38060405162461bcd60e51b8152600401610ada9190611f60565b60405180910390fd5b505b3d6000803e3d6000fd5b5050505050565b336001600160a01b037f00000000000000000000000097e4442bca2c069f9060f3b8eef52eb25c98c2451614610b3f5760405163e252986960e01b815260040160405180910390fd5b6000610b4d82840184611b87565b90506000806000871315610be7578691507f00000000000000000000000097e4442bca2c069f9060f3b8eef52eb25c98c2456001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015610bbc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610be09190611cb0565b9050610c59565b6000861315610c51578591507f00000000000000000000000097e4442bca2c069f9060f3b8eef52eb25c98c2456001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015610bbc573d6000803e3d6000fd5b505050610cf2565b82821115610c7a57604051633245138160e21b815260040160405180910390fd5b610c826101d9565b6001600160a01b0316816001600160a01b031614158015610cbc5750610ca6610262565b6001600160a01b0316816001600160a01b031614155b15610cda57604051631a6ae4bd60e01b815260040160405180910390fd5b610cee6001600160a01b0382163384611488565b5050505b50505050565b610d006117a0565b8051600003610d2257604051632a045c0f60e11b815260040160405180910390fd5b8060200151600003610d4757604051632a045c0f60e11b815260040160405180910390fd5b6000806000610d54610262565b9050806001600160a01b03167f000000000000000000000000d49174dba635489c67fa628864c2d0d04824ebd86001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa158015610dbe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610de29190611cb0565b6001600160a01b031603610dfc5783602001519250610ebb565b806001600160a01b03167f000000000000000000000000d49174dba635489c67fa628864c2d0d04824ebd86001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa158015610e64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e889190611cb0565b6001600160a01b031603610ea25783602001519150610ebb565b6040516382c6b5f760e01b815260040160405180910390fd5b6040805160c0810182526001600160a01b037f000000000000000000000000ed67a6cbf4b9f3d0d818e158f5e7f4dfb316678316815285516020808301919091528681015182840152868301516060830152336080830181905260a08301529151600092610f2a929101611f73565b60408051601f19818403018152908290526312439b2f60e21b825291506001600160a01b037f000000000000000000000000d49174dba635489c67fa628864c2d0d04824ebd8169063490e6cbc90610f8c903090889088908790600401611f81565b600060405180830381600087803b158015610fa657600080fd5b505af1158015610fba573d6000803e3d6000fd5b5050505050505050610fcc6001600055565b50565b8015806110495750604051636eb1769f60e11b81523060048201526001600160a01b03838116602483015284169063dd62ed3e90604401602060405180830381865afa158015611023573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906110479190611d04565b155b6110b45760405162461bcd60e51b815260206004820152603660248201527f5361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f60448201527520746f206e6f6e2d7a65726f20616c6c6f77616e636560501b6064820152608401610ada565b6040516001600160a01b03831660248201526044810182905261111790849063095ea7b360e01b906064015b60408051601f198184030181529190526020810180516001600160e01b03166001600160e01b0319909316929092179091526117f9565b505050565b60008260000361112e57506000611482565b8160000361114f57604051633245138160e21b815260040160405180910390fd5b60006111596101d9565b90506000611165610262565b90506000807f00000000000000000000000097e4442bca2c069f9060f3b8eef52eb25c98c2456001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156111c8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111ec9190611cb0565b905060007f00000000000000000000000097e4442bca2c069f9060f3b8eef52eb25c98c2456001600160a01b031663d21220a76040518163ffffffff1660e01b8152600401602060405180830381865afa15801561124e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112729190611cb0565b9050816001600160a01b0316856001600160a01b03161480156112a65750806001600160a01b0316846001600160a01b0316145b156112b4576001925061130d565b806001600160a01b0316856001600160a01b03161480156112e65750816001600160a01b0316846001600160a01b0316145b156112f4576000925061130d565b604051633245138160e21b815260040160405180910390fd5b50506000807f00000000000000000000000097e4442bca2c069f9060f3b8eef52eb25c98c2456001600160a01b031663128acb0830858b61134d90611fb8565b8761137657611371600173fffd8963efd1fc6a506488495d951d5263988d26611fd4565b611386565b6113866401000276a36001611ffc565b60408051602081018f9052016040516020818303038152906040526040518663ffffffff1660e01b81526004016113c1959493929190612027565b60408051808303816000875af11580156113df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114039190612062565b915091508215611436576000821361142e57604051633245138160e21b815260040160405180910390fd5b81955061145b565b6000811361145757604051633245138160e21b815260040160405180910390fd5b8095505b8686111561147c57604051633245138160e21b815260040160405180910390fd5b50505050505b92915050565b6040516001600160a01b03831660248201526044810182905261111790849063a9059cbb60e01b906064016110e0565b6000816000036114ca57506000919050565b60006114d46101d9565b905060007f00000000000000000000000097e4442bca2c069f9060f3b8eef52eb25c98c2456001600160a01b0316633850c7bd6040518163ffffffff1660e01b815260040160e060405180830381865afa158015611536573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061155a9190612098565b505050505050905060007f00000000000000000000000097e4442bca2c069f9060f3b8eef52eb25c98c2456001600160a01b0316630dfe16816040518163ffffffff1660e01b8152600401602060405180830381865afa1580156115c2573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906115e69190611cb0565b6001600160a01b0316836001600160a01b0316149050600081156116445760006116196001600160a01b03851680611d4b565b9050600160c01b808210611638576116318183611d6a565b925061163d565b600192505b5050611680565b60006116596001600160a01b03851680611d4b565b9050600160c01b8115611677576116708282611d6a565b925061167d565b60001992505b50505b8060000361173e5760007f00000000000000000000000097e4442bca2c069f9060f3b8eef52eb25c98c2456001600160a01b0316631a6865026040518163ffffffff1660e01b8152600401602060405180830381865afa1580156116e8573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061170c9190612132565b90506001600160801b0381161561172a5764e8d4a510009150611738565b506000199695505050505050565b50611759565b670de0b6b3a76400008111156117595750670de0b6b3a76400005b8015611770576117698187611d6a565b9450611776565b60001994505b61178a670de0b6b3a7640000600019611d6a565b8511156117975760001994505b50505050919050565b6002600054036117f25760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610ada565b6002600055565b600061184e826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166118ce9092919063ffffffff16565b905080516000148061186f57508080602001905181019061186f9190611ce9565b6111175760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e6044820152691bdd081cdd58d8d9595960b21b6064820152608401610ada565b60606118dd84846000856118e5565b949350505050565b6060824710156119465760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f6044820152651c8818d85b1b60d21b6064820152608401610ada565b600080866001600160a01b03168587604051611962919061215b565b60006040518083038185875af1925050503d806000811461199f576040519150601f19603f3d011682016040523d82523d6000602084013e6119a4565b606091505b50915091506119b5878383876119c0565b979650505050505050565b60608315611a2f578251600003611a28576001600160a01b0385163b611a285760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610ada565b50816118dd565b6118dd8383815115611a445781518083602001fd5b8060405162461bcd60e51b8152600401610ada9190611f60565b601f8201601f1916810167ffffffffffffffff81118282101715611a9257634e487b7160e01b600052604160045260246000fd5b6040525050565b6001600160a01b0381168114610fcc57600080fd5b600060c08284031215611ac057600080fd5b60405160c0810181811067ffffffffffffffff82111715611af157634e487b7160e01b600052604160045260246000fd5b6040529050808235611b0281611a99565b808252506020830135602082015260408301356040820152606083013560608201526080830135611b3281611a99565b608082015260a0830135611b4581611a99565b60a0919091015292915050565b60008060006101008486031215611b6857600080fd5b611b728585611aae565b9560c0850135955060e0909401359392505050565b600060208284031215611b9957600080fd5b5035919050565b60008083601f840112611bb257600080fd5b50813567ffffffffffffffff811115611bca57600080fd5b602083019150836020828501011115611be257600080fd5b9250929050565b60008060008060608587031215611bff57600080fd5b8435935060208501359250604085013567ffffffffffffffff811115611c2457600080fd5b611c3087828801611ba0565b95989497509550505050565b600060808284031215611c4e57600080fd5b6040516080810181811067ffffffffffffffff82111715611c7f57634e487b7160e01b600052604160045260246000fd5b8060405250823581526020830135602082015260408301356040820152606083013560608201528091505092915050565b600060208284031215611cc257600080fd5b8151611ccd81611a99565b9392505050565b80518015158114611ce457600080fd5b919050565b600060208284031215611cfb57600080fd5b611ccd82611cd4565b600060208284031215611d1657600080fd5b5051919050565b634e487b7160e01b600052601160045260246000fd5b60008219821115611d4657611d46611d1d565b500190565b6000816000190483118215151615611d6557611d65611d1d565b500290565b600082611d8757634e487b7160e01b600052601260045260246000fd5b500490565b600060208284031215611d9e57600080fd5b815162ffffff81168114611ccd57600080fd5b600082821015611dc357611dc3611d1d565b500390565b600060c08284031215611dda57600080fd5b611ccd8383611aae565b80516001600160a01b03908116835260208083015190840152604080830151908401526060808301519084015260808083015182169084015260a09182015116910152565b6101008101611e388286611de4565b60c082019390935260e00152919050565b600060033d1115611e625760046000803e5060005160e01c5b90565b600060443d1015611e735790565b6040516003193d81016004833e81513d67ffffffffffffffff8160248401118184111715611ea357505050505090565b8285019150815181811115611ebb5750505050505090565b843d8701016020828501011115611ed55750505050505090565b611ee460208286010187611a5e565b509095945050505050565b60005b83811015611f0a578181015183820152602001611ef2565b83811115610cf25750506000910152565b60008151808452611f33816020860160208601611eef565b601f01601f19169290920160200192915050565b8281526040602082015260006118dd6040830184611f1b565b602081526000611ccd6020830184611f1b565b60c081016114828284611de4565b60018060a01b0385168152836020820152826040820152608060608201526000611fae6080830184611f1b565b9695505050505050565b6000600160ff1b8201611fcd57611fcd611d1d565b5060000390565b60006001600160a01b0383811690831681811015611ff457611ff4611d1d565b039392505050565b60006001600160a01b0382811684821680830382111561201e5761201e611d1d565b01949350505050565b6001600160a01b0386811682528515156020830152604082018590528316606082015260a0608082018190526000906119b590830184611f1b565b6000806040838503121561207557600080fd5b505080516020909101519092909150565b805161ffff81168114611ce457600080fd5b600080600080600080600060e0888a0312156120b357600080fd5b87516120be81611a99565b8097505060208801518060020b81146120d657600080fd5b95506120e460408901612086565b94506120f260608901612086565b935061210060808901612086565b925060a088015160ff8116811461211657600080fd5b915061212460c08901611cd4565b905092959891949750929550565b60006020828403121561214457600080fd5b81516001600160801b0381168114611ccd57600080fd5b6000825161216d818460208701611eef565b919091019291505056fea2646970667358221220a51d1235c75504e517c172b6f0eb277cc4ef32a527a16c853b1aed12ae0b7bf064736f6c634300080d0033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
000000000000000000000000ed67a6cbf4b9f3d0d818e158f5e7f4dfb3166783000000000000000000000000d49174dba635489c67fa628864c2d0d04824ebd8
-----Decoded View---------------
Arg [0] : _optionToken (address): 0xeD67a6CbF4b9f3D0D818E158F5E7f4dFB3166783
Arg [1] : _flashPool (address): 0xd49174DbA635489C67fA628864C2D0d04824eBd8
-----Encoded View---------------
2 Constructor Arguments found :
Arg [0] : 000000000000000000000000ed67a6cbf4b9f3d0d818e158f5e7f4dfb3166783
Arg [1] : 000000000000000000000000d49174dba635489c67fa628864c2d0d04824ebd8
Loading...
Loading
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 35 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.