Lenny
The Lenny.sol smart contract is an ERC20 token that uses Openzeppelin Implentation with extra functions to protect our community from Wales wallets. Most of the functions in this smart contracts are taken from the Openzeppelin but for those that has any change from the library implementation, we are goiung to explain them here.
Note : instead of Inheriting from the ERC20 Openzeppelin Extensions, we decided to implement them into the Lenny.sol contract directly. Here is the list of extensions :
Inheritances​
This contract inherits from:
Interfaces​
This contract use IDOSC.sol to interact with the DemocraticOwnership.sol smart contract.
State Variables, Enums and Structs​
uint256 public maxTokenPerAddress : the maximum token (non decimals) that can be hold by an account
Mappings​
private _isExcludedFromMaxToken that maps the calling address to the bool that indicates true if caller is exluded from maximum token restrictions.
Functions​
constructor(address _doscAddress, uint256 _cap_, uint256 _maxTokenPerAddress) (public)​
To instantiate the smart contract, we provide the _doscAddress, the _cap_ and the _maxTokenPerAddress. Also the name and version to build the EIP712.sol abstract are hard coded with the value Lenny and 1.
constructor (
address _doscAddress,
uint256 _cap_,
uint256 _maxTokenPerAddress
) EIP712("Lenny", "1") Democratic(_doscAddress) {
require(_cap_ > 0, "ERC20Capped: cap is 0");
_cap = _cap_ * 10 ** _decimals;
maxTokenPerAddress = _maxTokenPerAddress * 10 ** _decimals;
}
isExcludedFromMaxToken(address account) → bool (public)​
Return true if account address is excluded from maximum token restrictions, false otherwise.
excludeFromMaxToken(address account) (public)​
The authorized administrator can call this function to exclude the account address from the maximum restriction. Some addresses like the pairToken created by the UniswapV2 Factory have to own a substantial amount of token to create a secured liquidity pool.
function excludeFromMaxToken(address account) public demokratia() {
require(!_isExcludedFromMaxToken[account], "Account is already excluded from restriction");
_isExcludedFromMaxToken[account] = true;
IDOSC dosc = IDOSC(doscAdd);
dosc.registerCall('LENNY', 'excludeFromMaxToken');
}
includeInMaxToken(address account) (public)​
The authorized administrator can call this function to include the account address into the maximum restriction.
function includeInMaxToken(address account) public demokratia {
_isExcludedFromMaxToken[account] = false;
IDOSC dosc = IDOSC(doscAdd);
dosc.registerCall('LENNY', 'includeInMaxToken');
}
setMaxTokenPerAddress(uint256 _maxToken) (external)​
The authorized administrator can call this function to change the maximium amount of token that one address can have. The value of _maxToken is decimals.
function setMaxTokenPerAddress(uint256 _maxToken) external demokratia {
require(_maxToken <= 500_000_000*10**_decimals, 'Must be a maximum of 500 millions');
require(_maxToken >= 100_000_000*10**_decimals, 'Must be a minimum of 100 millions');
maxTokenPerAddress = _maxToken;
IDOSC dosc = IDOSC(doscAdd);
dosc.registerCall('LENNY', 'setMaxTokenPerAddress');
}