¡El código fuente de este contrato está verificado!
Metadatos del Contrato
Compilador
0.8.22+commit.4fc1097e
Idioma
Solidity
Código Fuente del Contrato
Archivo 1 de 14: Address.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)pragmasolidity ^0.8.1;/**
* @dev Collection of functions related to the address type
*/libraryAddress{
/**
* @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.
* ====
*/functionisContract(address account) internalviewreturns (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].
*/functionsendValue(addresspayable 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._
*/functionfunctionCall(address target, bytesmemory data) internalreturns (bytesmemory) {
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._
*/functionfunctionCall(address target,
bytesmemory data,
stringmemory errorMessage
) internalreturns (bytesmemory) {
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._
*/functionfunctionCallWithValue(address target, bytesmemory data, uint256 value) internalreturns (bytesmemory) {
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._
*/functionfunctionCallWithValue(address target,
bytesmemory data,
uint256 value,
stringmemory errorMessage
) internalreturns (bytesmemory) {
require(address(this).balance>= value, "Address: insufficient balance for call");
(bool success, bytesmemory 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._
*/functionfunctionStaticCall(address target, bytesmemory data) internalviewreturns (bytesmemory) {
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._
*/functionfunctionStaticCall(address target,
bytesmemory data,
stringmemory errorMessage
) internalviewreturns (bytesmemory) {
(bool success, bytesmemory 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._
*/functionfunctionDelegateCall(address target, bytesmemory data) internalreturns (bytesmemory) {
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._
*/functionfunctionDelegateCall(address target,
bytesmemory data,
stringmemory errorMessage
) internalreturns (bytesmemory) {
(bool success, bytesmemory 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._
*/functionverifyCallResultFromTarget(address target,
bool success,
bytesmemory returndata,
stringmemory errorMessage
) internalviewreturns (bytesmemory) {
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 contractrequire(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._
*/functionverifyCallResult(bool success,
bytesmemory returndata,
stringmemory errorMessage
) internalpurereturns (bytesmemory) {
if (success) {
return returndata;
} else {
_revert(returndata, errorMessage);
}
}
function_revert(bytesmemory returndata, stringmemory errorMessage) privatepure{
// Look for revert reason and bubble it up if presentif (returndata.length>0) {
// The easiest way to bubble the revert reason is using memory via assembly/// @solidity memory-safe-assemblyassembly {
let returndata_size :=mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
Código Fuente del Contrato
Archivo 2 de 14: CastleOfBlackwaterToken.sol
// SPDX-License-Identifier: BUSL-1.1pragmasolidity 0.8.22;import"@openzeppelin/contracts@4.9.6/access/Ownable2Step.sol";
import"@openzeppelin/contracts@4.9.6/token/ERC20/ERC20.sol";
import"@openzeppelin/contracts@4.9.6/token/ERC20/utils/SafeERC20.sol";
import"@uniswap/v3-core/contracts/interfaces/IUniswapV3Factory.sol";
import"@uniswap/v2-core/contracts/interfaces/IUniswapV2Factory.sol";
import"@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";
interfaceIUniswapV3Router{
functionfactory() externalpurereturns (address);
}
contractCastleOfBlackwaterTokenisERC20, Ownable2Step{
usingSafeERC20forIERC20;
IUniswapV2Router02 publicimmutable uniswapV2Router;
IUniswapV3Router publicimmutable uniswapV3Router;
addresspublicconstant ZERO_ADDRESS =address(0);
addresspublicconstant DEAD_ADDRESS =address(0xdead);
boolprivate _v2LPProtectionEnabled;
boolprivate _v3LPProtectionEnabled;
boolpublic limitsEnabled;
boolpublic taxesEnabled;
boolpublic launched;
boolpublic migrated;
uint256publicconstant MAX_BUY_FEE =500;
uint256publicconstant MAX_SELL_FEE =500;
uint256publicconstant FEES_PERCENT_DENOMINATOR =10000;
uint256publicconstant MAX_TRANSACTION_PERCENT_DENOMINATOR =1000000;
uint256publicconstant MAX_WALLET_PERCENT_DENOMINATOR =100000;
uint256public launchBlock;
uint256public launchTime;
uint256public maxTransaction;
uint256public maxWallet;
uint256public buyFees;
uint256public sellFees;
mapping(address=>bool) public isExcludedFromFees;
mapping(address=>bool) public isExcludedMaxTransactionAmount;
mapping(address=>bool) public automatedMarketMakerPairsV2;
mapping(address=>bool) public automatedMarketMakerPairsV3;
mapping(address=>bool) public isBot;
eventAirdrop(address account, uint256 amount);
eventLaunch();
eventPrepareForMigration();
eventSetLimitsEnabled(bool status);
eventSetTaxesEnabled(bool status);
eventSetMaxTransaction(uint256 oldValueMaxTransaction,
uint256 newValueMaxTransaction
);
eventSetMaxWallet(uint256 oldValueMaxWallet, uint256 newValueMaxWallet);
eventSetBuyFees(uint256 oldValue, uint256 newValue);
eventSetSellFees(uint256 oldValue, uint256 newValue);
eventWithdrawStuckTokens(address token, uint256 amount);
eventExcludeFromFees(addressindexed account, bool isExcluded);
eventExcludeFromMaxTransaction(addressindexed account, bool isExcluded);
eventSetBots(addressindexed account, bool isExcluded);
eventSetAutomatedMarketMakerPairV2(addressindexed pair,
boolindexed value
);
eventSetAutomatedMarketMakerPairV3(addressindexed pair,
boolindexed value
);
constructor(address _owner) ERC20("Castle of Blackwater", "COBE") {
address sender = _msgSender();
uint256 tSupply =100_000_000ether;
uint256 supplyToLiquidity = (tSupply *125) /10000;
uint256 supplyLeftover = tSupply - supplyToLiquidity;
uniswapV2Router = IUniswapV2Router02(
0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D
);
uniswapV3Router = IUniswapV3Router(
0xE592427A0AEce92De3Edee1F18E0157C05861564
);
maxTransaction = tSupply;
maxWallet = tSupply;
buyFees =500;
sellFees =500;
_excludeFromFees(sender, true);
_excludeFromFees(_owner, true);
_excludeFromFees(address(this), true);
_excludeFromFees(DEAD_ADDRESS, true);
_excludeFromMaxTransaction(sender, true);
_excludeFromMaxTransaction(_owner, true);
_excludeFromMaxTransaction(address(this), true);
_excludeFromMaxTransaction(DEAD_ADDRESS, true);
_excludeFromMaxTransaction(address(uniswapV2Router), true);
_mint(address(this), supplyToLiquidity);
_mint(_owner, supplyLeftover);
}
receive() externalpayable{}
functionburn(uint256 amount) publicvirtual{
_burn(_msgSender(), amount);
}
/**
* @dev The new owner accepts the ownership transfer.
* Revoke exclusions from previous owner.
* Grand exclusions to new owner.
*/functionacceptOwnership() publicvirtualoverride{
address sender = _msgSender();
require(
pendingOwner() == sender,
"CastleOfBlackwaterToken: caller is not the new owner"
);
address ownr = owner();
_excludeFromFees(ownr, false);
_excludeFromMaxTransaction(ownr, false);
_excludeFromFees(sender, true);
_excludeFromMaxTransaction(sender, true);
super.acceptOwnership();
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* Revoke exclusions from owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling any functionality that is only available to the owner.
*/functionrenounceOwnership() publicvirtualoverrideonlyOwner{
address sender = _msgSender();
_excludeFromFees(sender, false);
_excludeFromMaxTransaction(sender, false);
super.renounceOwnership();
}
/**
* @dev Transfer corresponding amounts of tokens owned by this owner to accounts
*
* Requirements:
*
* - `accounts` array length should be equal to `amounts` array length
*/functionairdrop(address[] memory accounts,
uint256[] memory amounts
) publiconlyOwner{
uint256 accountsLength = accounts.length;
require(
accountsLength == amounts.length,
"CastleOfBlackwaterToken: Arrays must be the same length"
);
for (uint256 i =0; i < accountsLength; i++) {
address account = accounts[i];
uint256 amount = amounts[i];
_transfer(_msgSender(), account, amount);
emit Airdrop(account, amount);
}
}
/**
* @dev Trigger the launch of the token
*/functionlaunch() publicpayableonlyOwner{
require(!launched, "CastleOfBlackwaterToken: Already launched.");
IUniswapV2Factory uniswapV2Factory = IUniswapV2Factory(
uniswapV2Router.factory()
);
IUniswapV3Factory uniswapV3Factory = IUniswapV3Factory(
uniswapV3Router.factory()
);
address wethAddress = uniswapV2Router.WETH();
address uniswapV2Pair = uniswapV2Factory.getPair(
address(this),
wethAddress
);
address uniswapV3Migrator =0xA5644E29708357803b5A882D272c41cC0dF92B34;
if (uniswapV2Pair == ZERO_ADDRESS) {
uniswapV2Pair = uniswapV2Factory.createPair(
address(this),
wethAddress
);
}
address uniswapV3Pool10000 = IUniswapV3Factory(
uniswapV3Router.factory()
).getPool(address(this), wethAddress, 10000);
address uniswapV3Pool3000 = uniswapV3Factory.getPool(
address(this),
wethAddress,
3000
);
address uniswapV3Pool500 = uniswapV3Factory.getPool(
address(this),
wethAddress,
500
);
address uniswapV3Pool100 = uniswapV3Factory.getPool(
address(this),
wethAddress,
100
);
if (uniswapV3Pool10000 == ZERO_ADDRESS) {
uniswapV3Pool10000 = uniswapV3Factory.createPool(
address(this),
wethAddress,
10000
);
}
if (uniswapV3Pool3000 == ZERO_ADDRESS) {
uniswapV3Pool3000 = uniswapV3Factory.createPool(
address(this),
wethAddress,
3000
);
}
if (uniswapV3Pool500 == ZERO_ADDRESS) {
uniswapV3Pool500 = uniswapV3Factory.createPool(
address(this),
wethAddress,
500
);
}
if (uniswapV3Pool100 == ZERO_ADDRESS) {
uniswapV3Pool100 = uniswapV3Factory.createPool(
address(this),
wethAddress,
100
);
}
_setAutomatedMarketMakerPairV2(address(uniswapV2Pair), true);
_setAutomatedMarketMakerPairV3(address(uniswapV3Pool10000), true);
_setAutomatedMarketMakerPairV3(address(uniswapV3Pool3000), true);
_setAutomatedMarketMakerPairV3(address(uniswapV3Pool500), true);
_setAutomatedMarketMakerPairV3(address(uniswapV3Pool100), true);
_excludeFromMaxTransaction(address(uniswapV2Pair), true);
_excludeFromMaxTransaction(address(uniswapV3Pool10000), true);
_excludeFromMaxTransaction(address(uniswapV3Pool3000), true);
_excludeFromMaxTransaction(address(uniswapV3Pool500), true);
_excludeFromMaxTransaction(address(uniswapV3Pool100), true);
_excludeFromMaxTransaction(uniswapV3Migrator, true);
_excludeFromFees(uniswapV3Migrator, true);
uint256 ethAmount =address(this).balance;
require(ethAmount >0, "CastleOfBlackwaterToken: Invalid ETH amount.");
uint256 tokenAmount = balanceOf(address(this));
require(
tokenAmount >0,
"CastleOfBlackwaterToken: Invalid token amount."
);
uint256 amountTokenMin = (tokenAmount *99) /100;
uint256 amountETHMin = (ethAmount *99) /100;
_approve(address(this), address(uniswapV2Router), tokenAmount);
(uint256 amountToken, uint256 amountETH, ) = uniswapV2Router
.addLiquidityETH{value: ethAmount}(
address(this),
tokenAmount,
amountTokenMin,
amountETHMin,
tx.origin,
block.timestamp+ (30minutes)
);
require(
(amountToken >= amountTokenMin) && (amountToken <= tokenAmount),
"CastleOfBlackwaterToken: Undesired amount of tokens added to liquidity."
);
require(
(amountETH >= amountETHMin) && (amountETH <= ethAmount),
"CastleOfBlackwaterToken: Undesired amount of ETH added to liquidity."
);
maxTransaction = tokenAmount /100;
maxWallet = tokenAmount /100;
_v2LPProtectionEnabled =false;
_v3LPProtectionEnabled =true;
limitsEnabled =true;
taxesEnabled =true;
launched =true;
launchBlock =block.number;
launchTime =block.timestamp;
emit Launch();
}
/**
* @dev Trigger the preparation for migration of the token to UniswapV3
*/functionprepareForMigration() publiconlyOwner{
require(!migrated, "CastleOfBlackwaterToken: Already migrated.");
require(launched, "CastleOfBlackwaterToken: Not launched.");
_v2LPProtectionEnabled =true;
_v3LPProtectionEnabled =false;
limitsEnabled =false;
taxesEnabled =false;
buyFees =0;
sellFees =0;
maxTransaction = totalSupply();
maxWallet = totalSupply();
if (balanceOf(address(this)) >0) {
super._transfer(
address(this),
_msgSender(),
balanceOf(address(this))
);
}
migrated =true;
emit PrepareForMigration();
}
/**
* @dev Activate or deactivate the enforcement of limits during transfers
*/functionsetLimitsEnabled(bool value) publiconlyOwner{
require(!migrated, "CastleOfBlackwaterToken: Already migrated.");
limitsEnabled = value;
emit SetLimitsEnabled(value);
}
/**
* @dev Activate or deactivate the enforcement of fees during transfers
*/functionsetTaxesEnabled(bool value) publiconlyOwner{
require(!migrated, "CastleOfBlackwaterToken: Already migrated.");
taxesEnabled = value;
emit SetTaxesEnabled(value);
}
/**
* @dev Update the max transaction enforced during transfers
*/functionsetMaxTransaction(uint256 _maxTransaction) externalonlyOwner{
require(!migrated, "CastleOfBlackwaterToken: Already migrated.");
require(
_maxTransaction >=
(totalSupply() / MAX_TRANSACTION_PERCENT_DENOMINATOR),
"CastleOfBlackwaterToken: Cannot set maxTransaction lower than 0.0001%"
);
uint256 oldValueMaxTransaction = maxTransaction;
maxTransaction = _maxTransaction;
emit SetMaxTransaction(oldValueMaxTransaction, _maxTransaction);
}
/**
* @dev Update the max wallet enforced during transfers
*/functionsetMaxWallet(uint256 _maxWallet) externalonlyOwner{
require(!migrated, "CastleOfBlackwaterToken: Already migrated.");
require(
_maxWallet >= (totalSupply() / MAX_WALLET_PERCENT_DENOMINATOR),
"CastleOfBlackwaterToken: Cannot set maxWallet lower than 0.001%"
);
uint256 oldValueMaxWallet = maxWallet;
maxWallet = _maxWallet;
emit SetMaxWallet(oldValueMaxWallet, _maxWallet);
}
/**
* @dev Update the fee enforced during transfers when tokens are bought
*/functionsetBuyFees(uint256 _buyFees) publiconlyOwner{
require(!migrated, "CastleOfBlackwaterToken: Already migrated.");
require(
_buyFees <= MAX_BUY_FEE,
"CastleOfBlackwaterToken: Must keep fees at 5% or less"
);
uint256 oldValue = buyFees;
buyFees = _buyFees;
emit SetBuyFees(oldValue, _buyFees);
}
/**
* @dev Update the fee enforced during transfers when tokens are sold
*/functionsetSellFees(uint256 _sellFees) publiconlyOwner{
require(!migrated, "CastleOfBlackwaterToken: Already migrated.");
require(
_sellFees <= MAX_SELL_FEE,
"CastleOfBlackwaterToken: Must keep fees at 5% or less"
);
uint256 oldValue = sellFees;
sellFees = _sellFees;
emit SetSellFees(oldValue, _sellFees);
}
/**
* @dev Withdraw any amount of native or ERC20 tokens from the contract
* excluding self token
*/functionwithdrawStuckTokens(address tkn) publiconlyOwner{
require(
tkn !=address(this),
"CastleOfBlackwaterToken: Cannot withdraw self"
);
address sender = _msgSender();
uint256 amount;
if (tkn == ZERO_ADDRESS) {
bool success;
amount =address(this).balance;
require(amount >0, "CastleOfBlackwaterToken: No native tokens");
(success, ) =address(sender).call{value: amount}("");
require(
success,
"CastleOfBlackwaterToken: Failed to withdraw native tokens"
);
} else {
amount = IERC20(tkn).balanceOf(address(this));
require(amount >0, "CastleOfBlackwaterToken: No tokens");
IERC20(tkn).safeTransfer(sender, amount);
}
emit WithdrawStuckTokens(tkn, amount);
}
/**
* @dev Exclude (or not) accounts from fees
*/functionexcludeFromFees(address[] calldata accounts,
bool value
) publiconlyOwner{
require(!migrated, "CastleOfBlackwaterToken: Already migrated.");
for (uint256 i =0; i < accounts.length; i++) {
_excludeFromFees(accounts[i], value);
}
}
/**
* @dev Exclude (or not) accounts from transaction and wallets limits
*/functionexcludeFromMaxTransaction(address[] calldata accounts,
bool value
) publiconlyOwner{
require(!migrated, "CastleOfBlackwaterToken: Already migrated.");
for (uint256 i =0; i < accounts.length; i++) {
_excludeFromMaxTransaction(accounts[i], value);
}
}
/**
* @dev Set account as an AMM for Uniswap V2
*
* NOTE The effect of this function cannot be reverted
*/functionsetAutomatedMarketMakerPairV2(address account,
bool value
) publiconlyOwner{
require(
!automatedMarketMakerPairsV2[account],
"CastleOfBlackwaterToken: AMM Pair v2 already set."
);
_setAutomatedMarketMakerPairV2(account, value);
}
/**
* @dev Set account as an AMM for Uniswap V3
*
* NOTE The effect of this function cannot be reverted
*/functionsetAutomatedMarketMakerPairV3(address account,
bool value
) publiconlyOwner{
require(
!automatedMarketMakerPairsV3[account],
"CastleOfBlackwaterToken: AMM Pair v3 already set."
);
_setAutomatedMarketMakerPairV3(account, value);
}
/**
* @dev Set accounts (or not) as bots
*/functionsetBots(address[] calldata accounts, bool value) publiconlyOwner{
for (uint256 i =0; i < accounts.length; i++) {
if (
(!automatedMarketMakerPairsV2[accounts[i]]) &&
(!automatedMarketMakerPairsV3[accounts[i]]) &&
(accounts[i] !=address(uniswapV2Router)) &&
(accounts[i] !=address(uniswapV3Router)) &&
(accounts[i] !=address(this)) &&
(!isExcludedFromFees[accounts[i]] &&!isExcludedMaxTransactionAmount[accounts[i]])
) _setBots(accounts[i], value);
}
}
function_transfer(addressfrom,
address to,
uint256 amount
) internalvirtualoverride{
require(
from!= ZERO_ADDRESS,
"CastleOfBlackwaterToken: transfer from the zero address"
);
require(
to != ZERO_ADDRESS,
"CastleOfBlackwaterToken: transfer to the zero address"
);
if (
(isExcludedFromFees[from] || isExcludedFromFees[to]) &&
(isExcludedMaxTransactionAmount[from] ||
isExcludedMaxTransactionAmount[to])
) {
super._transfer(from, to, amount);
return;
}
address sender = _msgSender();
require(!isBot[from], "CastleOfBlackwaterToken: bot detected");
require(
sender ==from||!isBot[sender],
"CastleOfBlackwaterToken: bot detected"
);
require(
tx.origin==from||tx.origin== sender ||!isBot[tx.origin],
"CastleOfBlackwaterToken: bot detected"
);
if (amount ==0) {
super._transfer(from, to, 0);
return;
}
address ownr = owner();
require(
launched ||from== ownr || to == ownr || to == DEAD_ADDRESS,
"CastleOfBlackwaterToken: Not launched."
);
require(
!_v2LPProtectionEnabled ||
(!automatedMarketMakerPairsV2[from] &&!automatedMarketMakerPairsV2[to]),
"CastleOfBlackwaterToken: Not authorized to trade through Uniswap V2 Pool"
);
require(
!_v3LPProtectionEnabled ||
(!automatedMarketMakerPairsV3[from] &&!automatedMarketMakerPairsV3[to]),
"CastleOfBlackwaterToken: Not authorized to trade through Uniswap V3 Pool"
);
if (limitsEnabled) {
if (
automatedMarketMakerPairsV2[from] &&!isExcludedMaxTransactionAmount[to]
) {
require(
amount <= maxTransaction,
"CastleOfBlackwaterToken: Buy transfer amount exceeds the maxTransaction."
);
require(
(amount + balanceOf(to)) <= maxWallet,
"CastleOfBlackwaterToken: Max wallet exceeded"
);
} elseif (
automatedMarketMakerPairsV2[to] &&!isExcludedMaxTransactionAmount[from]
) {
require(
amount <= maxTransaction,
"CastleOfBlackwaterToken: Sell transfer amount exceeds the maxTransaction."
);
} elseif (!isExcludedMaxTransactionAmount[to]) {
require(
(amount + balanceOf(to)) <= maxWallet,
"CastleOfBlackwaterToken: Max wallet exceeded"
);
}
}
if (taxesEnabled) {
uint256 fees =0;
uint256 totalFees =0;
if (automatedMarketMakerPairsV2[to] && sellFees >0) {
if (block.number> launchBlock) {
totalFees = sellFees;
} else {
totalFees =3000;
}
fees = (amount * totalFees) / FEES_PERCENT_DENOMINATOR;
} elseif (automatedMarketMakerPairsV2[from] && buyFees >0) {
if (block.number> launchBlock) {
totalFees = buyFees;
} else {
totalFees =3000;
}
fees = (amount * totalFees) / FEES_PERCENT_DENOMINATOR;
}
if (fees >0) {
super._burn(from, fees);
}
amount -= fees;
}
super._transfer(from, to, amount);
}
function_excludeFromMaxTransaction(address account,
bool value
) internalvirtual{
isExcludedMaxTransactionAmount[account] = value;
emit ExcludeFromMaxTransaction(account, value);
}
function_excludeFromFees(address account, bool value) internalvirtual{
isExcludedFromFees[account] = value;
emit ExcludeFromFees(account, value);
}
function_setBots(address account, bool value) internalvirtual{
isBot[account] = value;
emit SetBots(account, value);
}
function_setAutomatedMarketMakerPairV2(address account,
bool value
) internalvirtual{
automatedMarketMakerPairsV2[account] = value;
emit SetAutomatedMarketMakerPairV2(account, value);
}
function_setAutomatedMarketMakerPairV3(address account,
bool value
) internalvirtual{
automatedMarketMakerPairsV3[account] = value;
emit SetAutomatedMarketMakerPairV3(account, value);
}
}
Código Fuente del Contrato
Archivo 3 de 14: Context.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.9.4) (utils/Context.sol)pragmasolidity ^0.8.0;/**
* @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.
*/abstractcontractContext{
function_msgSender() internalviewvirtualreturns (address) {
returnmsg.sender;
}
function_msgData() internalviewvirtualreturns (bytescalldata) {
returnmsg.data;
}
function_contextSuffixLength() internalviewvirtualreturns (uint256) {
return0;
}
}
Código Fuente del Contrato
Archivo 4 de 14: ERC20.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)pragmasolidity ^0.8.0;import"./IERC20.sol";
import"./extensions/IERC20Metadata.sol";
import"../../utils/Context.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}.
* For a generic mechanism see {ERC20PresetMinterPauser}.
*
* 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.
*
* Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
* functions have been added to mitigate the well-known issues around setting
* allowances. See {IERC20-approve}.
*/contractERC20isContext, IERC20, IERC20Metadata{
mapping(address=>uint256) private _balances;
mapping(address=>mapping(address=>uint256)) private _allowances;
uint256private _totalSupply;
stringprivate _name;
stringprivate _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(stringmemory name_, stringmemory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev Returns the name of the token.
*/functionname() publicviewvirtualoverridereturns (stringmemory) {
return _name;
}
/**
* @dev Returns the symbol of the token, usually a shorter version of the
* name.
*/functionsymbol() publicviewvirtualoverridereturns (stringmemory) {
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}.
*/functiondecimals() publicviewvirtualoverridereturns (uint8) {
return18;
}
/**
* @dev See {IERC20-totalSupply}.
*/functiontotalSupply() publicviewvirtualoverridereturns (uint256) {
return _totalSupply;
}
/**
* @dev See {IERC20-balanceOf}.
*/functionbalanceOf(address account) publicviewvirtualoverridereturns (uint256) {
return _balances[account];
}
/**
* @dev See {IERC20-transfer}.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - the caller must have a balance of at least `amount`.
*/functiontransfer(address to, uint256 amount) publicvirtualoverridereturns (bool) {
address owner = _msgSender();
_transfer(owner, to, amount);
returntrue;
}
/**
* @dev See {IERC20-allowance}.
*/functionallowance(address owner, address spender) publicviewvirtualoverridereturns (uint256) {
return _allowances[owner][spender];
}
/**
* @dev See {IERC20-approve}.
*
* NOTE: If `amount` 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.
*/functionapprove(address spender, uint256 amount) publicvirtualoverridereturns (bool) {
address owner = _msgSender();
_approve(owner, spender, amount);
returntrue;
}
/**
* @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 `amount`.
* - the caller must have allowance for ``from``'s tokens of at least
* `amount`.
*/functiontransferFrom(addressfrom, address to, uint256 amount) publicvirtualoverridereturns (bool) {
address spender = _msgSender();
_spendAllowance(from, spender, amount);
_transfer(from, to, amount);
returntrue;
}
/**
* @dev Atomically increases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
*/functionincreaseAllowance(address spender, uint256 addedValue) publicvirtualreturns (bool) {
address owner = _msgSender();
_approve(owner, spender, allowance(owner, spender) + addedValue);
returntrue;
}
/**
* @dev Atomically decreases the allowance granted to `spender` by the caller.
*
* This is an alternative to {approve} that can be used as a mitigation for
* problems described in {IERC20-approve}.
*
* Emits an {Approval} event indicating the updated allowance.
*
* Requirements:
*
* - `spender` cannot be the zero address.
* - `spender` must have allowance for the caller of at least
* `subtractedValue`.
*/functiondecreaseAllowance(address spender, uint256 subtractedValue) publicvirtualreturns (bool) {
address owner = _msgSender();
uint256 currentAllowance = allowance(owner, spender);
require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
unchecked {
_approve(owner, spender, currentAllowance - subtractedValue);
}
returntrue;
}
/**
* @dev Moves `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.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `from` must have a balance of at least `amount`.
*/function_transfer(addressfrom, address to, uint256 amount) internalvirtual{
require(from!=address(0), "ERC20: transfer from the zero address");
require(to !=address(0), "ERC20: transfer to the zero address");
_beforeTokenTransfer(from, to, amount);
uint256 fromBalance = _balances[from];
require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
unchecked {
_balances[from] = fromBalance - amount;
// Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by// decrementing then incrementing.
_balances[to] += amount;
}
emit Transfer(from, to, amount);
_afterTokenTransfer(from, to, amount);
}
/** @dev Creates `amount` tokens and assigns them to `account`, increasing
* the total supply.
*
* Emits a {Transfer} event with `from` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
*/function_mint(address account, uint256 amount) internalvirtual{
require(account !=address(0), "ERC20: mint to the zero address");
_beforeTokenTransfer(address(0), account, amount);
_totalSupply += amount;
unchecked {
// Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
_balances[account] += amount;
}
emit Transfer(address(0), account, amount);
_afterTokenTransfer(address(0), account, amount);
}
/**
* @dev Destroys `amount` tokens from `account`, reducing the
* total supply.
*
* Emits a {Transfer} event with `to` set to the zero address.
*
* Requirements:
*
* - `account` cannot be the zero address.
* - `account` must have at least `amount` tokens.
*/function_burn(address account, uint256 amount) internalvirtual{
require(account !=address(0), "ERC20: burn from the zero address");
_beforeTokenTransfer(account, address(0), amount);
uint256 accountBalance = _balances[account];
require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
unchecked {
_balances[account] = accountBalance - amount;
// Overflow not possible: amount <= accountBalance <= totalSupply.
_totalSupply -= amount;
}
emit Transfer(account, address(0), amount);
_afterTokenTransfer(account, address(0), amount);
}
/**
* @dev Sets `amount` 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.
*/function_approve(address owner, address spender, uint256 amount) internalvirtual{
require(owner !=address(0), "ERC20: approve from the zero address");
require(spender !=address(0), "ERC20: approve to the zero address");
_allowances[owner][spender] = amount;
emit Approval(owner, spender, amount);
}
/**
* @dev Updates `owner` s allowance for `spender` based on spent `amount`.
*
* Does not update the allowance amount in case of infinite allowance.
* Revert if not enough allowance is available.
*
* Might emit an {Approval} event.
*/function_spendAllowance(address owner, address spender, uint256 amount) internalvirtual{
uint256 currentAllowance = allowance(owner, spender);
if (currentAllowance !=type(uint256).max) {
require(currentAllowance >= amount, "ERC20: insufficient allowance");
unchecked {
_approve(owner, spender, currentAllowance - amount);
}
}
}
/**
* @dev Hook that is called before any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* will be transferred to `to`.
* - when `from` is zero, `amount` tokens will be minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/function_beforeTokenTransfer(addressfrom, address to, uint256 amount) internalvirtual{}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
* has been transferred to `to`.
* - when `from` is zero, `amount` tokens have been minted for `to`.
* - when `to` is zero, `amount` of ``from``'s tokens have been burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/function_afterTokenTransfer(addressfrom, address to, uint256 amount) internalvirtual{}
}
Código Fuente del Contrato
Archivo 5 de 14: IERC20.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)pragmasolidity ^0.8.0;/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/interfaceIERC20{
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/eventTransfer(addressindexedfrom, addressindexed 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.
*/eventApproval(addressindexed owner, addressindexed spender, uint256 value);
/**
* @dev Returns the amount of tokens in existence.
*/functiontotalSupply() externalviewreturns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/functionbalanceOf(address account) externalviewreturns (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.
*/functiontransfer(address to, uint256 amount) externalreturns (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.
*/functionallowance(address owner, address spender) externalviewreturns (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.
*/functionapprove(address spender, uint256 amount) externalreturns (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.
*/functiontransferFrom(addressfrom, address to, uint256 amount) externalreturns (bool);
}
Código Fuente del Contrato
Archivo 6 de 14: IERC20Metadata.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)pragmasolidity ^0.8.0;import"../IERC20.sol";
/**
* @dev Interface for the optional metadata functions from the ERC20 standard.
*
* _Available since v4.1._
*/interfaceIERC20MetadataisIERC20{
/**
* @dev Returns the name of the token.
*/functionname() externalviewreturns (stringmemory);
/**
* @dev Returns the symbol of the token.
*/functionsymbol() externalviewreturns (stringmemory);
/**
* @dev Returns the decimals places of the token.
*/functiondecimals() externalviewreturns (uint8);
}
Código Fuente del Contrato
Archivo 7 de 14: IERC20Permit.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.9.4) (token/ERC20/extensions/IERC20Permit.sol)pragmasolidity ^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.
*/interfaceIERC20Permit{
/**
* @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.
*/functionpermit(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.
*/functionnonces(address owner) externalviewreturns (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-mixedcasefunctionDOMAIN_SEPARATOR() externalviewreturns (bytes32);
}
// SPDX-License-Identifier: GPL-2.0-or-laterpragmasolidity >=0.5.0;/// @title The interface for the Uniswap V3 Factory/// @notice The Uniswap V3 Factory facilitates creation of Uniswap V3 pools and control over the protocol feesinterfaceIUniswapV3Factory{
/// @notice Emitted when the owner of the factory is changed/// @param oldOwner The owner before the owner was changed/// @param newOwner The owner after the owner was changedeventOwnerChanged(addressindexed oldOwner, addressindexed newOwner);
/// @notice Emitted when a pool is created/// @param token0 The first token of the pool by address sort order/// @param token1 The second token of the pool by address sort order/// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip/// @param tickSpacing The minimum number of ticks between initialized ticks/// @param pool The address of the created pooleventPoolCreated(addressindexed token0,
addressindexed token1,
uint24indexed fee,
int24 tickSpacing,
address pool
);
/// @notice Emitted when a new fee amount is enabled for pool creation via the factory/// @param fee The enabled fee, denominated in hundredths of a bip/// @param tickSpacing The minimum number of ticks between initialized ticks for pools created with the given feeeventFeeAmountEnabled(uint24indexed fee, int24indexed tickSpacing);
/// @notice Returns the current owner of the factory/// @dev Can be changed by the current owner via setOwner/// @return The address of the factory ownerfunctionowner() externalviewreturns (address);
/// @notice Returns the tick spacing for a given fee amount, if enabled, or 0 if not enabled/// @dev A fee amount can never be removed, so this value should be hard coded or cached in the calling context/// @param fee The enabled fee, denominated in hundredths of a bip. Returns 0 in case of unenabled fee/// @return The tick spacingfunctionfeeAmountTickSpacing(uint24 fee) externalviewreturns (int24);
/// @notice Returns the pool address for a given pair of tokens and a fee, or address 0 if it does not exist/// @dev tokenA and tokenB may be passed in either token0/token1 or token1/token0 order/// @param tokenA The contract address of either token0 or token1/// @param tokenB The contract address of the other token/// @param fee The fee collected upon every swap in the pool, denominated in hundredths of a bip/// @return pool The pool addressfunctiongetPool(address tokenA,
address tokenB,
uint24 fee
) externalviewreturns (address pool);
/// @notice Creates a pool for the given two tokens and fee/// @param tokenA One of the two tokens in the desired pool/// @param tokenB The other of the two tokens in the desired pool/// @param fee The desired fee for the pool/// @dev tokenA and tokenB may be passed in either order: token0/token1 or token1/token0. tickSpacing is retrieved/// from the fee. The call will revert if the pool already exists, the fee is invalid, or the token arguments/// are invalid./// @return pool The address of the newly created poolfunctioncreatePool(address tokenA,
address tokenB,
uint24 fee
) externalreturns (address pool);
/// @notice Updates the owner of the factory/// @dev Must be called by the current owner/// @param _owner The new owner of the factoryfunctionsetOwner(address _owner) external;
/// @notice Enables a fee amount with the given tickSpacing/// @dev Fee amounts may never be removed once enabled/// @param fee The fee amount to enable, denominated in hundredths of a bip (i.e. 1e-6)/// @param tickSpacing The spacing between ticks to be enforced for all pools created with the given fee amountfunctionenableFeeAmount(uint24 fee, int24 tickSpacing) external;
}
Código Fuente del Contrato
Archivo 12 de 14: Ownable.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)pragmasolidity ^0.8.0;import"../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.
*
* By default, the owner account will be the one that deploys the contract. 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.
*/abstractcontractOwnableisContext{
addressprivate _owner;
eventOwnershipTransferred(addressindexed previousOwner, addressindexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/modifieronlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/functionowner() publicviewvirtualreturns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/function_checkOwner() internalviewvirtual{
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @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.
*/functionrenounceOwnership() publicvirtualonlyOwner{
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/functiontransferOwnership(address newOwner) publicvirtualonlyOwner{
require(newOwner !=address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/function_transferOwnership(address newOwner) internalvirtual{
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
Código Fuente del Contrato
Archivo 13 de 14: Ownable2Step.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable2Step.sol)pragmasolidity ^0.8.0;import"./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.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership} and {acceptOwnership}.
*
* This module is used through inheritance. It will make available all functions
* from parent (Ownable).
*/abstractcontractOwnable2StepisOwnable{
addressprivate _pendingOwner;
eventOwnershipTransferStarted(addressindexed previousOwner, addressindexed newOwner);
/**
* @dev Returns the address of the pending owner.
*/functionpendingOwner() publicviewvirtualreturns (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.
*/functiontransferOwnership(address newOwner) publicvirtualoverrideonlyOwner{
_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) internalvirtualoverride{
delete _pendingOwner;
super._transferOwnership(newOwner);
}
/**
* @dev The new owner accepts the ownership transfer.
*/functionacceptOwnership() publicvirtual{
address sender = _msgSender();
require(pendingOwner() == sender, "Ownable2Step: caller is not the new owner");
_transferOwnership(sender);
}
}
Código Fuente del Contrato
Archivo 14 de 14: SafeERC20.sol
// SPDX-License-Identifier: MIT// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)pragmasolidity ^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.
*/librarySafeERC20{
usingAddressforaddress;
/**
* @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.
*/functionsafeTransfer(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.
*/functionsafeTransferFrom(IERC20 token, addressfrom, 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.
*/functionsafeApprove(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.
*/functionsafeIncreaseAllowance(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.
*/functionsafeDecreaseAllowance(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.
*/functionforceApprove(IERC20 token, address spender, uint256 value) internal{
bytesmemory 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.
*/functionsafePermit(
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, bytesmemory 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.bytesmemory 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, bytesmemory data) privatereturns (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, bytesmemory returndata) =address(token).call(data);
return
success && (returndata.length==0||abi.decode(returndata, (bool))) && Address.isContract(address(token));
}
}