Skip to content

Codyfight Token $CTOK ‐ Contract Documentation

Vinicius Martins edited this page Apr 16, 2024 · 1 revision

Codyfight Token $CTOK - Contract Documentation

Context Contract

Context provides information about the transaction sender.

Context library from OpenZeppelin contracts.

_msgSender

function _msgSender() internal view virtual returns (address)

Returns the transaction sender address.

Return Values

Name Type Description
[0] address sender_ The transaction sender address.

_msgData

function _msgData() internal view virtual returns (bytes)

Returns the transaction data.

Return Values

Name Type Description
[0] bytes data_ The transaction data.

ILssController

LssController is a contract that implements the lossless feature. It is used to control the lossless feature of the LERC20Burnable contract. The LssController contract must implement the beforeTransfer, beforeTransferFrom, beforeApprove, beforeIncreaseAllowance, beforeDecreaseAllowance, and beforeBurn functions. The LssController contract must be set in the LERC20Burnable contract.

Interface of the LssController.

beforeTransfer

function beforeTransfer(address sender, address recipient, uint256 amount) external

Function to be called before a transfer.

Parameters

Name Type Description
sender address The sender address.
recipient address The recipient address.
amount uint256 The transfer amount.

beforeTransferFrom

function beforeTransferFrom(address msgSender, address sender, address recipient, uint256 amount) external

Function to be called before a transfer from.

Parameters

Name Type Description
msgSender address The transaction sender address.
sender address The sender address.
recipient address The recipient address.
amount uint256 The transfer amount.

beforeApprove

function beforeApprove(address sender, address spender, uint256 amount) external

Function to be called before an approve.

Parameters

Name Type Description
sender address The sender address.
spender address The spender address.
amount uint256 The approve amount.

beforeIncreaseAllowance

function beforeIncreaseAllowance(address msgSender, address spender, uint256 addedValue) external

Function to be called before an increase allowance.

Parameters

Name Type Description
msgSender address The transaction sender address.
spender address The spender address.
addedValue uint256 The added allowance amount.

beforeDecreaseAllowance

function beforeDecreaseAllowance(address msgSender, address spender, uint256 subtractedValue) external

Function to be called before a decrease allowance.

Parameters

Name Type Description
msgSender address The transaction sender address.
spender address The spender address.
subtractedValue uint256 The subtracted allowance amount.

beforeBurn

function beforeBurn(address account, uint256 amount) external

Function to be called before a burn.

Parameters

Name Type Description
account address The account address.
amount uint256 The burn amount.

LERC20Burnable Contract

LERC20Burnable is a contract that implements the ERC20 standard with burn and lossless features. The LERC20Burnable contract is based on the OpenZeppelin Context contract.

LERC20Burnable contract from Lossless.io. Extends the Context contract.

recoveryAdmin

address recoveryAdmin

recoveryAdmin is the address of the recovery admin, who can change the admin and turn off the lossless feature.

Recovery admin variable.

admin

address admin

admin is the address of the admin, who will hold the minted tokens and have governance rights.

Admin variable.

timelockPeriod

uint256 timelockPeriod

timelockPeriod is the period in seconds that the recovery admin must wait to turn off the lossless feature.

Timelock period variable.

losslessTurnOffTimestamp

uint256 losslessTurnOffTimestamp

losslessTurnOffTimestamp is the timestamp when the lossless feature will be turned off.

Lossless turn off timestamp variable.

isLosslessOn

bool isLosslessOn

isLosslessOn is a boolean that indicates if the lossless feature is on.

Lossless on variable.

lossless

contract ILssController lossless

lossless is the address of the LssController contract, which implements the lossless feature.

Lossless controller variable.

constructor

constructor(uint256 totalSupply_, string name_, string symbol_, address admin_, address recoveryAdmin_, uint256 timelockPeriod_, address lossless_) public

Constructor sets the initial values of the contract. It mints the total supply to the admin address.

Constructor function.

Parameters

Name Type Description
totalSupply_ uint256 The total supply of the token.
name_ string The name of the token.
symbol_ string The symbol of the token.
admin_ address The address of the admin.
recoveryAdmin_ address The address of the recovery admin.
timelockPeriod_ uint256 The timelock period in seconds.
lossless_ address The address of the LssController contract.

Transfer

event Transfer(address _from, address _to, uint256 _value)

Transfer event.

Parameters

Name Type Description
_from address The sender address.
_to address The recipient address.
_value uint256 The transfer amount.

Approval

event Approval(address _owner, address _spender, uint256 _value)

Approval event.

Parameters

Name Type Description
_owner address The owner address.
_spender address The spender address.
_value uint256 The approve amount.

NewAdmin

event NewAdmin(address _newAdmin)

New admin event.

Parameters

Name Type Description
_newAdmin address The new admin address.

NewRecoveryAdminProposal

event NewRecoveryAdminProposal(address _candidate)

New recovery admin proposal event.

Parameters

