g8keepFactory

g8keepFactory

Inherits: IG8keepFactory, Ownable

Factory for managing deployment parameters, deploying g8keep token contracts, locking initial liquidity, and managing token fees.

State Variables

WETH

Wrapped native token contract for token deployments using native currency.

address public immutable WETH;

UNISWAP_V2_ROUTER

Uniswap V2 router address for the chain.

address public immutable UNISWAP_V2_ROUTER;

g8keepTokenVesting

Vesting contract to be used when deployer tokens are subject to vesting restrictions.

address public g8keepTokenVesting;

g8keepFeeWallet

Fee wallet to receive initial liquidity fees.

address public g8keepFeeWallet;

penaltyReceiver

Address that will receive penalty tax tokens.

address public penaltyReceiver;

g8keepFee

Fee in BPS assessed on token trades, paid to g8keep. Initial value: 1.0%

uint16 public g8keepFee = 100;

g8keepInitialLiquidityFee

Fee in BPS assessed on initial liquidity supplied. Initial value: 2.0%

uint16 public g8keepInitialLiquidityFee = 200;

maxBuyFee

Maximum buy fee in BPS assessed on token trades, paid to token deployer. Initial value: 5.0%

uint16 public maxBuyFee = 500;

maxSellFee

Maximum sell fee in BPS assessed on token trades, paid to token deployer. Initial value: 5.0%

uint16 public maxSellFee = 500;

minimumDeployVestTime

Minimum time in seconds that a deployer's share of tokens must be vested over. Initial value: 1 day

uint24 public minimumDeployVestTime = 1 days;

minimumSnipeProtectionSeconds

Minimum time in seconds that a deployed token must have snipe protection enabled.

uint24 public minimumSnipeProtectionSeconds = 30 minutes;

maximumSnipeProtectionSeconds

Maximum time in seconds that a deployed token may have snipe protection enabled.

uint24 public maximumSnipeProtectionSeconds = 30 days;

minimumHeavySnipeProtectionSeconds

Minimum time in seconds that a deployed token must have heavy snipe protection enabled.

uint24 public minimumHeavySnipeProtectionSeconds = 30 minutes;

maximumHeavySnipeProtectionSeconds

Maximum time in seconds that a deployed token may have heavy snipe protection enabled.

uint24 public maximumHeavySnipeProtectionSeconds = 1 days;

minimumHeavySnipeExponent

Minimum exponent that a deployed token must have for heavy snipe penalties.

uint8 public minimumHeavySnipeExponent = 20;

maximumHeavySnipeExponent

Maximum exponent that a deployed token may have for heavy snipe penalties.

uint8 public maximumHeavySnipeExponent = 60;

MAX_SETTING_G8KEEP_FEE

Guardrail for g8keepFee to prevent it from being set over 100 BPS.

uint16 private constant MAX_SETTING_G8KEEP_FEE = 100;

MAX_SETTING_G8KEEP_INITIAL_LIQUIDITY_FEE

Guardrail for g8keepInitialLiquidityFee to prevent it from being set over 200 BPS.

uint16 private constant MAX_SETTING_G8KEEP_INITIAL_LIQUIDITY_FEE = 200;

MAX_SETTING_BUY_FEE

Guardrail for maxBuyFee to prevent it from being set over 500 BPS.

uint16 private constant MAX_SETTING_BUY_FEE = 500;

MAX_SETTING_SELL_FEE

Guardrail for maxSellFee to prevent it from being set over 500 BPS.

uint16 private constant MAX_SETTING_SELL_FEE = 500;

MAX_SETTING_MINIMUM_DEPLOY_VEST_TIME

Guardrail for minimumDeployVestTime to prevent it from being set over 90 days.

uint40 private constant MAX_SETTING_MINIMUM_DEPLOY_VEST_TIME = 90 days;

MAX_SETTING_MINIMUM_SNIPE_PROTECTION_SECONDS

Guardrail for minimumSnipeProtectionSeconds to prevent it from being set over 7 days.

uint40 private constant MAX_SETTING_MINIMUM_SNIPE_PROTECTION_SECONDS = 7 days;

MAX_SETTING_MAXIMUM_SNIPE_PROTECTION_SECONDS

Guardrail for maximumSnipeProtectionSeconds to prevent it from being set over 365 days.

uint40 private constant MAX_SETTING_MAXIMUM_SNIPE_PROTECTION_SECONDS = 365 days;

MAX_SETTING_MINIMUM_HEAVY_SNIPE_PROTECTION_SECONDS

Guardrail for minimumHeavySnipeProtectionSeconds to prevent it from being set over 1 days.

uint40 private constant MAX_SETTING_MINIMUM_HEAVY_SNIPE_PROTECTION_SECONDS = 1 days;

MAX_SETTING_MAXIMUM_HEAVY_SNIPE_PROTECTION_SECONDS

