Untitled
unknown
plain_text
7 months ago
3.3 kB
3
Indexable
Never
// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.24; // Uncomment this line to use console.log // import "hardhat/console.sol"; contract PoolV1 { address admin; address projectAddress; uint poolSize; uint COMMISSION_SIZE; uint immutable deploymentTime; uint immutable poolLivingTime; address influAdress; uint influComissionSize; uint influComissionBalance; bool isGoodInfl; mapping(address => uint) userBalance; mapping(address => uint) userTokenBalance; uint contractBalance; uint comissionBalance; bool moneySent; constructor (address _admin, address _projectAddress, uint _poolSize, uint _COMMISSION_SIZE, uint _deploymentTime, address _influAdress, uint _influComissionSize) { admin = _admin; poolSize = _poolSize; projectAddress = _projectAddress; COMMISSION_SIZE = _COMMISSION_SIZE; deploymentTime = _deploymentTime; influAdress = _influAdress; influComissionSize = _influComissionSize; influComissionBalance = 0; isGoodInfl = false; contractBalance = 0; comissionBalance = 0; moneySent = false; poolLivingTime = 1 weeks; } function depositToPool(uint amount) public { assert(block.timestamp < deploymentTime + poolLivingTime); uint comission = amount * COMMISSION_SIZE / 100; // in the real contract need to use more presice formula uint influComission = amount * influComissionSize / 100; // transder_usdt(msg.sender, address(this), amount + comission + influComission); userBalance[msg.sender] += amount; influComissionBalance += influComission; comissionBalance += comission; contractBalance += amount; } // function withdrawFromPool(uint amount) public { // assert(userBalance >= amount); // assert(moneySent == false); // userBalance -= amount; // poolSize -= amount; // // transfer_usdt(address(this), msg.sender, amount); // } function withdraw_comission(uint amount, uint to) public { assert(msg.sender == admin); assert(comissionBalance >= amount); // add check that comission balance is > then amount // transfer_usdt(address(this), to, amount); comissionBalance -= amount; } function influencer_withdraw_commission(uint amount) public { assert(influComissionBalance >= amount); assert(isGoodInfl == true); // transfer_usdt(address(this), influAdress, amount); } function sendToProject() public { assert(block.timestamp > deploymentTime + poolLivingTime); // Check the pool deadline. assert(contractBalance >= poolSize); // Check whether the pool accumulates the desired amount of money. // transfer_usdt(projectAddress, poolSize); // or maybe we need to transfer contractBalance contractBalance -= poolSize; moneySent = true; } function claimTokens() public { // Here should be logic to calculate the amount of tokens user has // calling external function to claim tokens // maybe sth like *amount = address(PROJECT_CONTRACT).claim()* userTokenBalance += amount; } }
Leave a Comment