Name Type Description
_candidate address The candidate address.

NewRecoveryAdmin

event NewRecoveryAdmin(address _newAdmin)

New recovery admin event.

Parameters

Name Type Description
_newAdmin address The new recovery admin address.

LosslessTurnOffProposal

event LosslessTurnOffProposal(uint256 _turnOffDate)

Lossless turn off proposal event.

Parameters

Name Type Description
_turnOffDate uint256 The turn off date timestamp.

LosslessOff

event LosslessOff()

Lossless off event.

LosslessOn

event LosslessOn()

Lossless on event.

lssAprove

modifier lssAprove(address spender, uint256 amount)

The lssAprove modifier calls the beforeApprove function of the lossless contract.

Lossless approve modifier.

Parameters

Name Type Description
spender address The spender address.
amount uint256 The approve amount.

lssTransfer

modifier lssTransfer(address recipient, uint256 amount)

The lssTransfer modifier calls the beforeTransfer function of the lossless contract.

Lossless transfer modifier.

Parameters

Name Type Description
recipient address The recipient address.
amount uint256 The transfer amount.

lssTransferFrom

modifier lssTransferFrom(address sender, address recipient, uint256 amount)

The lssTransferFrom modifier calls the beforeTransferFrom function of the lossless contract.

Lossless transfer from modifier.

Parameters

Name Type Description
sender address The sender address.
recipient address The recipient address.
amount uint256 The transfer amount.

lssBurn

modifier lssBurn(address account, uint256 amount)

The lssBurn modifier calls the beforeBurn function of the lossless contract.

Lossless burn modifier.

Parameters

Name Type Description
account address The account address.
amount uint256 The burn amount.

lssIncreaseAllowance

modifier lssIncreaseAllowance(address spender, uint256 addedValue)

The lssIncreaseAllowance modifier calls the beforeIncreaseAllowance function of the lossless contract.

Lossless increase allowance modifier.

Parameters

Name Type Description
spender address The spender address.
addedValue uint256 The added allowance amount.

lssDecreaseAllowance

modifier lssDecreaseAllowance(address spender, uint256 subtractedValue)

The lssDecreaseAllowance modifier calls the beforeDecreaseAllowance function of the lossless contract.

Lossless decrease allowance modifier.

Parameters

Name Type Description
spender address The spender address.
subtractedValue uint256 The subtracted allowance amount.

onlyRecoveryAdmin

modifier onlyRecoveryAdmin()

The onlyRecoveryAdmin modifier restricts access to the recovery admin.

Recovery admin modifier.

transferOutBlacklistedFunds

function transferOutBlacklistedFunds(address[] from) external

This function allows the lossless contract to transfer out blacklisted funds.

Function to transfer out blacklisted funds.

Parameters

Name Type Description
from address[] The array of addresses from which the funds will be transferred.

setLosslessAdmin

function setLosslessAdmin(address newAdmin) external

This function allows the recovery admin to set a new admin.

Function to set new admin.

Parameters

Name Type Description
newAdmin address The new admin address.

transferRecoveryAdminOwnership

function transferRecoveryAdminOwnership(address candidate, bytes32 keyHash) external

This function allows the recovery admin to transfer the recovery admin ownership to a candidate address.

Function to transfer recovery admin ownership.

Parameters

Name Type Description
candidate address The candidate address.
keyHash bytes32 The key hash.

acceptRecoveryAdminOwnership

function acceptRecoveryAdminOwnership(bytes key) external

This function allows the candidate address to accept the recovery admin ownership.

Function to accept recovery admin ownership.

Parameters

Name Type Description
key bytes The key.

proposeLosslessTurnOff

function proposeLosslessTurnOff() external

This function allows the recovery admin to propose to turn off the lossless features.

Function to propose lossless turn off.

executeLosslessTurnOff

function executeLosslessTurnOff() external

This function allows the recovery admin to execute the lossless turn off, when the timelock period has passed.

Function to execute lossless turn off.

executeLosslessTurnOn

function executeLosslessTurnOn() external

This function allows the recovery admin to execute the lossless turn on.

Function to execute lossless turn on.

getAdmin

function getAdmin() public view virtual returns (address)

Function to get the admin address.

Return Values

Name Type Description
[0] address The admin address.

name

function name() public view virtual returns (string)

Function to get the name of the token.

Return Values

Name Type Description
[0] string The name of the token.

symbol

function symbol() public view virtual returns (string)

Function to get the symbol of the token.

Return Values

Name Type Description
[0] string The symbol of the token.

decimals

function decimals() public view virtual returns (uint8)

Function to get the decimals of the token.

Return Values

Name Type Description
[0] uint8 The decimals of the token.

totalSupply

function totalSupply() public view virtual returns (uint256)

Function to get the total supply of the token.

Return Values

Name Type Description
[0] uint256 The total supply of the token.

balanceOf

function balanceOf(address account) public view virtual returns (uint256)

Function to get the balance of an account.

