// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./e2XUsers1.sol"; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; contract VoucherContract { e2XUsernames public userDataContract; mapping(string => bool) public usedVouchers; mapping(address => uint256) public e2xCumulativeTotal; event VoucherRedeemed(string indexed voucherId, address indexed memberAddress, string e2xDataId); modifier onlyOwner() { require(msg.sender == owner, "Only contract owner can call this function"); _; } address public owner; IERC20 public usdeToken; constructor(address _userDataContract, address _usdeToken) { userDataContract = e2XUsernames(_userDataContract); usdeToken = IERC20(_usdeToken); owner = msg.sender; } function deposit() external { // Deposit 35 USDe tokens uint256 depositAmount = 35 * 10**18; // 35 USDe tokens with 18 decimals usdeToken.transferFrom(msg.sender, address(this), depositAmount); // Transfer 10 USDe tokens to the referrer address referrer = userDataContract.getAddressByUser(userDataContract.getData(msg.sender)); uint256 referralAmount = 10 * 10**18; // 10 USDe tokens with 18 decimals usdeToken.transfer(referrer, referralAmount); // Increment e2x cumulative total e2xCumulativeTotal[msg.sender] += 15; } function redeemVoucher(string memory voucherId) external { require(!usedVouchers[voucherId], "Voucher has already been used"); // Mark the voucher as used usedVouchers[voucherId] = true; // Increment e2x cumulative total e2xCumulativeTotal[msg.sender] += 15; // Emit the VoucherRedeemed event emit VoucherRedeemed(voucherId, msg.sender, userDataContract.getData(msg.sender)); // Emit other events and perform necessary actions... } function generateVoucherCode(string memory e2xDataId) internal pure returns (string memory) { // Dummy implementation to generate a unique voucher code return string(abi.encodePacked(e2xDataId, "-USDe20")); } }