Define uma estrutura chamada Bot que armazena informaΓ§Γ΅es sobre um bot, incluindo seu nome, endereΓ§o da carteira, endereΓ§os de contratos relevantes, e outros.
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.
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.
Transaction event: 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.
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.
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.
_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.