Guardrail for maximumHeavySnipeProtectionSeconds to prevent it from being set over 5 days.

uint40 private constant MAX_SETTING_MAXIMUM_HEAVY_SNIPE_PROTECTION_SECONDS = 5 days;

MIN_SETTING_MINIMUM_HEAVY_SNIPE_EXPONENT

Guardrail for minimumHeavySnipeExponent to prevent it from being set under 2.

uint8 private constant MIN_SETTING_MINIMUM_HEAVY_SNIPE_EXPONENT = 2;

MAX_SETTING_MINIMUM_HEAVY_SNIPE_EXPONENT

Guardrail for minimumHeavySnipeExponent to prevent it from being set over 20.

uint8 private constant MAX_SETTING_MINIMUM_HEAVY_SNIPE_EXPONENT = 20;

MAX_SETTING_MAXIMUM_HEAVY_SNIPE_EXPONENT

Guardrail for maximumHeavySnipeExponent to prevent it from being set over 100.

uint8 private constant MAX_SETTING_MAXIMUM_HEAVY_SNIPE_EXPONENT = 100;

BPS

Constant value for BPS.

uint16 private constant BPS = 10_000;

allowedPairs

Mapping to flag a token address as an allowed pair token for g8keep token deployments.

mapping(address => bool) public allowedPairs;

pairedTokenMinimumLiquidity

Mapping of the minimum initial liquidity to be provided for a paired token.

mapping(address => uint256) public pairedTokenMinimumLiquidity;

lockedTokens

Mapping of tokens that are locked to prevent sale or withdrawal.

mapping(address => bool) private lockedTokens;

Functions

constructor

Constructs the g8keepFactory contract.

Initialization parameters are retrieved from a configuration contract so that the g8keepFactory may be deterministically deployed on EVM chains at the same

address.

constructor(address _g8keepFactoryConfiguration);

Parameters

deployToken

Deploys a g8keepToken contract, creates and funds the LP, locks initial liquidity.

Parameters must be within ranges defined by the factory settings.

Token salt value must be calculated to generate a token deployment address that is greater than the _pairedToken address.

function deployToken(
    uint256 _initialLiquidity,
    string memory _name,
    string memory _symbol,
    uint256 _totalSupply,
    address _treasuryWallet,
    uint16 _buyFee,
    uint16 _sellFee,
    address _pairedToken,
    uint256 _deployReserve,
    uint256 _deployVestTime,
    uint256 _snipeProtectionSeconds,
    uint256 _heavySnipeSeconds,
    uint256 _heavySnipeExponent,
    bytes32 _tokenSalt
) external payable returns (address _tokenAddress);

Parameters

setPairedTokenSettings

Admin function to configure a paired token.

function setPairedTokenSettings(address pairedToken, bool allowed, uint256 minimumLiquidity) external onlyOwner;

Parameters

setPairedTokenSettingsWithAllowance

Admin function to configure a paired token with a specific allowance amount.

Used for certain ERC20 tokens that have unusual approval methods.

function setPairedTokenSettingsWithAllowance(
    address pairedToken,
    bool allowed,
    uint256 minimumLiquidity,
    uint256 allowanceAmount
) external onlyOwner;

Parameters

setDeploymentSettings

Admin function to configure deployment parameters.

Settings parameters must be within the constant guardrails defined.

function setDeploymentSettings(
    uint16 _maxBuyFee,
    uint16 _maxSellFee,
    uint24 _minimumDeployVestTime,
    uint24 _minimumSnipeProtectionSeconds,
    uint24 _maximumSnipeProtectionSeconds,
    uint24 _minimumHeavySnipeProtectionSeconds,
    uint24 _maximumHeavySnipeProtectionSeconds,
    uint8 _minimumHeavySnipeExponent,
    uint8 _maximumHeavySnipeExponent
) external onlyOwner;

Parameters

setG8keepFee

Admin function to set the g8keep fee that will be assessed on token trades.

Fee must be less than the constant guardrail settings.

function setG8keepFee(uint16 _g8keepFee) external onlyOwner;

Parameters

setG8keepInitialLiquidityFee

Admin function to set the g8keep fee that will be assessed on initial liquidity.

Fee must be less than the constant guardrail settings.

function setG8keepInitialLiquidityFee(uint16 _g8keepInitialLiquidityFee) external onlyOwner;

Parameters

setG8keepTokenVestingAddress

Admin function to set the g8keep vesting contract address.

The vesting contract address may only be set to the zero address when minimum vesting time is set to zero.

function setG8keepTokenVestingAddress(address _g8keepTokenVesting) external onlyOwner;

Parameters

setG8keepFeeWallet

Admin function to set the g8keep fee wallet to receive initial liquidity fees.

The fee wallet cannot be set to the zero address.

