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

NameTypeDescription

_g8keepFactoryConfiguration

address

The address of the factory configuration contract to retrieve configuration 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

NameTypeDescription

_initialLiquidity

uint256

Amount of paired token to supply as liquidity in the LP.

_name

string

Name of the token being deployed.

_symbol

string

Symbol of the token being deployed.

_totalSupply

uint256

Total supply to be minted during deployment.

_treasuryWallet

address

Address that will receive deployer buy and sell fees.

_buyFee

uint16

Buy fee in BPS.

_sellFee

uint16

Sell fee in BPS.

_pairedToken

address

Address of the token to pair with in the LP.

_deployReserve

uint256

Amount of total supply in BPS to allocate to deployer.

_deployVestTime

uint256

Time in seconds to vest the deployer's allocation.

_snipeProtectionSeconds

uint256

Amount of time in seconds that snipe protection will be enabled.

_heavySnipeSeconds

uint256

Amount of time in seconds that heavy snipe penalty is enabled.

_heavySnipeExponent

uint256

Starting exponent for heavy snipe penalty.

_tokenSalt

bytes32

Salt for token deployment to generate a deterministic address.

setPairedTokenSettings

Admin function to configure a paired token.

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

Parameters

NameTypeDescription

pairedToken

address

Address of the paired token to configure.

allowed

bool

True if the token is allowed as a paired token, false if not.

minimumLiquidity

uint256

Minimum amount of token that may be supplied as initial liquidity.

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

NameTypeDescription

pairedToken

address

Address of the paired token to configure.

allowed

bool

True if the token is allowed as a paired token, false if not.

minimumLiquidity

uint256

Minimum amount of token that may be supplied as initial liquidity.

allowanceAmount

uint256

Amount to set for the allowance to the Uniswap Router.

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

NameTypeDescription

_maxBuyFee

uint16

Maximum buy fee in BPS.

_maxSellFee

uint16

Maximum sell fee in BPS.

_minimumDeployVestTime

uint24

Minimum time in seconds that a deployer tokens must vest over.

_minimumSnipeProtectionSeconds

uint24

Minimum time in seconds for snipe protection to be enabled.

_maximumSnipeProtectionSeconds

uint24

Maximum time in seconds for snipe protection to be enabled.

_minimumHeavySnipeProtectionSeconds

uint24

Minimum time in seconds for heavy snipe protection to be enabled.

_maximumHeavySnipeProtectionSeconds

uint24

Maximum time in seconds for heavy snipe protection to be enabled.

_minimumHeavySnipeExponent

uint8

Minimum exponent penalty during heavy snipe protection.

_maximumHeavySnipeExponent

uint8

Maximum exponent penalty during heavy snipe protection.

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

NameTypeDescription

_g8keepFee

uint16

Fee in BPS to assess on token trades.

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

NameTypeDescription

_g8keepInitialLiquidityFee

uint16

Fee in BPS to assess on initial liquidity.

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

NameTypeDescription

_g8keepTokenVesting

address

Address of the g8keep token vesting contract.

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

NameTypeDescription

_g8keepFeeWallet

address

Address of the g8keep fee wallet.

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

NameTypeDescription

_penaltyReceiver

address

Address of the penalty receiver.

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

NameTypeDescription

tokenAddresses

address[]

Array of tokens to set approvals on.

approved

bool[]

Array specifying whether to approve or revoke approval.

approvalRevokeAmount

uint256

Amount to use when revoking approvals.

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

NameTypeDescription

sellParameters

TokenSale[]

Array of token sale parameters to execute on the Uniswap router.

deadline

uint256

Timestamp that the transaction must execute by or revert.

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

NameTypeDescription

tokenAddress

address

Address of the token to withdraw.

to

address

Address to withdraw the token to.

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

NameTypeDescription

tokenAddress

address

Address of the token to withdraw.

to

address

Address to withdraw the token to.

amount

uint256

Amount of the token to withdraw.

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

NameTypeDescription

to

address

Address to withdraw the token to.

_setPairedTokenSettings

Internal function for setPairedTokenSettings and setPairedTokenSettingsWithAllowance.

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

Parameters

NameTypeDescription

pairedToken

address

Address of the paired token to configure.

allowed

bool

True if the token is allowed as a paired token, false if not.

minimumLiquidity

uint256

Minimum amount of token that may be supplied as initial liquidity.

allowanceAmount

uint256

Amount to set for the allowance to the Uniswap Router.

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