// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.24;
// UniSwap
import "@uniswap/v3-core/contracts/interfaces/IUniswapV3Pool.sol";
// OpenZeppelin
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable2Step.sol";
// lib
import "./lib/Constants.sol";
import "./lib/interfaces/IDragonX.sol";
import "./lib/interfaces/ITitanX.sol";
import "./lib/interfaces/INonfungiblePositionManager.sol";
/*
* @title The BabyDragonX Contract
* @author The DragonX and BabyDragon devs
*/
contract BabyDragonX is ERC20, Ownable2Step {
// -----------------------------------------
// Type declarations
// -----------------------------------------
/**
* @dev Indicates if a contract was initialized
*/
enum Initialized {
No,
Yes
}
/**
* @dev Indicates if minting was closed
*/
enum MintingFinalized {
No,
Yes
}
/**
* @dev Represents the information about a Uniswap V3 liquidity pool position token.
* This struct is used to store details of the position token, specifically for a single full range position.
*/
struct LpTokenInfo {
uint80 tokenId; // The ID of the position token in the Uniswap V3 pool.
uint128 liquidity; // The amount of liquidity provided in the position.
int24 tickLower; // The lower end of the price range for the position.
int24 tickUpper; // The upper end of the price range for the position.
}
// -----------------------------------------
// State variables
// -----------------------------------------
/**
* @dev Begin of the mint phase
*/
uint256 public mintPhaseBegin;
/**
* @dev The end of the mint phase
*/
uint256 public mintPhaseEnd;
/**
* @dev The address of the main LP for DragonX / BabyDragon
*/
address public poolAddress;
/**
* @notice true if the address is a LP Pool
*/
mapping(address => bool) public pools;
/**
* @dev Indicates if BabyDragon contract was initialized
*/
Initialized public initialized;
/**
* @dev Indicates if the mint phase was finalized
*/
MintingFinalized public mintingFinalized;
/**
* @dev Total DragonX send to BabyDragonX buy and burn
*/
uint256 public totalDragonSentToBabyDragonBuyAndBurn;
/**
* @dev Total BabyDragon burned through LP fees
*/
uint256 public totalBabyDragonBurned;
/**
* @dev Interacting with LP pools is disabled while minting
*/
bool public tradingEnabled;
/**
* @dev Stores the position token information, specifically for a single full range position in the Uniswap V3 pool.
*/
LpTokenInfo public lpTokenInfo;
/**
* @dev The BabyDragonX buy and burn address (smart contract executing buy and burns)
*/
address public babyDragonBuyAndBurnAddress;
// -----------------------------------------
// Events
// -----------------------------------------
/**
* @notice Emitted when fees are collected in both DragonX and BabyDragon tokens.
* @dev This event is triggered when a fee collection transaction is completed.
* @param dragon The amount of DragonX collected as fees.
* @param babyDragon The amount of BabyDragon tokens collected as fees.
* @param caller The address of the user or contract that initiated the fee collection.
*/
event CollectedFees(
uint256 indexed dragon,
uint256 indexed babyDragon,
address indexed caller
);
// -----------------------------------------
// Errors
// -----------------------------------------
// -----------------------------------------
// Modifiers
// -----------------------------------------
// -----------------------------------------
// Constructor
// -----------------------------------------
constructor(
address babyDragonBuyAndBurnAddress_
) ERC20("Baby DragonX", "BDX") Ownable(msg.sender) {
require(babyDragonBuyAndBurnAddress_ != address(0), "invalid address");
// set other states
initialized = Initialized.No;
mintingFinalized = MintingFinalized.No;
tradingEnabled = false;
babyDragonBuyAndBurnAddress = babyDragonBuyAndBurnAddress_;
}
// -----------------------------------------
// Receive function
// -----------------------------------------
// -----------------------------------------
// Fallback function
// -----------------------------------------
// -----------------------------------------
// External functions
// -----------------------------------------
/**
* Mint BabyDragonX Tokens
* @dev Mints BabyDragonX tokens in exchange for TitanX tokens based on a dynamic minting ratio.
* This function allows users to contribute TitanX tokens during the mint phase of
* DragonX and receive BabyDragonX tokens in return.
* The mint ratio adjusts according to the timestamp. It also allocates a
* portion of TitanX tokens for team allocation,
* expenses, and DragonX genesis share before minting.
*
* Requirements:
* - The contract must be initialized.
* - The minting phase must have started and not yet ended.
*
* Emits a {Transfer} event from the zero address to the `msg.sender` indicating the minting of BabyDragonX tokens.
*
* @param titanAmount The amount of TitanX tokens the user wishes to contribute for minting BabyDragonX tokens.
* The function calculates the allocation for different purposes, mints DragonX tokens with a portion of TitanX,
* and finally mints BabyDragonX tokens based on the calculated ratio.
*/
function mint(uint256 titanAmount) external {
IDragonX dragonX = IDragonX(DRAGONX_ADDRESS);
ITitanX titanX = ITitanX(TITANX_ADDRESS);
require(initialized == Initialized.Yes, "not initialized");
require(titanAmount > 0, "invalid amount");
// Align the mint-ratio with DragonX
// This function will revert if minting has ended or not started yet
uint256 ratio = getMintRatio();
// 7% Baby Dragon Team Allocation
uint256 teamAllocation = (titanAmount * 700) / BASIS;
titanX.transferFrom(
msg.sender,
BABY_DRAGON_TEAM_ADDRESS,
teamAllocation
);
// 5% Baby Dragon Expenses
uint256 expenses = (titanAmount * 500) / BASIS;
titanX.transferFrom(msg.sender, BABY_DRAGON_EXPENSES_ADDRESS, expenses);
// Send 1% of TitanX to DragonX genesis
uint256 dragonGenesisShare = (titanAmount * 100) / BASIS;
titanX.transferFrom(
msg.sender,
DRAGONX_GENESIS_ADDRESS,
dragonGenesisShare
);
// Mint DragonX with 87% of TitanX (accumulate in this contract)
uint256 titanToMintDragon = titanAmount -
teamAllocation -
expenses -
dragonGenesisShare;
titanX.transferFrom(msg.sender, address(this), titanToMintDragon);
titanX.approve(DRAGONX_ADDRESS, titanToMintDragon);
dragonX.mint(titanToMintDragon);
// Mint BabyDragon
uint256 babyDragonToMint = (titanAmount * ratio) / BASIS;
_mint(msg.sender, babyDragonToMint);
}
/**
* Collects fees accrued from liquidity provision in DragonX and BabyDragon tokens.
* @dev This function handles the collection and burning of fees generated by liquidity pools.
* It determines the amounts of DragonX and BabyDragon tokens collected as fees,
* burns the collected BabyDragon tokens, and sends the collected DragonX tokens to the
* BabyDragon buy and burn address.
*
* Emits a {CollectedFees} event indicating the amounts of tokens collected and burned, and the caller's address.
*/
function collectFees() external {
require(initialized == Initialized.Yes, "not initialized");
// Cache state variables
address dragonAddress = DRAGONX_ADDRESS;
address babyDragonAddress = address(this);
(uint256 amount0, uint256 amount1) = _collectFees();
uint256 dragon;
uint256 babyDragon;
if (dragonAddress < babyDragonAddress) {
dragon = amount0;
babyDragon = amount1;
} else {
babyDragon = amount0;
dragon = amount1;
}
// Burn BabyDragon
totalBabyDragonBurned += babyDragon;
_burn(address(this), babyDragon);
// Burn DragonX
IDragonX dragonX = IDragonX(dragonAddress);
totalDragonSentToBabyDragonBuyAndBurn += dragon;
dragonX.transfer(babyDragonBuyAndBurnAddress, dragon);
emit CollectedFees(dragon, babyDragon, msg.sender);
}
/**
* @notice Allows users to burn their BabyDragonX tokens, reducing the total supply.
* @dev Burns a specific amount of BabyDragonX tokens from the caller's balance.
* Updates the `totalBabyDragonBurned` state to reflect the burned tokens.
*
* @param amount The amount of BabyDragonX tokens to burn from the caller's balance.
*
* Requirements:
* - The caller must have at least `amount` tokens in their balance.
*/
function burn(uint256 amount) external {
require(amount > 0, "invalid amount");
totalBabyDragonBurned += amount;
_burn(msg.sender, amount);
}
/**
* Finalizes the minting phase, allocates tokens for liquidity, grants, and rewards, and enables trading.
* @dev This function can only be called once by the contract owner after
* the minting phase has ended.
* It performs token allocations to various addresses and pools, mints additional
* BabyDragonX tokens for grants and rewards, adds liquidity to the UniSwap pool,
* and enables trading by updating the contract state.
*
* Requirements:
* - The minting phase has ended.
* - The function must not have been previously called.
* - Can only be called by the contract owner.
*/
function finalizeMint() external onlyOwner {
require(block.timestamp > mintPhaseEnd, "minting still open");
require(
mintingFinalized == MintingFinalized.No,
"minting already finalized"
);
IDragonX dragonX = IDragonX(DRAGONX_ADDRESS);
uint256 dragonBalance = dragonX.balanceOf(address(this));
// Allocate 50% to liquidity pool
uint256 liquidityTopUp = (dragonBalance * 5000) / BASIS;
// Allocate 3% to BabyDragonX Genesis
uint256 genesisShare = (dragonBalance * 300) / BASIS;
dragonX.transfer(BABY_DRAGON_TEAM_ADDRESS, genesisShare);
// Allocate 47% to BabyDragonX buy and burn
uint256 dragonForBabyDragonBurnShare = dragonBalance -
liquidityTopUp -
genesisShare;
dragonX.transfer(
babyDragonBuyAndBurnAddress,
dragonForBabyDragonBurnShare
);
totalDragonSentToBabyDragonBuyAndBurn += dragonForBabyDragonBurnShare;
// Mint additional 4% for grants
uint256 totalBabyDragonMinted = totalSupply();
_mint(BABY_DRAGON_GRANT_ADDRESS, (totalBabyDragonMinted * 400) / BASIS);
// Mint additional 10% for future rewards
_mint(
BABY_DRAGON_FUTURE_REWARDS_ADDRESS,
(totalBabyDragonMinted * 1000) / BASIS
);
// Prepare LP
uint256 amount0Desired = liquidityTopUp;
uint256 amount1Desired = liquidityTopUp;
// mint BabyDragon for LP
_mint(address(this), liquidityTopUp);
// Approve the Uniswap non-fungible position manager to spend DragonX.
dragonX.approve(UNI_NONFUNGIBLEPOSITIONMANAGER, liquidityTopUp);
// Approve the UniSwap non-fungible position manager to spend BabyDragon.
_approve(address(this), UNI_NONFUNGIBLEPOSITIONMANAGER, liquidityTopUp);
// Top Up Liquidity
(uint128 liquidity, , ) = _addLiquidity(amount0Desired, amount1Desired);
lpTokenInfo.liquidity = liquidity;
// Burn remaining DragonX
if (dragonX.balanceOf(address(this)) > 0) {
dragonX.burn();
}
// Burn remaining BabyDragon
uint256 remainingBabyDragon = balanceOf(address(this));
if (remainingBabyDragon > 0) {
totalBabyDragonBurned += remainingBabyDragon;
_burn(address(this), remainingBabyDragon);
}
// enable trading
tradingEnabled = true;
// Update state
mintingFinalized = MintingFinalized.Yes;
}
/**
* @notice Initializes the contract by setting up initial liquidity in the Uniswap pool and enabling minting.
* @dev This function sets the initial liquidity parameters for the BabyDragonX and
* DragonX tokens in the Uniswap pool. It mints initial liquidity tokens to this contract,
* approves the Uniswap non-fungible position manager to spend the tokens,
* and creates the initial liquidity pool if it doesn't exist already.
* It also sets the minting phase's beginning and end times. This function can only be
* called once by the contract owner.
*
* @param initialLiquidityAmount The amount of DragonX tokens to be added as initial liquidity to the Uniswap pool.
* The function automatically calculates and mints the amount of BabyDragonX tokens for the initial liquidity,
* assuming an initial price ratio of 1 DragonX to 1 BabyDragonX.
*
* Requirements:
* - The contract must not have been initialized before.
* - Only the contract owner can call this function.
*/
function initialize(uint256 initialLiquidityAmount) external onlyOwner {
require(initialized == Initialized.No, "already initialized");
IDragonX dragonX = IDragonX(DRAGONX_ADDRESS);
// Mint initial liquidity
_mint(address(this), initialLiquidityAmount);
// Setup initial liquidity pool
// Transfer the specified amount of DragonX tokens from the caller to this contract.
dragonX.transferFrom(msg.sender, address(this), initialLiquidityAmount);
// Approve the Uniswap non-fungible position manager to spend DragonX.
dragonX.approve(UNI_NONFUNGIBLEPOSITIONMANAGER, initialLiquidityAmount);
// Approve the UniSwap non-fungible position manager to spend BabyDragon.
_approve(
address(this),
UNI_NONFUNGIBLEPOSITIONMANAGER,
initialLiquidityAmount
);
// Create the initial liquidity pool in Uniswap V3.
_createPool(initialLiquidityAmount);
// Mint the initial position in the pool.
_mintInitialPosition(initialLiquidityAmount);
// Align mint phase begin to midnight UTC
uint256 currentTimestamp = block.timestamp;
uint256 secondsUntilMidnight = 86400 - (currentTimestamp % 86400);
// The mint phase begins at midnight
mintPhaseBegin = currentTimestamp + secondsUntilMidnight;
// Minting will be open for 14 days
mintPhaseEnd = mintPhaseBegin + 14 days;
// Update states
initialized = Initialized.Yes;
}
/**
* @notice Registers or deregisters an address as a liquidity pool.
* @dev Allows the contract owner to mark an address as a recognized liquidity pool
* or remove it from the list of recognized pools. This function is critical for managing
* which pools are considered for trading and can help in disabling trading in the minting phase.
*
* @param poolAddress_ The address of the liquidity pool to be registered or deregistered.
* @param isPool A boolean indicating whether the address should be considered a
* liquidity pool (true) or not (false).
*
* Requirements:
* - Only the contract owner can call this function.
* - This function has no effect once minting is finalized and trading is enabled.
*/
function setPool(address poolAddress_, bool isPool) external onlyOwner {
require(poolAddress_ != address(0), "invalid address");
pools[poolAddress_] = isPool;
}
/**
* @notice Sets the BabyDragon buy and burn address to a new address.
* @dev Allows the contract owner to update the address where DragonX tokens are
* sent for buying and burning BabyDragonX tokens.
* This can be used to change the destination address for the DragonX tokens
* collected as fees and used for burning.
*
* @param babyDragonBuyAndBurnAddress_ The new address for buying and burning BabyDragonX tokens.
*
* Requirements:
* - Only the contract owner can call this function.
* - The new address must not be the zero address.
*/
function setBabyDragonBuyAndBurnAddress(
address babyDragonBuyAndBurnAddress_
) external onlyOwner {
require(babyDragonBuyAndBurnAddress_ != address(0), "invalid address");
babyDragonBuyAndBurnAddress = babyDragonBuyAndBurnAddress_;
}
// -----------------------------------------
// Public functions
// -----------------------------------------
/**
* @notice Calculates the current mint ratio for BabyDragonX tokens based on the current
* phase of the minting period.
* @dev Returns a mint ratio that determines how many BabyDragonX tokens can be minted per unit of TitanX.
* The mint ratio changes depending on which week of the minting phase the function is called.
*
* The mint ratio starts at 1 for the first week and adjusts to 0.95 for the second week.
* This function ensures that the ratio is only accessible during the minting phase to enforce the minting schedule.
*
* Requirements:
* - The current timestamp must be within the minting phase period, between `mintPhaseBegin` and `mintPhaseEnd`.
*
* @return ratio The current mint ratio
*/
function getMintRatio() public view returns (uint256 ratio) {
require(initialized == Initialized.Yes, "not yet initialized");
require(block.timestamp >= mintPhaseBegin, "minting not started");
require(block.timestamp <= mintPhaseEnd, "minting has ended");
if (block.timestamp < mintPhaseBegin + 7 days) {
// week 1
ratio = 10_000;
} else {
// week 2
ratio = 9_500;
}
}
// -----------------------------------------
// Internal functions
// -----------------------------------------
/**
* @dev Overrides the ERC20 `_update` function to enforce trading restrictions.
* This internal function is called during every transfer operation to check if trading is enabled
* and whether the sender or recipient is a recognized liquidity pool address.
* It ensures that trading through LP pools is only possible when explicitly enabled.
*
* @param from The address sending the tokens.
* @param to The address receiving the tokens.
* @param value The amount of tokens being transferred.
*
* Requirements:
* - Trading must be enabled if either `from` or `to` is a recognized liquidity pool address.
* - Always allow the contract itself to interact with the LP pool.
*/
function _update(
address from,
address to,
uint256 value
) internal override {
// Allow the contract itself to always interact without checking if trading is enabled
if (from != address(this) && to != address(this)) {
require(
(!pools[from] && !pools[to]) || tradingEnabled,
"trading was not enabled yet"
);
}
super._update(from, to, value);
}
// -----------------------------------------
// Private functions
// -----------------------------------------
/**
* @notice Sorts tokens in ascending order, as required by Uniswap for identifying a pair.
* @dev This function arranges the token addresses in ascending order and assigns
* liquidity in a ratio of 1:1
* @param initialLiquidityAmount The amount of liquidity to assign to each token.
* @return token0 The token address that is numerically smaller.
* @return token1 The token address that is numerically larger.
* @return amount0 The liquidity amount for `token0`.
* @return amount1 The liquidity amount for `token1`.
*/
function _getTokenConfig(
uint256 initialLiquidityAmount
)
private
view
returns (
address token0,
address token1,
uint256 amount0,
uint256 amount1
)
{
// Cache state variables
address dragonAddress = DRAGONX_ADDRESS;
address babyDragonAddress = address(this);
amount0 = initialLiquidityAmount;
amount1 = initialLiquidityAmount;
if (dragonAddress < babyDragonAddress) {
token0 = dragonAddress;
token1 = babyDragonAddress;
} else {
token0 = babyDragonAddress;
token1 = dragonAddress;
}
}
/**
* @notice Creates a liquidity pool with a preset square root price ratio.
* @dev This function initializes a Uniswap V3 pool with the specified initial liquidity amount.
* @param initialLiquidityAmount The amount of liquidity to use for initializing the pool.
*/
function _createPool(uint256 initialLiquidityAmount) private {
(address token0, address token1, , ) = _getTokenConfig(
initialLiquidityAmount
);
INonfungiblePositionManager manager = INonfungiblePositionManager(
UNI_NONFUNGIBLEPOSITIONMANAGER
);
poolAddress = manager.createAndInitializePoolIfNecessary(
token0,
token1,
FEE_TIER,
INITIAL_SQRT_PRICE_DRAGONX_BABYDRAGONX
);
// Increase cardinality for observations enabling TWAP
IUniswapV3Pool(poolAddress).increaseObservationCardinalityNext(100);
// Update state
pools[poolAddress] = true;
}
/**
* @notice Mints a full range liquidity provider (LP) token in the Uniswap V3 pool.
* @dev This function mints an LP token with the full price range in the Uniswap V3 pool.
* @param initialLiquidityAmount The amount of liquidity to be used for minting the position.
*/
function _mintInitialPosition(uint256 initialLiquidityAmount) private {
INonfungiblePositionManager manager = INonfungiblePositionManager(
UNI_NONFUNGIBLEPOSITIONMANAGER
);
(
address token0,
address token1,
uint256 amount0Desired,
uint256 amount1Desired
) = _getTokenConfig(initialLiquidityAmount);
INonfungiblePositionManager.MintParams
memory params = INonfungiblePositionManager.MintParams({
token0: token0,
token1: token1,
fee: FEE_TIER,
tickLower: MIN_TICK,
tickUpper: MAX_TICK,
amount0Desired: amount0Desired,
amount1Desired: amount1Desired,
amount0Min: (amount0Desired * 90) / 100,
amount1Min: (amount1Desired * 90) / 100,
recipient: address(this),
deadline: block.timestamp
});
(uint256 tokenId, uint256 liquidity, , ) = manager.mint(params);
lpTokenInfo.tokenId = uint80(tokenId);
lpTokenInfo.liquidity = uint128(liquidity);
lpTokenInfo.tickLower = MIN_TICK;
lpTokenInfo.tickUpper = MAX_TICK;
}
/**
* @notice Collects liquidity pool fees from the Uniswap V3 pool.
* @dev This function calls the Uniswap V3 `collect` function to retrieve LP fees.
* @return amount0 The amount of `token0` collected as fees.
* @return amount1 The amount of `token1` collected as fees.
*/
function _collectFees() private returns (uint256 amount0, uint256 amount1) {
INonfungiblePositionManager manager = INonfungiblePositionManager(
UNI_NONFUNGIBLEPOSITIONMANAGER
);
INonfungiblePositionManager.CollectParams
memory params = INonfungiblePositionManager.CollectParams(
lpTokenInfo.tokenId,
address(this),
type(uint128).max,
type(uint128).max
);
(amount0, amount1) = manager.collect(params);
}
/**
* @dev Adds liquidity to the Uniswap V3 pool for the BabyDragonX and DragonX tokens.
* Attempts to add the desired amounts of token0 and token1 to the liquidity pool, with a
* 10% minimum slippage tolerance.
*
* @param amount0Desired The desired amount of token0 to be added to the pool.
* @param amount1Desired The desired amount of token1 to be added to the pool.
* @return liquidity The amount of liquidity tokens received for the added liquidity.
* @return amount0 The actual amount of token0 added to the pool.
* @return amount1 The actual amount of token1 added to the pool.
*/
function _addLiquidity(
uint256 amount0Desired,
uint256 amount1Desired
) private returns (uint128 liquidity, uint256 amount0, uint256 amount1) {
INonfungiblePositionManager manager = INonfungiblePositionManager(
UNI_NONFUNGIBLEPOSITIONMANAGER
);
INonfungiblePositionManager.IncreaseLiquidityParams
memory params = INonfungiblePositionManager
.IncreaseLiquidityParams({
tokenId: lpTokenInfo.tokenId,
amount0Desired: amount0Desired,
amount1Desired: amount1Desired,
amount0Min: 0,
amount1Min: 0,
deadline: block.timestamp
});
(liquidity, amount0, amount1) = manager.increaseLiquidity(params);
}
}
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.24;
/* Other */
uint256 constant BASIS = 10_000;
/* Addresses */
address constant DRAGONX_ADDRESS = 0x96a5399D07896f757Bd4c6eF56461F58DB951862;
address constant TITANX_ADDRESS = 0xF19308F923582A6f7c465e5CE7a9Dc1BEC6665B1;
address constant WETH9_ADDRESS = 0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2;
address constant UNI_SWAP_ROUTER = 0xE592427A0AEce92De3Edee1F18E0157C05861564;
address constant UNI_NONFUNGIBLEPOSITIONMANAGER = 0xC36442b4a4522E871399CD717aBDD847Ab11FE88;
address constant UNI_FACTORY = 0x1F98431c8aD98523631AE4a59f267346ea31F984;
/* Genesis and dedicated Addresses */
address constant DRAGONX_GENESIS_ADDRESS = 0x25C9E69177655FdA916d849B1d7C11BE32d2458b;
address constant BABY_DRAGON_TEAM_ADDRESS = 0x3B30cC62f24183084779dfe4411506FB8b9a0F9D;
address constant BABY_DRAGON_EXPENSES_ADDRESS = 0x62d7940FEEE2E7E9d1BEF21203b1e1441EB0B749;
address constant BABY_DRAGON_GRANT_ADDRESS = 0x7877201c70892F6B5A896ddD9b909306EdD36220;
address constant BABY_DRAGON_FUTURE_REWARDS_ADDRESS = 0xfc51fa192fa63d357d4Fc496A11Ca9d8383ec2c5;
/* Uniswap Liquidity Pools (DragonX, BabyDragon) */
uint24 constant FEE_TIER = 10000;
int24 constant MIN_TICK = -887200;
int24 constant MAX_TICK = 887200;
uint160 constant INITIAL_SQRT_PRICE_DRAGONX_BABYDRAGONX = 79228162514264337593543950336; // 1:1
/* BabyDragonX Constants */
uint256 constant INCENTIVE_FEE = 300;
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/ERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "./IERC20.sol";
import {IERC20Metadata} from "./extensions/IERC20Metadata.sol";
import {Context} from "../../utils/Context.sol";
import {IERC20Errors} from "../../interfaces/draft-IERC6093.sol";
/**
* @dev Implementation of the {IERC20} interface.
*
* This implementation is agnostic to the way tokens are created. This means
* that a supply mechanism has to be added in a derived contract using {_mint}.
*
* TIP: For a detailed writeup see our guide
* https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
* to implement supply mechanisms].
*
* The default value of {decimals} is 18. To change this, you should override
* this function so it returns a different value.
*
* We have followed general OpenZeppelin Contracts guidelines: functions revert
* instead returning `false` on failure. This behavior is nonetheless
* conventional and does not conflict with the expectations of ERC20
* applications.
*
* Additionally, an {Approval} event is emitted on calls to {transferFrom}.
* This allows applications to reconstruct the allowance for all accounts just
* by listening to said events. Other implementations of the EIP may not emit
* these events, as it isn't required by the specification.
*/
abstract contract ERC20 is Context, IERC20, IERC20Metadata, IERC20Errors {
mapping(address account => uint256) private _balances;
mapping(address account => mapping(address spender => uint256)) private _allowances;
uint256 private _totalSupply;
string private _name;
string private _symbol;
/**
* @dev Sets the values for {name} and {symbol}.
*
* All two of these values are immutable: they can only be set once during
* construction.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/
function name() public view virtual returns (string memory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/
function symbol() public view virtual returns (string memory) {
return _symbol;
}
/**
* @dev Returns the number of decimals used to get its user representation.
* For example, if `decimals` equals `2`, a balance of `505` tokens should
* be displayed to a user as `5.05` (`505 / 10 ** 2`).
*
* Tokens usually opt for a value of 18, imitating the relationship between
* Ether and Wei. This is the default value returned by this function, unless
* it's overridden.
*
* NOTE: This information is only used for _display_ purposes: it in
* no way affects any of the arithmetic of the contract, including
* {IERC20-balanceOf} and {IERC20-transfer}.
*/
function decimals() public view virtual returns (uint8) {
return 18;
}
/**
* @dev See {IERC20-totalSupply}.
*/
function totalSupply() public view virtual returns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/
function balanceOf(address account) public view virtual returns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `value`.
*/
function transfer(address to, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_transfer(owner, to, value);
return true;
}
/**
* @dev See {IERC20-allowance}.
*/
function allowance(address owner, address spender) public view virtual returns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `value` is the maximum `uint256`, the allowance is not updated on
* `transferFrom`. This is semantically equivalent to an infinite approval.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/
function approve(address spender, uint256 value) public virtual returns (bool) {
address owner = _msgSender();
_approve(owner, spender, value);
return true;
}
/**
* @dev See {IERC20-transferFrom}.
*
* Emits an {Approval} event indicating the updated allowance. This is not
* required by the EIP. See the note at the beginning of {ERC20}.
*
* NOTE: Does not update the allowance if the current allowance
* is the maximum `uint256`.
*
* Requirements:
*
* - `from` and `to` cannot be the zero address.
* - `from` must have a balance of at least `value`.
* - the caller must have allowance for ``from``'s tokens of at least
* `value`.
*/
function transferFrom(address from, address to, uint256 value) public virtual returns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, value);
_transfer(from, to, value);
return true;
}
/**
* @dev Moves a `value` amount of tokens from `from` to `to`.
*
* This internal function is equivalent to {transfer}, and can be used to
* e.g. implement automatic token fees, slashing mechanisms, etc.
*
* Emits a {Transfer} event.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _transfer(address from, address to, uint256 value) internal {
if (from == address(0)) {
revert ERC20InvalidSender(address(0));
}
if (to == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(from, to, value);
}
/**
* @dev Transfers a `value` amount of tokens from `from` to `to`, or alternatively mints (or burns) if `from`
* (or `to`) is the zero address. All customizations to transfers, mints, and burns should be done by overriding
* this function.
*
* Emits a {Transfer} event.
*/
function _update(address from, address to, uint256 value) internal virtual {
if (from == address(0)) {
// Overflow check required: The rest of the code assumes that totalSupply never overflows
_totalSupply += value;
} else {
uint256 fromBalance = _balances[from];
if (fromBalance < value) {
revert ERC20InsufficientBalance(from, fromBalance, value);
}
unchecked {
// Overflow not possible: value <= fromBalance <= totalSupply.
_balances[from] = fromBalance - value;
}
}
if (to == address(0)) {
unchecked {
// Overflow not possible: value <= totalSupply or value <= fromBalance <= totalSupply.
_totalSupply -= value;
}
} else {
unchecked {
// Overflow not possible: balance + value is at most totalSupply, which we know fits into a uint256.
_balances[to] += value;
}
}
emit Transfer(from, to, value);
}
/**
* @dev Creates a `value` amount of tokens and assigns them to `account`, by transferring it from address(0).
* Relies on the `_update` mechanism
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead.
*/
function _mint(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidReceiver(address(0));
}
_update(address(0), account, value);
}
/**
* @dev Destroys a `value` amount of tokens from `account`, lowering the total supply.
* Relies on the `_update` mechanism.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* NOTE: This function is not virtual, {_update} should be overridden instead
*/
function _burn(address account, uint256 value) internal {
if (account == address(0)) {
revert ERC20InvalidSender(address(0));
}
_update(account, address(0), value);
}
/**
* @dev Sets `value` as the allowance of `spender` over the `owner` s tokens.
*
* This internal function is equivalent to `approve`, and can be used to
* e.g. set automatic allowances for certain subsystems, etc.
*
* Emits an {Approval} event.
*
* Requirements:
*
* - `owner` cannot be the zero address.
* - `spender` cannot be the zero address.
*
* Overrides to this logic should be done to the variant with an additional `bool emitEvent` argument.
*/
function _approve(address owner, address spender, uint256 value) internal {
_approve(owner, spender, value, true);
}
/**
* @dev Variant of {_approve} with an optional flag to enable or disable the {Approval} event.
*
* By default (when calling {_approve}) the flag is set to true. On the other hand, approval changes made by
* `_spendAllowance` during the `transferFrom` operation set the flag to false. This saves gas by not emitting any
* `Approval` event during `transferFrom` operations.
*
* Anyone who wishes to continue emitting `Approval` events on the`transferFrom` operation can force the flag to
* true using the following override:
* ```
* function _approve(address owner, address spender, uint256 value, bool) internal virtual override {
* super._approve(owner, spender, value, true);
* }
* ```
*
* Requirements are the same as {_approve}.
*/
function _approve(address owner, address spender, uint256 value, bool emitEvent) internal virtual {
if (owner == address(0)) {
revert ERC20InvalidApprover(address(0));
}
if (spender == address(0)) {
revert ERC20InvalidSpender(address(0));
}
_allowances[owner][spender] = value;
if (emitEvent) {
emit Approval(owner, spender, value);
}
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `value`.
*
* Does not update the allowance value in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Does not emit an {Approval} event.
*/
function _spendAllowance(address owner, address spender, uint256 value) internal virtual {
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance != type(uint256).max) {
if (currentAllowance < value) {
revert ERC20InsufficientAllowance(spender, currentAllowance, value);
}
unchecked {
_approve(owner, spender, currentAllowance - value, false);
}
}
}
}
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.24;
// OpenZeppelin
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
interface IDragonX is IERC20 {
// External functions
function mint(uint256 amount) external;
function stake() external;
function claim() external returns (uint256 claimedAmount);
function totalStakesOpened() external view returns (uint256 totalStakes);
function incentiveFeeForClaim() external view returns (uint256 fee);
function stakeReachedMaturity()
external
view
returns (bool hasStakesToEnd, address instanceAddress, uint256 sId);
function burn() external;
function vault() external view returns (uint256 vault);
function mintPhaseBegin() external view returns (uint256);
function mintPhaseEnd() external view returns (uint256);
function mintRatioWeekOne() external view returns (uint256);
function mintRatioWeekTwo() external view returns (uint256);
function mintRatioWeekThree() external view returns (uint256);
function mintRatioWeekFour() external view returns (uint256);
function mintRatioWeekFive() external view returns (uint256);
function mintRatioWeekSix() external view returns (uint256);
function mintRatioWeekSeven() external view returns (uint256);
function mintRatioWeekEight() external view returns (uint256);
function mintRatioWeekNine() external view returns (uint256);
function mintRatioWeekTen() external view returns (uint256);
function mintRatioWeekEleven() external view returns (uint256);
function mintRatioWeekTwelve() external view returns (uint256);
// Public functions
function updateVault() external;
function totalEthClaimable() external view returns (uint256 claimable);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @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 value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` 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 value) external returns (bool);
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (token/ERC20/extensions/IERC20Metadata.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*/
interface IERC20Metadata is IERC20 {
/**
* @dev Returns the name of the token.
*/
function name() external view returns (string memory);
/**
* @dev Returns the symbol of the token.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the decimals places of the token.
*/
function decimals() external view returns (uint8);
}
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.24;
/**
* @notice A subset of the Uniswap Interface to allow
* using latest openzeppelin contracts
*/
interface INonfungiblePositionManager {
// Structs for mint and collect functions
struct MintParams {
address token0;
address token1;
uint24 fee;
int24 tickLower;
int24 tickUpper;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 amount0Min;
uint256 amount1Min;
address recipient;
uint256 deadline;
}
struct CollectParams {
uint256 tokenId;
address recipient;
uint128 amount0Max;
uint128 amount1Max;
}
struct IncreaseLiquidityParams {
uint256 tokenId;
uint256 amount0Desired;
uint256 amount1Desired;
uint256 amount0Min;
uint256 amount1Min;
uint256 deadline;
}
// Functions
function createAndInitializePoolIfNecessary(
address token0,
address token1,
uint24 fee,
uint160 sqrtPriceX96
) external payable returns (address pool);
function mint(
MintParams calldata params
)
external
payable
returns (
uint256 tokenId,
uint128 liquidity,
uint256 amount0,
uint256 amount1
);
function collect(
CollectParams calldata params
) external payable returns (uint256 amount0, uint256 amount1);
function increaseLiquidity(
IncreaseLiquidityParams calldata params
) external returns (uint128 liquidity, uint256 amount0, uint256 amount1);
}
// SPDX-License-Identifier: UNLICENSED
pragma solidity 0.8.24;
// OpenZeppelin
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
// Enum for stake status
enum StakeStatus {
ACTIVE,
ENDED,
BURNED
}
// Struct for user stake information
struct UserStakeInfo {
uint152 titanAmount;
uint128 shares;
uint16 numOfDays;
uint48 stakeStartTs;
uint48 maturityTs;
StakeStatus status;
}
// Struct for user stake
struct UserStake {
uint256 sId;
uint256 globalStakeId;
UserStakeInfo stakeInfo;
}
// Interface for the contract
interface IStakeInfo {
/**
* @notice Get all stake info of a given user address.
* @param user The address of the user to query stake information for.
* @return An array of UserStake structs containing all stake info for the given address.
*/
function getUserStakes(
address user
) external view returns (UserStake[] memory);
/** @notice get stake info with stake id
* @return stakeInfo stake info
*/
function getUserStakeInfo(
address user,
uint256 id
) external view returns (UserStakeInfo memory);
}
/**
* @title The TitanX interface used by DragonX to manages stakes
* @author The DragonX devs
*/
interface ITitanX is IERC20, IStakeInfo {
/**
* @notice Start a new stake
* @param amount The amount of TitanX tokens to stake
* @param numOfDays The length of the stake in days
*/
function startStake(uint256 amount, uint256 numOfDays) external;
/**
* @notice Claims available ETH payouts for a user based on their shares in various cycles.
* @dev This function calculates the total reward from different cycles and transfers it to the caller.
*/
function claimUserAvailableETHPayouts() external;
/**
* @notice Calculates the total ETH claimable by a user for all cycles.
* @dev This function sums up the rewards from various cycles based on user shares.
* @param user The address of the user for whom to calculate the claimable ETH.
* @return reward The total ETH reward claimable by the user.
*/
function getUserETHClaimableTotal(
address user
) external view returns (uint256 reward);
/**
* @notice Allows anyone to sync dailyUpdate manually.
* @dev Function to be called for manually triggering the daily update process.
* This function is public and can be called by any external entity.
*/
function manualDailyUpdate() external;
/**
* @notice Trigger cycle payouts for days 8, 28, 90, 369, 888, including the burn reward cycle 28.
* Payouts can be triggered on or after the maturity day of each cycle (e.g., Cycle8 on day 8).
*/
function triggerPayouts() external;
/**
* @notice Create a new mint
* @param mintPower The power of the mint, ranging from 1 to 100.
* @param numOfDays The duration of the mint, ranging from 1 to 280 days.
*/
function startMint(uint256 mintPower, uint256 numOfDays) external payable;
/**
* @notice Returns current mint cost
* @return currentMintCost The current cost of minting.
*/
function getCurrentMintCost() external view returns (uint256);
/** @notice end a stake
* @param id stake id
*/
function endStake(uint256 id) 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
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is set to the address provided by the deployer. This can
* later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable2Step.sol)
pragma solidity ^0.8.20;
import {Ownable} from "./Ownable.sol";
/**
* @dev Contract module which provides access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* The initial owner is specified at deployment time in the constructor for `Ownable`. This
* can later be changed with {transferOwnership} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/
abstract contract Ownable2Step is Ownable {
address private _pendingOwner;
event OwnershipTransferStarted(address indexed previousOwner, address indexed newOwner);
/**
* @dev Returns the address of the pending owner.
*/
function pendingOwner() public view virtual returns (address) {
return _pendingOwner;
}
/**
* @dev Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one.
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual override onlyOwner {
_pendingOwner = newOwner;
emit OwnershipTransferStarted(owner(), newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`) and deletes any pending owner.
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual override {
delete _pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/
function acceptOwnership() public virtual {
address sender = _msgSender();
if (pendingOwner() != sender) {
revert OwnableUnauthorizedAccount(sender);
}
_transferOwnership(sender);
}
}
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/draft-IERC6093.sol)
pragma solidity ^0.8.20;
/**
* @dev Standard ERC20 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC20 tokens.
*/
interface IERC20Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientBalance(address sender, uint256 balance, uint256 needed);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC20InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC20InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `spender`’s `allowance`. Used in transfers.
* @param spender Address that may be allowed to operate on tokens without being their owner.
* @param allowance Amount of tokens a `spender` is allowed to operate with.
* @param needed Minimum amount required to perform a transfer.
*/
error ERC20InsufficientAllowance(address spender, uint256 allowance, uint256 needed);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC20InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `spender` to be approved. Used in approvals.
* @param spender Address that may be allowed to operate on tokens without being their owner.
*/
error ERC20InvalidSpender(address spender);
}
/**
* @dev Standard ERC721 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC721 tokens.
*/
interface IERC721Errors {
/**
* @dev Indicates that an address can't be an owner. For example, `address(0)` is a forbidden owner in EIP-20.
* Used in balance queries.
* @param owner Address of the current owner of a token.
*/
error ERC721InvalidOwner(address owner);
/**
* @dev Indicates a `tokenId` whose `owner` is the zero address.
* @param tokenId Identifier number of a token.
*/
error ERC721NonexistentToken(uint256 tokenId);
/**
* @dev Indicates an error related to the ownership over a particular token. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param tokenId Identifier number of a token.
* @param owner Address of the current owner of a token.
*/
error ERC721IncorrectOwner(address sender, uint256 tokenId, address owner);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC721InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC721InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param tokenId Identifier number of a token.
*/
error ERC721InsufficientApproval(address operator, uint256 tokenId);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC721InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC721InvalidOperator(address operator);
}
/**
* @dev Standard ERC1155 Errors
* Interface of the https://eips.ethereum.org/EIPS/eip-6093[ERC-6093] custom errors for ERC1155 tokens.
*/
interface IERC1155Errors {
/**
* @dev Indicates an error related to the current `balance` of a `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
* @param balance Current balance for the interacting account.
* @param needed Minimum amount required to perform a transfer.
* @param tokenId Identifier number of a token.
*/
error ERC1155InsufficientBalance(address sender, uint256 balance, uint256 needed, uint256 tokenId);
/**
* @dev Indicates a failure with the token `sender`. Used in transfers.
* @param sender Address whose tokens are being transferred.
*/
error ERC1155InvalidSender(address sender);
/**
* @dev Indicates a failure with the token `receiver`. Used in transfers.
* @param receiver Address to which tokens are being transferred.
*/
error ERC1155InvalidReceiver(address receiver);
/**
* @dev Indicates a failure with the `operator`’s approval. Used in transfers.
* @param operator Address that may be allowed to operate on tokens without being their owner.
* @param owner Address of the current owner of a token.
*/
error ERC1155MissingApprovalForAll(address operator, address owner);
/**
* @dev Indicates a failure with the `approver` of a token to be approved. Used in approvals.
* @param approver Address initiating an approval operation.
*/
error ERC1155InvalidApprover(address approver);
/**
* @dev Indicates a failure with the `operator` to be approved. Used in approvals.
* @param operator Address that may be allowed to operate on tokens without being their owner.
*/
error ERC1155InvalidOperator(address operator);
/**
* @dev Indicates an array length mismatch between ids and values in a safeBatchTransferFrom operation.
* Used in batch transfers.
* @param idsLength Length of the array of token identifiers
* @param valuesLength Length of the array of token amounts
*/
error ERC1155InvalidArrayLength(uint256 idsLength, uint256 valuesLength);
}
{
"compilationTarget": {
"contracts/BabyDragonX.sol": "BabyDragonX"
},
"evmVersion": "paris",
"libraries": {},
"metadata": {
"bytecodeHash": "none"
},
"optimizer": {
"enabled": true,
"runs": 9999
},
"remappings": []
}
[{"inputs":[{"internalType":"address","name":"babyDragonBuyAndBurnAddress_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"allowance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientAllowance","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"uint256","name":"balance","type":"uint256"},{"internalType":"uint256","name":"needed","type":"uint256"}],"name":"ERC20InsufficientBalance","type":"error"},{"inputs":[{"internalType":"address","name":"approver","type":"address"}],"name":"ERC20InvalidApprover","type":"error"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"}],"name":"ERC20InvalidReceiver","type":"error"},{"inputs":[{"internalType":"address","name":"sender","type":"address"}],"name":"ERC20InvalidSender","type":"error"},{"inputs":[{"internalType":"address","name":"spender","type":"address"}],"name":"ERC20InvalidSpender","type":"error"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"OwnableInvalidOwner","type":"error"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"OwnableUnauthorizedAccount","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"dragon","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"babyDragon","type":"uint256"},{"indexed":true,"internalType":"address","name":"caller","type":"address"}],"name":"CollectedFees","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferStarted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"acceptOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"babyDragonBuyAndBurnAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"collectFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"finalizeMint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"getMintRatio","outputs":[{"internalType":"uint256","name":"ratio","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"initialLiquidityAmount","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"initialized","outputs":[{"internalType":"enum BabyDragonX.Initialized","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"lpTokenInfo","outputs":[{"internalType":"uint80","name":"tokenId","type":"uint80"},{"internalType":"uint128","name":"liquidity","type":"uint128"},{"internalType":"int24","name":"tickLower","type":"int24"},{"internalType":"int24","name":"tickUpper","type":"int24"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"titanAmount","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"mintPhaseBegin","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mintPhaseEnd","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"mintingFinalized","outputs":[{"internalType":"enum BabyDragonX.MintingFinalized","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pendingOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"poolAddress","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"pools","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"babyDragonBuyAndBurnAddress_","type":"address"}],"name":"setBabyDragonBuyAndBurnAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"poolAddress_","type":"address"},{"internalType":"bool","name":"isPool","type":"bool"}],"name":"setPool","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalBabyDragonBurned","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalDragonSentToBabyDragonBuyAndBurn","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"tradingEnabled","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}]