function setG8keepFeeWallet(address _g8keepFeeWallet) external onlyOwner;

Parameters

setPenaltyReceiver

Admin function to set the penalty receiver address.

The penalty receiver cannot be set to the zero address.

function setPenaltyReceiver(address _penaltyReceiver) external onlyOwner;

Parameters

setApprovalToUniswapRouter

Admin function to update approvals to the Uniswap router.

Used to update or revoke approvals in case there is an unusual approval mechanism on a paired ERC20 token.

function setApprovalToUniswapRouter(
    address[] calldata tokenAddresses,
    bool[] calldata approved,
    uint256 approvalRevokeAmount
) external onlyOwner;

Parameters

sellTokens

Admin function to sell the tokens collected as fees on the g8keep platform.

Locked tokens supplied in sellParameters will be skipped without reverting.

function sellTokens(TokenSale[] calldata sellParameters, uint256 deadline) external onlyOwner;

Parameters

withdrawToken

Admin function to withdraw a token that is held by the factory contract.

Withdrawing a locked token will revert the transaction.

Will withdraw the entire balance of the token.

function withdrawToken(address tokenAddress, address to) external onlyOwner;

Parameters

withdrawToken

Admin function to withdraw a token that is held by the factory contract.

Withdrawing a locked token will revert the transaction.

Will withdraw the specified amount of token.

function withdrawToken(address tokenAddress, address to, uint256 amount) external onlyOwner;

Parameters

withdrawETH

Admin function to withdraw native token that is held by the factory contract.

Will withdraw the entire balance.

function withdrawETH(address to) external onlyOwner;

Parameters

_setPairedTokenSettings

Internal function for setPairedTokenSettings and setPairedTokenSettingsWithAllowance.

function _setPairedTokenSettings(address pairedToken, bool allowed, uint256 minimumLiquidity, uint256 allowanceAmount)
    internal;

Parameters

Events

TokenDeployed

Emitted when a token is deployed.

event TokenDeployed(address indexed token, address indexed pair, address indexed deployer, string symbol);

DeploymentSettingsUpdated

Emitted when the g8keepFactory owner updates deployment settings.

event DeploymentSettingsUpdated(
    uint16 maxBuyFee,
    uint16 maxSellFee,
    uint24 minimumDeployVestTime,
    uint24 minimumSnipeProtectionSeconds,
    uint24 maximumSnipeProtectionSeconds,
    uint24 minimumHeavySnipeProtectionSeconds,
    uint24 maximumHeavySnipeProtectionSeconds,
    uint8 minimumHeavySnipeExponent,
    uint8 maximumHeavySnipeExponent
);

PairedTokenSettingsUpdated

Emitted when the g8keepFactory owner updates a paired token settings.

event PairedTokenSettingsUpdated(address indexed pairedToken, bool allowed, uint256 minimumLiquidity);

PenaltyReceiverUpdated

Emitted when the g8keepFactory owner updates a penalty receiver.

event PenaltyReceiverUpdated(address indexed penaltyReceiver);

Errors

ArrayLengthMismatch

Thrown when arrays must match in length and they do not.

error ArrayLengthMismatch();

DeadlinePassed

Thrown when selling tokens and the deadline for the sale has passed.

error DeadlinePassed();

FailedToDepositWETH

Thrown when the deposit to the WETH contract for initial liquidity fails.

error FailedToDepositWETH();

InvalidDeploymentParameters

Thrown when deploying a token and the parameters are not compliant with deployment settings.

error InvalidDeploymentParameters();

InvalidSettings

Thrown when the g8keepFactory owner is updating deployment settings and they are not compliant with the constant guardrails or when setting a penalty receiver that is the current receiver.

error InvalidSettings();

NotEnoughInitialLiquidity

Thrown when deploying a token and the initial liquidity is less than the minimum required.

error NotEnoughInitialLiquidity();

PairNotAllowed

Thrown when deploying a token with a paired token that is not allowed.

error PairNotAllowed();

TokenLocked

Thrown when attempting to withdraw a token that is locked.

error TokenLocked();

ValueNotAllowedForNonWETHPairs

Thrown when native value is sent with a token deployment that does not use wrapped native.

error ValueNotAllowedForNonWETHPairs();

ValueSentNotValid

Thrown when deploying a token and the value sent exceeds the initial liquidity specified.

error ValueSentNotValid();

WithdrawalFailed

Thrown when withdrawing native token from the contract and the withdrawal fails.

error WithdrawalFailed();

ZeroAddress

Thrown when a supplied address that must be non-zero is zero.

error ZeroAddress();

Structs

TokenSale

Struct used for defining token sale parameters.

struct TokenSale {
    address tokenAddress;
    uint256 amountToSell;
    uint256 amountOutMin;
    address recipient;
}

Last updated