🖥️For Developers
Contrato
Contrato WEbdEXFactoryV3
solidityCopy code// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
import "@openzeppelin/contracts/access/Ownable.sol";SPDX-License-Identifier: Este é um comentário SPDX-License-Identifier indicando que o contrato está licenciado sob o MIT.
pragma solidity ^0.8.18: Indica a versão mínima do compilador Solidity necessária para compilar o contrato.
Importação de bibliotecas:
O contrato importa a biblioteca
Ownabledo OpenZeppelin, que fornece funcionalidades básicas de controle de propriedade.
solidityCopy codecontract WEbdEXFactoryV3 is Ownable {Declaração de Variáveis:
bots: Uma matriz interna de estruturasBot.faucets, wusd, usdt, dai, usdc, switchWUSD, swapBook, payments: Endereços de contratos relacionados à plataforma WEbdEX.
solidityCopy code Bot[] internal bots;
address public faucets;
address public wusd;
address public usdt;
address public dai;
address public usdc;
address public switchWUSD;
address public swapBook;
address public payments;Struct Bot:
Define uma estrutura chamada
Botque armazena informações sobre um bot, incluindo seu nome, endereço da carteira, endereços de contratos relevantes, e outros.
solidityCopy code struct Bot {
string name;
string wallet;
address faucets;
address wusd;
address usdt;
address dai;
address usdc;
address botManager;
address switchWUSD;
address swapBook;
address pass;
address networkPool;
address strategies;
address payments;
}Constructor:
O construtor recebe os endereços iniciais dos contratos relevantes e os atribui às variáveis correspondentes.
solidityCopy code constructor(
address faucets_,
address wusd_,
address usdt_,
address dai_,
address usdc_,
address switchWUSD_,
address swapBook_,
address payments_
) {
faucets = faucets_;
wusd = wusd_;
usdt = usdt_;
dai = dai_;
usdc = usdc_;
switchWUSD = switchWUSD_;
swapBook = swapBook_;
payments = payments_;
}Função addBot:
Permite ao proprietário adicionar um novo bot à plataforma, fornecendo informações como nome, carteira, e endereços dos contratos relevantes.
solidityCopy code function addBot(
string memory name,
string memory wallet,
address botManager,
address pass,
address strategies,
address networkPool
) public onlyOwner {
bots.push(
Bot(
name,
wallet,
faucets,
wusd,
usdt,
dai,
usdc,
botManager,
switchWUSD,
swapBook,
pass,
networkPool,
strategies,
payments
)
);
}Função getBots:
Permite ao proprietário obter a lista de bots adicionados à plataforma.
solidityCopy code function getBots() public view onlyOwner returns (Bot[] memory) {
return bots;
}
}Essas são as principais características e funcionalidades do contrato. Ele serve como uma fábrica para criar bots, mantendo uma lista de bots existentes e seus detalhes.
WEbdEXManagerV3 Contract
solidityCopy code// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
import "@openzeppelin/contracts/access/Ownable.sol";
import "../utils/NFT.sol";
interface IWEbdEXPassV3 {
struct User {
bool passExpired;
bool haveFreeTrial;
uint256 expirationTime;
}
function getUserInfoByWallet(address to) external view returns (User memory);
}License and Pragma Directives:
SPDX-License-Identifier specifies the license under which the contract is released.
Pragma solidity ^0.8.18 sets the minimum version of the Solidity compiler.
Import Statements:
The contract imports the Ownable contract from the OpenZeppelin library and a custom NFT contract.
solidityCopy codecontract WEbdEXManagerV3 is Ownable {Contract Declaration:
The contract inherits from the Ownable contract, indicating it has owner-based access control.
solidityCopy code Bot public bot;
IWEbdEXPassV3 public webDexPassV3;
Register[] internal registers;
address public webDexStrategiesV3;State Variables:
bot: Stores information about a bot, including its name, associated token contract, wallet, and seller address.webDexPassV3: Represents an interface to the WEbdEXPassV3 contract, allowing access to user information.registers: An array to store registration details, including user wallet and associated manager.webDexStrategiesV3: Address of the WebDexStrategies contract.
solidityCopy code mapping(address => User) internal users;
struct User {
address manager;
bool status;
}
struct Bot {
string name;
address token;
address wallet;
address seller;
}Mapping and Structs:
users: A mapping to store user information based on their address.User: A struct representing user details, including the associated manager and registration status.Bot: A struct representing bot details, including its name, associated token, wallet, and seller address.
solidityCopy code struct Register {
address wallet;
address manager;
}
struct Display {
address wallet;
address manager;
bool status;
bool passExpired;
bool haveFreeTrial;
uint256 expirationTime;
}Additional Structs:
Register: A struct to store registration details, including user wallet and associated manager.Display: A struct representing user details for display purposes, including wallet, manager, status, pass expiration, free trial status, and expiration time.
solidityCopy code event Transaction(
address indexed from,
string method,
uint256 timeStamp,
address to,
uint256 value
);
constructor(
string memory name_,
string memory symbol_,
address wallet_,
IWEbdEXPassV3 webDexPassV3_,
address seller_
) {
bot = Bot(
name_,
address(
new NFT(string(abi.encodePacked(name_, " Affiliated")), symbol_)
),
wallet_,
seller_
);
webDexPassV3 = webDexPassV3_;
}Event and Constructor:
Transactionevent: Logs transactions with details such as the sender, method, timestamp, recipient, and value.Constructor: Initializes the contract with the bot details, including its name, token, wallet, and seller, as well as the WEbdEXPassV3 contract interface.
solidityCopy code modifier onlyWebDexStrategiesOrOwner() {
require(
msg.sender == webDexStrategiesV3 ||
(msg.sender == owner() && webDexStrategiesV3 != address(0)),
"You must own the contract or the WebDexStrategies"
);
_;
}Modifier:
onlyWebDexStrategiesOrOwner: A modifier restricting access to certain functions to the owner or the WebDexStrategies contract.
solidityCopy code function changeWEbdEXStrategiesV3(
address newWebDexStrategiesV3
) public onlyOwner {
webDexStrategiesV3 = newWebDexStrategiesV3;
}Function:
changeWEbdEXStrategiesV3: Allows the owner to change the address of the WebDexStrategies contract.
solidityCopy code function registerInBot(address manager) public {
// Function implementation...
}Function:
registerInBot: Allows users to register in the bot, associating themselves with a manager and minting an NFT.
solidityCopy code function getUserInfo() public view returns (Display memory) {
return _getUser(msg.sender);
}Function:
getUserInfo: Retrieves user information for the caller.
solidityCopy code function getUserInfoByWallet(address to) public view onlyWebDexStrategiesOrOwner returns (Display memory) {
return _getUser(to);
}Function:
getUserInfoByWallet: Retrieves user information based on the provided wallet address, restricted to the owner or the WebDexStrategies contract.
solidityCopy code function getBot() public view returns (Bot memory) {
return bot;
}Function:
getBot: Retrieves information about the bot.
solidityCopy code function getRegisters() public view returns (Register[] memory) {
return registers;
}Function:
getRegisters: Retrieves an array of registration details.
solidityCopy code function _getUser(address to) internal view returns (Display memory) {
// Function implementation...
}
}Internal Function:
_getUser: Internal function to retrieve user information based on the provided address.
This breakdown provides a detailed overview of the WEbdEXManagerV3 contract, including its state variables, functions, and modifiers.
WEbdEXPassV3 Contract
solidityCopy code// SPDX-License-Identifier: MIT
pragma solidity ^0.8.18;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
interface IWEbdEXStrategiesV3 {
function lpMint(address to, address coin, uint256 amount) external returns (address);
}
interface IWEbdEXNetworkPoolV3 {
function addBalance(address to, address coin, uint256 amount, address lpToken, address user, string memory method) external;
}
contract WEbdEXPassV3 is Ownable {
ERC20 public erc20;
uint256 public monthlyPassValue;
uint256 public quarterlyPassValue;
uint256 public semesterPassValue;
uint256 public annualPassValue;
uint256 internal constant monthlyExpirationTime = 30 days;
uint256 internal constant quarterlyExpirationTime = 90 days;
uint256 internal constant semesterExpirationTime = 180 days;
uint256 internal constant annualExpirationTime = 365 days;
uint256 public freeTrialExpirationTime;
mapping(address => uint256) internal expirationTimes;
mapping(address => uint256) internal freeTrials;
enum PassType {
MONTHLY,
QUARTERLY,
SEMESTER,
ANNUAL
}
struct User {
bool passExpired;
bool haveFreeTrial;
uint256 expirationTime;
}License and Pragma Directives:
SPDX-License-Identifier specifies the license under which the contract is released.
Pragma solidity ^0.8.18 sets the minimum version of the Solidity compiler.
Import Statements:
The contract imports the ERC20 contract from the OpenZeppelin library and the Ownable contract for access control.
solidityCopy code event PayFee(address indexed wallet, address indexed coin, uint256 amount);
event ExtractLogs(address indexed from, string method, uint256 timeStamp, address to, uint256 value);
event PayPass(address indexed from, address coin, uint256 value);Events:
PayFee: Emitted when a fee is paid. Includes details such as the wallet, coin, and amount.ExtractLogs: Emitted for various transaction logs. Includes details like the sender, method, timestamp, recipient, and value.PayPass: Emitted when a pass is paid. Includes details such as the sender, coin, and value.
solidityCopy code struct NetworkData {
address wallet;
uint256 amount;
}
struct PayFeesAmount {
NetworkData[] network;
uint256 seller;
uint256 bot;
uint256 manager;
address token;
address user;
string transaction;
}
struct PayComissions {
PayFeesAmount list;
address seller;
address bot;
address manager;
IWEbdEXStrategiesV3 webDexStrategiesV3;
IWEbdEXNetworkPoolV3 webDexNetworkPoolV3;
}Structs:
NetworkData: Represents data about a network, including wallet and amount.PayFeesAmount: Represents amounts for various fees, including network fees, seller fee, bot fee, manager fee, token, user, and transaction type.PayComissions: Represents the commission structure with a list of fees and addresses for seller, bot, manager, webDexStrategiesV3, and webDexNetworkPoolV3.
solidityCopy code mapping(string => bool) private listPayments;
mapping(address => bool) private privilegedWallets;
constructor(
ERC20 erc20_,
uint256 monthlyPassValue_,
uint256 quarterlyPassValue_,
uint256 semesterPassValue_,
uint256 annualPassValue_,
uint256 freeTrialExpirationTime_
) {
erc20 = erc20_;
monthlyPassValue = monthlyPassValue_;
quarterlyPassValue = quarterlyPassValue_;
semesterPassValue = semesterPassValue_;
annualPassValue = annualPassValue_;
freeTrialExpirationTime = freeTrialExpirationTime_;
}Mappings and Constructor:
listPayments: A mapping to keep track of whether a payment has been made.privilegedWallets: A mapping to manage privileged wallets.Constructor: Initializes the contract with ERC20 token details, pass values, and free trial expiration time.
solidityCopy code modifier onlyWalletPrivileged() {
require(msg.sender == owner() || privilegedWallets[msg.sender], "You must be the owner or privilegedWallets");
_;
}
modifier onlyHaveFreeTrial() {
require(_haveFreeTrial(msg.sender), "Have you already used your free trial");
_;
}Modifiers:
onlyWalletPrivileged: A modifier to restrict access to only the owner or privileged wallets.onlyHaveFreeTrial: A modifier to check if the user has a free trial.
solidityCopy code function comissionPass(PayComissions memory payments) public onlyOwner {
// Function implementation...
}Function:
comissionPass: Allows the owner to pay various commissions. Utilizes a complex structure with different fees and destinations.
solidityCopy code function _payFee(
address coin,
uint256 amount,
address to,
address user,
IWEbdEXStrategiesV3 webDexStrategiesV3,
IWEbdEXNetworkPoolV3 webDexNetworkPoolV3
) internal {
// Function implementation...
}Internal Function:
_payFee: Internal function to facilitate the payment of fees, involving LP minting and adding balances to the network pool.
solidityCopy code function changeFreeTrialExpirationTime(uint256 newExpirationTime) public onlyWalletPrivileged {
// Function implementation...
}Function:
changeFreeTrialExpirationTime: Allows the owner or privileged wallets to change the free trial expiration time.
solidityCopy code function changePassValue(PassType passType, uint256 value) public onlyWalletPrivileged {
// Function implementation...
}Function:
changePassValue: Allows the owner or privileged wallets to change the pass values based on the pass type.
solidityCopy code function payPass(PassType passType) public {
// Function implementation...
}Function:
payPass: Allows users to pay for a pass based on the pass type.
solidityCopy code function getFreeTrial() public onlyHaveFreeTrial {
// Function implementation...
}Function:
getFreeTrial: Allows users to obtain a free trial.
solidityCopy code function sendPass(PassType passType, address to) public onlyWalletPrivileged {
// Function implementation...
}Function:
sendPass: Allows the owner or privileged wallets to send a pass to a specified address.
solidityCopy code function addWalletPrivilege(address wallet) public onlyOwner {
privilegedWallets[wallet] = true;
}
function revokeWalletPrivilege(address wallet) public onlyOwner {
privilegedWallets[wallet] = false;
}Functions:
addWalletPrivilege: Allows the owner to add wallet privilege.revokeWalletPrivilege: Allows the owner to revoke wallet privilege.
solidityCopy code function getUserInfo() public view returns (User memory) {
return _getUserInfo(msg.sender);
}
function getUserInfoByWallet(address to) public view returns (User memory) {
return _getUserInfo(to);
}Functions:
getUserInfo: Retrieves user information for the caller.getUserInfoByWallet: Retrieves user information based on the provided wallet address.
solidityCopy code function _getUserInfo(address to) internal view returns (User memory) {
return User(_passExpired(to), _haveFreeTrial(to), expirationTimes[to]);
}
function _passExpired(address to) internal view returns (bool) {
return block.timestamp >= expirationTimes[to];
}
function _haveFreeTrial(address to) internal view returns (bool) {
return freeTrials[to] == 0;
}
}Internal Functions:
_getUserInfo: Internal function to retrieve user information based on the provided address._passExpired: Internal function to check if the pass for the given address has expired._haveFreeTrial: Internal function to check if the user at the given address has a free trial.
This breakdown provides a detailed overview of the WEbdEXPassV3 contract, including its state variables, events, modifiers, functions, and internal functions.
Last updated