Parameters

Name Type Description
account address The account address.

Return Values

Name Type Description
[0] uint256 The balance of the account.

transfer

function transfer(address recipient, uint256 amount) public virtual returns (bool)

Function to transfer tokens. Uses the lssTransfer modifier to call the beforeTransfer function of the lossless contract.

Parameters

Name Type Description
recipient address The recipient address.
amount uint256 The transfer amount.

Return Values

Name Type Description
[0] bool A boolean that indicates if the operation was successful.

allowance

function allowance(address owner, address spender) public view virtual returns (uint256)

Function to get the allowance of a spender on an owner's tokens.

Parameters

Name Type Description
owner address The owner address.
spender address The spender address.

Return Values

Name Type Description
[0] uint256 The allowance of the spender on the owner's tokens.

approve

function approve(address spender, uint256 amount) public virtual returns (bool)

Function to approve a spender to spend an amount of tokens. Uses the lssAprove modifier to call the beforeApprove function of the lossless contract.

Parameters

Name Type Description
spender address The spender address.
amount uint256 The approve amount.

Return Values

Name Type Description
[0] bool A boolean that indicates if the operation was successful.

transferFrom

function transferFrom(address sender, address recipient, uint256 amount) public virtual returns (bool)

Function to transfer tokens from an owner to a recipient. Uses the lssTransferFrom modifier to call the beforeTransferFrom function of the lossless contract.

Parameters

Name Type Description
sender address The sender address.
recipient address The recipient address.
amount uint256 The transfer amount.

Return Values

Name Type Description
[0] bool A boolean that indicates if the operation was successful.

increaseAllowance

function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool)

Function to increase the allowance of a spender. Uses the lssIncreaseAllowance modifier to call the beforeIncreaseAllowance function of the lossless contract.

Parameters

Name Type Description
spender address The spender address.
addedValue uint256 The added allowance amount.

Return Values

Name Type Description
[0] bool A boolean that indicates if the operation was successful.

decreaseAllowance

function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool)

Function to decrease the allowance of a spender. Uses the lssDecreaseAllowance modifier to call the beforeDecreaseAllowance function of the lossless contract.

Parameters

Name Type Description
spender address The spender address.
subtractedValue uint256 The subtracted allowance amount.

Return Values

Name Type Description
[0] bool A boolean that indicates if the operation was successful.

_transfer

function _transfer(address sender, address recipient, uint256 amount) internal virtual

Internal function to transfer tokens. Overrides the _transfer function of the Context contract to enforce specific conditions.

Parameters

Name Type Description
sender address The sender address.
recipient address The recipient address.
amount uint256 The transfer amount.

_mint

function _mint(address account, uint256 amount) internal virtual

Mint function is only executed at contract deployment. No mint function is available after deployment.

Internal function to mint tokens. Overrides the _mint function of the Context contract to enforce specific conditions.

Parameters

Name Type Description
account address The account address.
amount uint256 The mint amount.

_burn

function _burn(address account, uint256 amount) internal virtual

Internal function to burn tokens. Overrides the _burn function of the Context contract to enforce specific conditions.

Parameters

Name Type Description
account address The account address.
amount uint256 The burn amount.

_approve

function _approve(address owner, address spender, uint256 amount) internal virtual

Internal function to approve a spender to spend an amount of tokens.

Parameters

Name Type Description
owner address The owner address.
spender address The spender address.
amount uint256 The approve amount.

burn

function burn(uint256 amount) public virtual

Burn function may not be allowed if the lossless feature is on, Lossless controller may block the burn.

Function to burn tokens. Uses the lssBurn modifier to call the beforeBurn function of the lossless contract.

Parameters

Name Type Description
amount uint256 The burn amount.

burnFrom

function burnFrom(address account, uint256 amount) public virtual

Burn function may not be allowed if the lossless feature is on, Lossless controller may block the burn.

Function to burn tokens from an account. Uses the lssBurn modifier to call the beforeBurn function of the lossless contract.

Parameters

Name Type Description
account address The account address.
amount uint256 The burn amount.

CodyfightToken Contract

CodyfightToken is the official token of Codyfight. Tokens are only minted at contract deployment. No mint function is available after deployment. Tokens can be burned.

CodyfightToken fully inherits the LERC20Burnable contract, which implements the ERC20 standard with burn and lossless features.

constructor

constructor(uint256 totalSupply_, string name_, string symbol_, address admin_, address recoveryAdmin_, uint256 timelockPeriod_, address lossless_) public

Constructor sets the initial values of the contract. It mints the total supply to the admin address.

Constructor function.

Parameters

Name Type Description
totalSupply_ uint256 The total supply of the token.
name_ string The name of the token.
symbol_ string The symbol of the token.
admin_ address The address of the admin.
recoveryAdmin_ address The address of the recovery admin.
timelockPeriod_ uint256 The timelock period in seconds.
lossless_ address The address of the LssController contract.
Clone this wiki locally