Verified contractExactMIT
AutoBuyBurnHook
Address0xe3aafd5568c7c6031fcf329b689d148c086b60cc
- Balance
0 ETH
- Transactions
2
- Compiler
solc 0.8.24
- Same code
Only this contract
Details
- Compiler
- solc 0.8.24+commit.e11b9ed9
- Language
- solidity
- Optimization
- Yes, 1 runs
- EVM version
- paris
- Via IR
- yes
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 24,155,273
- Creation transaction
- 0x931b7c0746…29a3b8d717
14 files
- contracts/hooks/AutoBuyBurnHook.solmain25.77 KB
- @openzeppelin/contracts/interfaces/IERC1363.sol4.45 KB
- @openzeppelin/contracts/interfaces/IERC165.sol193 B
- @openzeppelin/contracts/interfaces/IERC20.sol182 B
- @openzeppelin/contracts/token/ERC20/IERC20.sol2.78 KB
- @openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol10.08 KB
- @openzeppelin/contracts/utils/introspection/IERC165.sol871 B
- contracts/errors/Errors.sol608 B
- contracts/interfaces/IConfigurableHook.sol1.96 KB
- contracts/interfaces/ICurrency.sol939 B
- contracts/interfaces/IHooks.sol2.66 KB
- contracts/interfaces/IPoolManager.sol2.54 KB
- contracts/interfaces/IUnlockCallback.sol525 B
- contracts/interfaces/IWETH.sol523 B
contracts/hooks/AutoBuyBurnHook.sol
// SPDX-License-Identifier: MIT
// Qian Exchange - https://qian.ag
pragma solidity ^0.8.24;
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import "../interfaces/IPoolManager.sol";
import "../interfaces/IHooks.sol";
import "../interfaces/ICurrency.sol";
import "../interfaces/IUnlockCallback.sol";
import "../interfaces/IConfigurableHook.sol";
import "../interfaces/IWETH.sol";
import "../errors/Errors.sol";
/// @notice Interface for ERC20Burnable tokens
interface IERC20Burnable {
function burn(uint256 amount) external;
function burnFrom(address account, uint256 amount) external;
}
/**
* @title AutoBuyBurnHook
* @notice Uniswap V4 hook with buy/sell taxes, buyback/burn, and platform fees
* @dev Updated to implement IConfigurableHook for generic factory integration
*
* Tax Collection Strategy:
* - For BUYS (WETH → Token): Take WETH fee during beforeSwap
* - For SELLS (Token → WETH): Track WETH fee during afterSwap
*
* Fee Distribution on Buyback:
* - 20% of collected fees → Platform fee collector (in WETH)
* - 80% of collected fees → Buyback and burn tokens
*
* Tax Limits:
* - Max buy tax: 15% (1500 bps)
* - Max sell tax: 15% (1500 bps)
*
* Required hook flags: 0x00CC
*/
contract AutoBuyBurnHook is IHooks, IConfigurableHook, IUnlockCallback {
using SafeERC20 for IERC20;
using CurrencyLibrary for Currency;
// ============================================================
// CONSTANTS
// ============================================================
uint256 public constant FEE_DENOMINATOR = 10000;
uint256 public constant MAX_TAX_BPS = 1500; // Max 15% buy/sell tax
uint256 public constant MIN_PLATFORM_FEE_BPS = 2000; // Min 20% of fees to platform
uint256 public constant MAX_PLATFORM_FEE_BPS = 5000; // Max 50% of fees to platform
uint256 public constant MIN_THRESHOLD = 0.01 ether; // Min threshold 0.01 ETH
uint256 public constant MAX_THRESHOLD = 1 ether; // Max threshold 1 ETH
// ============================================================
// STATE
// ============================================================
address public immutable poolManager;
address public immutable weth;
address public controller;
address public platformFeeCollector;
address public factory;
uint256 public defaultPlatformFeeBps; // Default for NEW tokens (20-50%)
struct TaxConfig {
uint16 buyTaxBps;
uint16 sellTaxBps;
uint16 platformFeeBps; // FROZEN per-token at deployment (20-50%)
uint256 threshold;
uint256 accumulated;
address tokenAddress;
bool enabled;
}
mapping(bytes32 => TaxConfig) public taxConfigs;
uint256 public totalBuybacks;
uint256 public totalBurned;
uint256 public totalPlatformFees;
bool private _buybackInProgress;
uint256 public constant MIN_GAS_FOR_BUYBACK = 200000;
// ============================================================
// EVENTS
// ============================================================
event TaxTaken(bytes32 indexed poolId, uint256 amount, bool isBuy);
event BuybackExecuted(bytes32 indexed poolId, uint256 wethSpent, uint256 tokensBurned);
event PlatformFeeSent(bytes32 indexed poolId, uint256 wethAmount, address recipient);
event ThresholdReached(bytes32 indexed poolId, uint256 accumulated);
event PlatformFeeCollectorUpdated(address oldCollector, address newCollector);
event PlatformFeeBpsUpdated(uint256 oldBps, uint256 newBps);
event AutoBuybackTriggered(bytes32 indexed poolId, uint256 gasRemaining);
event AutoBuybackSkipped(bytes32 indexed poolId, string reason);
event HookConfigured(bytes32 indexed poolId, address indexed token, uint16 buyTaxBps, uint16 sellTaxBps);
event EmergencyWithdraw(address indexed to, uint256 wethAmount, uint256 ethAmount);
// ============================================================
// CONSTRUCTOR
// ============================================================
constructor(address _poolManager, address _weth, address _controller, address _platformFeeCollector) {
poolManager = _poolManager;
weth = _weth;
controller = _controller;
platformFeeCollector = _platformFeeCollector;
defaultPlatformFeeBps = 2000; // Default 20% of fees to platform (for NEW tokens)
}
// ============================================================
// IConfigurableHook IMPLEMENTATION
// ============================================================
/**
* @notice Configure the hook for a token's pool
* @param poolId The pool identifier
* @param tokenAddress The token address
* @param config Encoded as: abi.encode(uint16 buyTaxBps, uint16 sellTaxBps, uint256 threshold)
* @dev Called by factory. All settings are FROZEN after this call.
*/
function configureHook(
bytes32 poolId,
address tokenAddress,
bytes calldata config
) external override {
// Allow both controller and factory to configure
if (msg.sender != controller && msg.sender != factory) revert NotController();
// CRITICAL: Prevent reconfiguration - all settings are immutable after setup
if (taxConfigs[poolId].enabled) revert HookAlreadyConfigured();
// Decode config (now includes threshold from deployer)
(uint16 buyTaxBps, uint16 sellTaxBps, uint256 threshold) = abi.decode(config, (uint16, uint16, uint256));
// Validate tax rates
if (buyTaxBps > MAX_TAX_BPS) revert InvalidTaxRate();
if (sellTaxBps > MAX_TAX_BPS) revert InvalidTaxRate();
// Validate threshold (0.01 ETH to 1 ETH)
if (threshold < MIN_THRESHOLD || threshold > MAX_THRESHOLD) revert InvalidThreshold();
taxConfigs[poolId] = TaxConfig({
buyTaxBps: buyTaxBps,
sellTaxBps: sellTaxBps,
platformFeeBps: uint16(defaultPlatformFeeBps), // FROZEN at deployment
threshold: threshold, // FROZEN at deployment (deployer's choice)
accumulated: 0,
tokenAddress: tokenAddress,
enabled: true
});
emit HookConfigured(poolId, tokenAddress, buyTaxBps, sellTaxBps);
}
function getPoolId(PoolKey calldata key) external pure override returns (bytes32) {
return _getPoolId(key);
}
function isConfigured(bytes32 poolId) external view override returns (bool) {
return taxConfigs[poolId].enabled;
}
// ============================================================
// ADMIN FUNCTIONS
// ============================================================
function setController(address newController) external {
if (msg.sender != controller) revert NotController();
if (newController == address(0)) revert InvalidReceiver();
controller = newController;
}
function setFactory(address newFactory) external {
if (msg.sender != controller) revert NotController();
factory = newFactory;
}
function setPlatformFeeCollector(address newCollector) external {
if (msg.sender != controller) revert NotController();
if (newCollector == address(0)) revert InvalidReceiver();
address oldCollector = platformFeeCollector;
platformFeeCollector = newCollector;
emit PlatformFeeCollectorUpdated(oldCollector, newCollector);
}
/// @notice Set default platform fee for NEW tokens (existing tokens are frozen)
function setDefaultPlatformFeeBps(uint256 newPlatformFeeBps) external {
if (msg.sender != controller) revert NotController();
if (newPlatformFeeBps < MIN_PLATFORM_FEE_BPS || newPlatformFeeBps > MAX_PLATFORM_FEE_BPS) {
revert InvalidConfig(); // Must be between 20% and 50%
}
uint256 oldBps = defaultPlatformFeeBps;
defaultPlatformFeeBps = newPlatformFeeBps;
emit PlatformFeeBpsUpdated(oldBps, newPlatformFeeBps);
}
/**
* @notice Emergency withdrawal of ETH/WETH (controller only)
* @param withdrawETH If true, unwrap WETH to ETH before sending
* @dev Use only in emergencies - this will disrupt normal fee distribution
*/
function emergencyWithdraw(bool withdrawETH) external {
if (msg.sender != controller) revert NotController();
uint256 wethBalance = IERC20(weth).balanceOf(address(this));
uint256 ethBalance = address(this).balance;
if (wethBalance > 0) {
if (withdrawETH) {
// Unwrap WETH to ETH
IWETH(weth).withdraw(wethBalance);
ethBalance += wethBalance;
} else {
// Transfer WETH directly
IERC20(weth).safeTransfer(controller, wethBalance);
}
}
// Always transfer any ETH balance (could be from unwrap or stuck ETH)
if (ethBalance > 0) {
(bool success,) = payable(controller).call{value: ethBalance}("");
require(success, "ETH transfer failed");
}
emit EmergencyWithdraw(controller, wethBalance, ethBalance);
}
// ============================================================
// HOOK PERMISSIONS
// ============================================================
function getHookPermissions() external pure returns (Hooks.Permissions memory) {
return Hooks.Permissions({
beforeInitialize: false,
afterInitialize: false,
beforeAddLiquidity: false,
afterAddLiquidity: false,
beforeRemoveLiquidity: false,
afterRemoveLiquidity: false,
beforeSwap: true,
afterSwap: true,
beforeDonate: false,
afterDonate: false,
beforeSwapReturnDelta: true,
afterSwapReturnDelta: true,
afterAddLiquidityReturnDelta: false,
afterRemoveLiquidityReturnDelta: false
});
}
// ============================================================
// HOOK CALLBACKS
// ============================================================
function beforeInitialize(address, PoolKey calldata, uint160) external pure returns (bytes4) {
return IHooks.beforeInitialize.selector;
}
function afterInitialize(address, PoolKey calldata, uint160, int24) external pure returns (bytes4) {
return IHooks.afterInitialize.selector;
}
function beforeAddLiquidity(address, PoolKey calldata, ModifyLiquidityParams calldata, bytes calldata)
external pure returns (bytes4)
{
return IHooks.beforeAddLiquidity.selector;
}
function afterAddLiquidity(address, PoolKey calldata, ModifyLiquidityParams calldata, BalanceDelta, BalanceDelta, bytes calldata)
external pure returns (bytes4, BalanceDelta)
{
return (IHooks.afterAddLiquidity.selector, BalanceDelta.wrap(0));
}
function beforeRemoveLiquidity(address, PoolKey calldata, ModifyLiquidityParams calldata, bytes calldata)
external pure returns (bytes4)
{
return IHooks.beforeRemoveLiquidity.selector;
}
function afterRemoveLiquidity(address, PoolKey calldata, ModifyLiquidityParams calldata, BalanceDelta, BalanceDelta, bytes calldata)
external pure returns (bytes4, BalanceDelta)
{
return (IHooks.afterRemoveLiquidity.selector, BalanceDelta.wrap(0));
}
function beforeSwap(
address,
PoolKey calldata key,
SwapParams calldata params,
bytes calldata
) external returns (bytes4, BeforeSwapDelta, uint24) {
if (msg.sender != poolManager) revert Unauthorized();
bytes32 poolId = _getPoolId(key);
TaxConfig storage config = taxConfigs[poolId];
if (!config.enabled) {
return (IHooks.beforeSwap.selector, BeforeSwapDelta.wrap(0), 0);
}
address currency1Addr = Currency.unwrap(key.currency1);
bool wethIsCurrency1 = currency1Addr == weth;
bool isBuy;
if (wethIsCurrency1) {
isBuy = !params.zeroForOne;
} else {
isBuy = params.zeroForOne;
}
if (isBuy) {
uint16 taxBps = config.buyTaxBps;
if (taxBps == 0) {
return (IHooks.beforeSwap.selector, BeforeSwapDelta.wrap(0), 0);
}
uint256 wethAmount;
if (params.amountSpecified < 0) {
wethAmount = uint256(uint128(-int128(params.amountSpecified)));
} else {
wethAmount = uint256(uint128(int128(params.amountSpecified)));
}
uint256 feeAmount = (wethAmount * taxBps) / FEE_DENOMINATOR;
if (feeAmount > 0) {
Currency wethCurrency = wethIsCurrency1 ? key.currency1 : key.currency0;
IPoolManager(poolManager).take(wethCurrency, address(this), feeAmount);
config.accumulated += feeAmount;
emit TaxTaken(poolId, feeAmount, true);
bool exactInput = params.amountSpecified < 0;
int128 specifiedDelta = exactInput ? int128(uint128(feeAmount)) : int128(0);
int128 unspecifiedDelta = exactInput ? int128(0) : int128(uint128(feeAmount));
BeforeSwapDelta hookDelta = BeforeSwapDelta.wrap(
int256(int128(specifiedDelta)) << 128 | int256(int128(unspecifiedDelta))
);
return (IHooks.beforeSwap.selector, hookDelta, 0);
}
}
return (IHooks.beforeSwap.selector, BeforeSwapDelta.wrap(0), 0);
}
function afterSwap(
address,
PoolKey calldata key,
SwapParams calldata params,
BalanceDelta delta,
bytes calldata
) external returns (bytes4, int128) {
if (msg.sender != poolManager) revert Unauthorized();
bytes32 poolId = _getPoolId(key);
TaxConfig storage config = taxConfigs[poolId];
if (!config.enabled) {
return (IHooks.afterSwap.selector, 0);
}
address currency1Addr = Currency.unwrap(key.currency1);
bool wethIsCurrency1 = currency1Addr == weth;
bool isSell;
if (wethIsCurrency1) {
isSell = params.zeroForOne;
} else {
isSell = !params.zeroForOne;
}
int128 hookDelta = 0;
if (isSell && config.sellTaxBps > 0) {
int128 amount0 = int128(int256(BalanceDelta.unwrap(delta)) >> 128);
int128 amount1 = int128(int256(BalanceDelta.unwrap(delta)));
int128 wethDelta = wethIsCurrency1 ? amount1 : amount0;
uint256 wethOutput;
if (wethDelta > 0) {
wethOutput = uint256(uint128(wethDelta));
} else if (wethDelta < 0) {
wethOutput = uint256(uint128(-wethDelta));
} else {
wethOutput = 0;
}
if (wethOutput > 0) {
uint256 feeAmount = (wethOutput * config.sellTaxBps) / FEE_DENOMINATOR;
if (feeAmount > 0) {
Currency wethCurrency = wethIsCurrency1 ? key.currency1 : key.currency0;
IPoolManager(poolManager).take(wethCurrency, address(this), feeAmount);
config.accumulated += feeAmount;
emit TaxTaken(poolId, feeAmount, false);
hookDelta = int128(uint128(feeAmount));
}
}
}
if (config.accumulated >= config.threshold) {
emit ThresholdReached(poolId, config.accumulated);
if (!_buybackInProgress && gasleft() >= MIN_GAS_FOR_BUYBACK) {
emit AutoBuybackTriggered(poolId, gasleft());
_executeAutoBuyback(key, poolId, config);
} else if (_buybackInProgress) {
emit AutoBuybackSkipped(poolId, "reentrancy");
} else {
emit AutoBuybackSkipped(poolId, "insufficient gas");
}
}
return (IHooks.afterSwap.selector, hookDelta);
}
function beforeDonate(address, PoolKey calldata, uint256, uint256, bytes calldata)
external pure returns (bytes4)
{
return IHooks.beforeDonate.selector;
}
function afterDonate(address, PoolKey calldata, uint256, uint256, bytes calldata)
external pure returns (bytes4)
{
return IHooks.afterDonate.selector;
}
// ============================================================
// BUYBACK FUNCTIONS
// ============================================================
function _executeAutoBuyback(
PoolKey calldata key,
bytes32 poolId,
TaxConfig storage config
) internal {
_buybackInProgress = true;
uint256 wethBalance = IERC20(weth).balanceOf(address(this));
if (wethBalance == 0) {
_buybackInProgress = false;
return;
}
uint256 totalAmount = wethBalance < config.accumulated ? wethBalance : config.accumulated;
config.accumulated = config.accumulated > totalAmount ? config.accumulated - totalAmount : 0;
// Use per-token frozen platformFeeBps (not global default)
uint256 platformFee = (totalAmount * config.platformFeeBps) / FEE_DENOMINATOR;
uint256 buybackAmount = totalAmount - platformFee;
if (platformFee > 0 && platformFeeCollector != address(0)) {
// Unwrap WETH to ETH and send to platform
IWETH(weth).withdraw(platformFee);
(bool success, ) = payable(platformFeeCollector).call{value: platformFee}("");
require(success, "Platform fee transfer failed");
totalPlatformFees += platformFee;
emit PlatformFeeSent(poolId, platformFee, platformFeeCollector);
}
if (buybackAmount > 0) {
address currency1Addr = Currency.unwrap(key.currency1);
bool wethIsCurrency1 = currency1Addr == weth;
Currency wethCurrency = wethIsCurrency1 ? key.currency1 : key.currency0;
Currency tokenCurrency = wethIsCurrency1 ? key.currency0 : key.currency1;
bool zeroForOne = !wethIsCurrency1;
SwapParams memory swapParams = SwapParams({
zeroForOne: zeroForOne,
amountSpecified: -int256(buybackAmount),
sqrtPriceLimitX96: zeroForOne ? 4295128740 : 1461446703485210103287273052203988822378723970341
});
BalanceDelta swapDelta = IPoolManager(poolManager).swap(key, swapParams, "");
int128 amount0 = int128(int256(BalanceDelta.unwrap(swapDelta)) >> 128);
int128 amount1 = int128(int256(BalanceDelta.unwrap(swapDelta)));
int128 tokenDelta = wethIsCurrency1 ? amount0 : amount1;
uint256 tokensReceived = tokenDelta > 0 ? uint256(uint128(tokenDelta)) : 0;
IPoolManager(poolManager).sync(wethCurrency);
IERC20(weth).safeTransfer(poolManager, buybackAmount);
IPoolManager(poolManager).settle();
if (tokensReceived > 0) {
IPoolManager(poolManager).take(tokenCurrency, address(this), tokensReceived);
// Actually burn tokens (reduces totalSupply on-chain)
IERC20Burnable(config.tokenAddress).burn(tokensReceived);
totalBurned += tokensReceived;
}
totalBuybacks++;
emit BuybackExecuted(poolId, buybackAmount, tokensReceived);
}
_buybackInProgress = false;
}
function executeBuyback(PoolKey calldata key) external {
require(!_buybackInProgress, "Buyback in progress");
_buybackInProgress = true;
bytes32 poolId = _getPoolId(key);
TaxConfig storage config = taxConfigs[poolId];
require(config.enabled, "Not enabled");
require(config.accumulated >= config.threshold, "Threshold not reached");
uint256 wethBalance = IERC20(weth).balanceOf(address(this));
require(wethBalance > 0, "No WETH to buyback");
uint256 totalAmount = wethBalance < config.accumulated ? wethBalance : config.accumulated;
config.accumulated = config.accumulated > totalAmount ? config.accumulated - totalAmount : 0;
// Use per-token frozen platformFeeBps (not global default)
uint256 platformFee = (totalAmount * config.platformFeeBps) / FEE_DENOMINATOR;
uint256 buybackAmount = totalAmount - platformFee;
if (platformFee > 0 && platformFeeCollector != address(0)) {
// Unwrap WETH to ETH and send to platform
IWETH(weth).withdraw(platformFee);
(bool success, ) = payable(platformFeeCollector).call{value: platformFee}("");
require(success, "Platform fee transfer failed");
totalPlatformFees += platformFee;
emit PlatformFeeSent(poolId, platformFee, platformFeeCollector);
}
if (buybackAmount > 0) {
IERC20(weth).approve(poolManager, buybackAmount);
bytes memory data = abi.encode(key, buybackAmount, config.tokenAddress, poolId);
IPoolManager(poolManager).unlock(data);
}
_buybackInProgress = false;
}
function unlockCallback(bytes calldata data) external override returns (bytes memory) {
require(msg.sender == poolManager, "Not PoolManager");
(PoolKey memory key, uint256 buybackAmount, address tokenAddress, bytes32 poolId) =
abi.decode(data, (PoolKey, uint256, address, bytes32));
address currency1Addr = Currency.unwrap(key.currency1);
bool wethIsCurrency1 = currency1Addr == weth;
Currency wethCurrency = wethIsCurrency1 ? key.currency1 : key.currency0;
Currency tokenCurrency = wethIsCurrency1 ? key.currency0 : key.currency1;
bool zeroForOne = !wethIsCurrency1;
SwapParams memory swapParams = SwapParams({
zeroForOne: zeroForOne,
amountSpecified: -int256(buybackAmount),
sqrtPriceLimitX96: zeroForOne ? 4295128740 : 1461446703485210103287273052203988822378723970341
});
BalanceDelta swapDelta = IPoolManager(poolManager).swap(key, swapParams, "");
int128 amount0 = int128(int256(BalanceDelta.unwrap(swapDelta)) >> 128);
int128 amount1 = int128(int256(BalanceDelta.unwrap(swapDelta)));
int128 tokenDelta = wethIsCurrency1 ? amount0 : amount1;
uint256 tokensReceived = tokenDelta > 0 ? uint256(uint128(tokenDelta)) : 0;
IPoolManager(poolManager).sync(wethCurrency);
IERC20(weth).safeTransfer(poolManager, buybackAmount);
IPoolManager(poolManager).settle();
if (tokensReceived > 0) {
IPoolManager(poolManager).take(tokenCurrency, address(this), tokensReceived);
// Actually burn tokens (reduces totalSupply on-chain)
IERC20Burnable(tokenAddress).burn(tokensReceived);
totalBurned += tokensReceived;
}
totalBuybacks++;
emit BuybackExecuted(poolId, buybackAmount, tokensReceived);
return "";
}
// ============================================================
// VIEW FUNCTIONS
// ============================================================
function _getPoolId(PoolKey calldata key) internal pure returns (bytes32) {
return keccak256(abi.encode(
Currency.unwrap(key.currency0),
Currency.unwrap(key.currency1),
key.fee,
key.tickSpacing,
address(key.hooks)
));
}
function getAccumulated(bytes32 poolId) external view returns (uint256) {
return taxConfigs[poolId].accumulated;
}
function isThresholdReached(bytes32 poolId) external view returns (bool) {
return taxConfigs[poolId].accumulated >= taxConfigs[poolId].threshold;
}
function getWethBalance() external view returns (uint256) {
return IERC20(weth).balanceOf(address(this));
}
receive() external payable {}
}
// ============================================================
// HOOKS LIBRARY
// ============================================================
library Hooks {
struct Permissions {
bool beforeInitialize;
bool afterInitialize;
bool beforeAddLiquidity;
bool afterAddLiquidity;
bool beforeRemoveLiquidity;
bool afterRemoveLiquidity;
bool beforeSwap;
bool afterSwap;
bool beforeDonate;
bool afterDonate;
bool beforeSwapReturnDelta;
bool afterSwapReturnDelta;
bool afterAddLiquidityReturnDelta;
bool afterRemoveLiquidityReturnDelta;
}
}
@openzeppelin/contracts/interfaces/IERC1363.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1363.sol)
pragma solidity >=0.6.2;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
@openzeppelin/contracts/interfaces/IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC165.sol)
pragma solidity >=0.4.16;
import {IERC165} from "../utils/introspection/IERC165.sol";
@openzeppelin/contracts/interfaces/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20.sol)
pragma solidity >=0.4.16;
import {IERC20} from "../token/ERC20/IERC20.sol";
@openzeppelin/contracts/token/ERC20/IERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
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);
}
@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transferFrom, (from, to, 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.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @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.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @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 {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @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 silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}
@openzeppelin/contracts/utils/introspection/IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
contracts/errors/Errors.sol
// SPDX-License-Identifier: MIT
// Qian Exchange - https://qian.ag
pragma solidity ^0.8.24;
// Factory Errors
error BadRouterConfig();
error DeployDisabled();
error InsufficientDeployFee();
error InvalidFeeVault();
error InvalidConfig();
error InvalidReceiver();
error InvalidTickRange();
error NotController();
error Unauthorized();
error TransferFailed();
error MintingDisabled();
error InsufficientTokenBalance(uint256 required, uint256 available);
// Hook Registry Errors
error HookNotApproved();
error HookAlreadyConfigured();
error InvalidTaxRate();
error InvalidThreshold();
error InvalidPoolFee();
contracts/interfaces/IConfigurableHook.sol
// SPDX-License-Identifier: MIT
// Qian Exchange - https://qian.ag
pragma solidity ^0.8.24;
import "./IPoolManager.sol";
/**
* @title IConfigurableHook
* @notice Generic interface for hooks that can be configured by the factory
* @dev All hooks that want to be auto-configured by QianDTMFactoryv4 must implement this interface
*
* This allows the factory to remain hook-agnostic - new hooks can be added
* without modifying the factory contract. Each hook:
* 1. Defines its own config format (decoded from bytes)
* 2. Validates its own constraints (tax limits, thresholds, etc.)
* 3. Stores per-pool configuration
*
* Example config encoding:
* - AutoBuyBurnHook: abi.encode(uint16 buyTaxBps, uint16 sellTaxBps, uint256 threshold)
* - TaxmanHook: abi.encode(uint16 buyTaxBps, uint16 sellTaxBps)
* - FutureHook: abi.encode(param1, param2, param3, ...)
*/
interface IConfigurableHook {
/**
* @notice Configure the hook for a newly deployed token's pool
* @param poolId The pool identifier (keccak256 of PoolKey)
* @param tokenAddress The token address being configured
* @param config Hook-specific configuration data (abi.encoded)
* @dev Called by factory during deployCoin(). Must validate and store config.
* Should revert if already configured (immutability) or invalid params.
*/
function configureHook(
bytes32 poolId,
address tokenAddress,
bytes calldata config
) external;
/**
* @notice Get the pool ID from a PoolKey
* @param key The pool key
* @return poolId The computed pool identifier
*/
function getPoolId(PoolKey calldata key) external pure returns (bytes32);
/**
* @notice Check if a pool has been configured for this hook
* @param poolId The pool identifier
* @return True if the pool is configured and enabled
*/
function isConfigured(bytes32 poolId) external view returns (bool);
}
contracts/interfaces/ICurrency.sol
// SPDX-License-Identifier: MIT
// Qian Exchange - https://qian.ag
pragma solidity ^0.8.24;
/// @notice Currency type for Uniswap V4
/// Wraps an address to represent a token or native ETH
type Currency is address;
/// @notice Currency library for V4
library CurrencyLibrary {
/// @notice Wrap an address as Currency
function wrap(address token) internal pure returns (Currency) {
return Currency.wrap(token);
}
/// @notice Unwrap Currency to address
function unwrap(Currency currency) internal pure returns (address) {
return Currency.unwrap(currency);
}
/// @notice Native ETH currency
function native() internal pure returns (Currency) {
return Currency.wrap(address(0));
}
/// @notice Check if currency is native ETH
function isNative(Currency currency) internal pure returns (bool) {
return Currency.unwrap(currency) == address(0);
}
}
contracts/interfaces/IHooks.sol
// SPDX-License-Identifier: MIT
// Qian Exchange - https://qian.ag
pragma solidity ^0.8.24;
import "./IPoolManager.sol";
/// @notice Swap parameters for hook callbacks
struct SwapParams {
bool zeroForOne;
int256 amountSpecified;
uint160 sqrtPriceLimitX96;
}
/// @notice Uniswap V4 Hooks interface
/// Hooks can implement various callbacks to customize pool behavior
interface IHooks {
/// @notice Called before a pool is initialized
function beforeInitialize(address sender, PoolKey calldata key, uint160 sqrtPriceX96) external returns (bytes4);
/// @notice Called after a pool is initialized
function afterInitialize(address sender, PoolKey calldata key, uint160 sqrtPriceX96, int24 tick) external returns (bytes4);
/// @notice Called before a swap
function beforeSwap(address sender, PoolKey calldata key, SwapParams calldata params, bytes calldata hookData) external returns (bytes4, BeforeSwapDelta, uint24);
/// @notice Called after a swap
function afterSwap(address sender, PoolKey calldata key, SwapParams calldata params, BalanceDelta delta, bytes calldata hookData) external returns (bytes4, int128);
/// @notice Called before liquidity is added
function beforeAddLiquidity(address sender, PoolKey calldata key, ModifyLiquidityParams calldata params, bytes calldata hookData) external returns (bytes4);
/// @notice Called after liquidity is added
function afterAddLiquidity(address sender, PoolKey calldata key, ModifyLiquidityParams calldata params, BalanceDelta delta, BalanceDelta feesAccrued, bytes calldata hookData) external returns (bytes4, BalanceDelta);
/// @notice Called before liquidity is removed
function beforeRemoveLiquidity(address sender, PoolKey calldata key, ModifyLiquidityParams calldata params, bytes calldata hookData) external returns (bytes4);
/// @notice Called after liquidity is removed
function afterRemoveLiquidity(address sender, PoolKey calldata key, ModifyLiquidityParams calldata params, BalanceDelta delta, BalanceDelta feesAccrued, bytes calldata hookData) external returns (bytes4, BalanceDelta);
/// @notice Called before a donate
function beforeDonate(address sender, PoolKey calldata key, uint256 amount0, uint256 amount1, bytes calldata hookData) external returns (bytes4);
/// @notice Called after a donate
function afterDonate(address sender, PoolKey calldata key, uint256 amount0, uint256 amount1, bytes calldata hookData) external returns (bytes4);
}
/// @notice Before swap delta type - encodes (specifiedDelta, unspecifiedDelta)
type BeforeSwapDelta is int256;
contracts/interfaces/IPoolManager.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;
import "./ICurrency.sol";
import "./IHooks.sol";
// BalanceDelta is a packed int256 where:
// - Upper 128 bits = amount0 (int128)
// - Lower 128 bits = amount1 (int128)
type BalanceDelta is int256;
/// @notice Library for getting amount0/amount1 from BalanceDelta
library BalanceDeltaLibrary {
function amount0(BalanceDelta balanceDelta) internal pure returns (int128 _amount0) {
assembly ("memory-safe") {
_amount0 := sar(128, balanceDelta)
}
}
function amount1(BalanceDelta balanceDelta) internal pure returns (int128 _amount1) {
assembly ("memory-safe") {
_amount1 := signextend(15, balanceDelta)
}
}
}
/// @notice PoolKey identifies a V4 pool
struct PoolKey {
Currency currency0;
Currency currency1;
uint24 fee;
int24 tickSpacing;
IHooks hooks;
}
/// @notice Parameters for modifyLiquidity
struct ModifyLiquidityParams {
int24 tickLower;
int24 tickUpper;
int256 liquidityDelta;
bytes32 salt;
}
/// @notice Interface for Uniswap V4 PoolManager
interface IPoolManager {
/// @notice Initialize the state for a given pool
function initialize(PoolKey memory key, uint160 sqrtPriceX96) external returns (int24 tick);
/// @notice Modify the liquidity for the given pool
function modifyLiquidity(PoolKey memory key, ModifyLiquidityParams memory params, bytes calldata hookData)
external
returns (BalanceDelta callerDelta, BalanceDelta feesAccrued);
/// @notice All interactions on the contract that account deltas require unlocking
function unlock(bytes calldata data) external returns (bytes memory);
/// @notice Sync the currency to its current balance in the PoolManager
function sync(Currency currency) external;
/// @notice Settle the currency, paying what is owed
function settle() external payable returns (uint256 paid);
/// @notice Take currency from the PoolManager
/// @param currency The currency to take
/// @param to The address to receive the currency
/// @param amount The amount to take
function take(Currency currency, address to, uint256 amount) external;
/// @notice Execute a swap
/// @param key The pool key
/// @param params The swap parameters
/// @param hookData Any data to be passed to hooks
function swap(PoolKey memory key, SwapParams memory params, bytes calldata hookData)
external
returns (BalanceDelta swapDelta);
}
contracts/interfaces/IUnlockCallback.sol
// SPDX-License-Identifier: MIT
// Qian Exchange - https://qian.ag
pragma solidity ^0.8.24;
/// @notice Interface for the callback executed when an address unlocks the pool manager
interface IUnlockCallback {
/// @notice Called by the pool manager on `msg.sender` when the manager is unlocked
/// @param data The data that was passed to the call to unlock
/// @return Any data that you want to be returned from the unlock call
function unlockCallback(bytes calldata data) external returns (bytes memory);
}
contracts/interfaces/IWETH.sol
// SPDX-License-Identifier: MIT
// Qian Exchange - https://qian.ag
pragma solidity ^0.8.24;
interface IWETH {
function deposit() external payable;
function withdraw(uint256 amount) external;
function transfer(address to, uint256 amount) external returns (bool);
function transferFrom(address from, address to, uint256 amount) external returns (bool);
function approve(address spender, uint256 amount) external returns (bool);
function balanceOf(address account) external view returns (uint256);
}
Compiler settingsShow
{
"viaIR": true,
"optimizer": {
"runs": 1,
"enabled": true
},
"evmVersion": "paris"
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.