Contracts
Tokencreator

Token Creator Contract Documentation

Description

The Token Creator contract is responsible for creating and managing standard and liquidity tokens. It provides functions for creating new tokens, setting the contract owner, withdrawing funds, initializing fees, and retrieving token balances.

Dependencies

This contract relies on the following external dependencies:

  • OpenZeppelin Contracts: IERC20, IERC20Metadata, Context, Address

Structures

feeInfo

struct feeInfo {
    uint256 normal;
    uint256 mint;
    uint256 burn;
    uint256 pause;
    uint256 blacklist;
    uint256 deflation;
}

Represents the fee information for different operations.

  • normal: The fee for normal operations.
  • mint: The fee for minting tokens.
  • burn: The fee for burning tokens.
  • pause: The fee for pausing operations.
  • blacklist: The fee for blacklisting addresses.
  • deflation: The fee for deflationary operations.

State Variables

owner

address public owner;

The address of the contract owner.

router_address

address router_address;

The address of the router contract.

tokens

mapping(address => address[]) tokens;

A mapping of creator addresses to their corresponding token addresses.

fee

feeInfo public fee;

The fee information for different operations.

standardTokenFactory

StandardTokenFactory internal standardTokenFactory;

An instance of the StandardTokenFactory contract.

liquidityTokenFactory

LiquidityTokenFactory internal liquidityTokenFactory;

An instance of the LiquidityTokenFactory contract.

Events

OwnerWithdrawSuccess

event OwnerWithdrawSuccess(uint256 value);

Emitted when the contract owner successfully withdraws the contract's balance.

CreateStandardSuccess

event CreateStandardSuccess(address tokenAddress);

Emitted when a new standard token is successfully created.

setOwnerSuccess

event setOwnerSuccess(address newOwner);

Emitted when the contract owner is successfully updated.

createLiquiditySuccess

event createLiquiditySuccess(address tokenAddress);

Emitted when a new liquidity token is successfully created.

InitFeeSuccess

event InitFeeSuccess();

Emitted when the fee information is successfully initialized.

Functions

constructor

constructor(
    address _owner,
    address router_Addr,
    StandardTokenFactory _standardTokenFactory,
    LiquidityTokenFactory _liquidityTokenFactory
)

The constructor initializes the contract and sets the initial values for various contract parameters.

  • _owner: The address of the contract owner.
  • router_Addr: The address of the router contract.
  • _standardTokenFactory: An instance of the StandardTokenFactory contract.
  • _liquidityTokenFactory: An instance of the LiquidityTokenFactory contract.

setOwner

function setOwner(address newOwner) public

Allows the contract owner to update the owner address.

  • newOwner: The new address of the contract owner.

ownerWithdraw

function ownerWithdraw() public

Allows the contract owner to withdraw the contract's balance.

initFee

function initFee(feeInfo memory _fee) public

Initializes the fee information for different operations

.

  • _fee: The fee information for different operations.

calcFee

function calcFee(SharedStructs.status memory _state) internal view returns (uint256)

Calculates the total fee based on the current state of the token.

  • _state: The status of the token.

createStandard

function createStandard(
    address creator_,
    string memory name_,
    string memory symbol_,
    uint8 decimals_,
    uint256 tokenSupply_,
    SharedStructs.status memory _state
) public payable

Creates a new standard token and registers it in the token factory.

  • creator_: The address of the token creator.
  • name_: The name of the token.
  • symbol_: The symbol of the token.
  • decimals_: The number of decimal places for the token.
  • tokenSupply_: The total supply of the token.
  • _state: The status of the token.

createLiquidity

function createLiquidity(
    address creator_,
    address receiver,
    string memory name_,
    string memory symbol_,
    uint8 decimals_,
    uint256 supply,
    uint256 settingFlag,
    uint256[4] memory fees,
    SharedStructs.status memory _state
) public payable

Creates a new liquidity token and registers it in the token factory.

  • creator_: The address of the token creator.
  • receiver: The address of the token receiver.
  • name_: The name of the token.
  • symbol_: The symbol of the token.
  • decimals_: The number of decimal places for the token.
  • supply: The total supply of the token.
  • settingFlag: The flag indicating the token's settings.
  • fees: The fees associated with the token.
  • _state: The status of the token.

getBalance

function getBalance() public view returns (uint256)

Returns the current balance of the contract.

getCreatedToken

function getCreatedToken(address creator) public view returns (address[] memory)

Returns an array of tokens created by the specified creator.

  • creator: The address of the token creator.