Multi G5
Last updated
Last updated
0xa4c61D20945c11855E7A390153fd29ceC9C7349b
Contract deployed on 2024-07-15
[
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "iterations",
"type": "uint256"
}
],
"name": "multiBuyWithDAI",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newOwnerAddress",
"type": "address"
}
],
"name": "setOwner",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "percent",
"type": "uint256"
}
],
"name": "setTax",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "tax",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "percentage",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "taxAmountByPercentage",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [],
"name": "taxMax",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "tokenAddress",
"type": "address"
}
],
"name": "withdrawERC20",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "withdrawPLS",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface IERC20 {
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
function transfer(address recipient, uint256 amount) external returns (bool);
function balanceOf(address _owner) external returns (uint256);
function totalSupply() external returns (uint256);
function decimals() external returns (uint256);
function approve(address _spender, uint256 _value) external returns (bool);
}
interface G5Interface {
function BuyWithDAI() external;
function BuyWithUSDC() external;
function BuyWithUSDT() external;
}
contract MultiG5 {
address private ownerAddress;
mapping(address => uint256) private etherBalances;
mapping(address => mapping(address => uint256)) private tokenBalances;
uint public tax;
uint public taxMax;
address G5ContractAddress = 0x2fc636E7fDF9f3E8d61033103052079781a6e7D2;
address pDAIContractAddress = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
// address pUSDCContractAddress = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
// address pUSDTContractAddress = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
G5Interface G5Contract = G5Interface(G5ContractAddress);
IERC20 G5Token = IERC20(G5ContractAddress);
IERC20 pDAIToken = IERC20(pDAIContractAddress);
// IERC20 pUSDCToken = IERC20(pUSDCContractAddress);
// IERC20 pUSDTToken = IERC20(pUSDTContractAddress);
uint256 G5TokenDecimals;
uint256 pDAITokenDecimals;
// uint256 pUSDCTokenDecimals;
// uint256 pUSDTTokenDecimals;
constructor() {
pDAIToken.approve(G5ContractAddress, type(uint256).max);
// pUSDCToken.approve(G5ContractAddress, type(uint256).max);
// pUSDTToken.approve(G5ContractAddress, type(uint256).max);
ownerAddress= msg.sender;
tax = 1;
taxMax = 15;
G5TokenDecimals = G5Token.decimals();
pDAITokenDecimals = pDAIToken.decimals();
// pUSDCTokenDecimals = pUSDCToken.decimals();
// pUSDTTokenDecimals = pUSDTToken.decimals();
}
modifier onlyOwner() {
require(msg.sender == ownerAddress, "Only the owner can call this");
_;
}
function taxAmountByPercentage(uint256 percentage, uint256 value) public pure returns (uint256, uint256) {
if (percentage == 0)
return (value, 0);
uint256 valueWithDecimals = value * 10**18;
uint256 percentageToSubtract = valueWithDecimals * percentage / 100;
uint256 result = valueWithDecimals - percentageToSubtract;
uint256 subtractedAmount = value - (result / 10**18);
return (result / 10**18, subtractedAmount);
}
function multiBuyWithDAI(uint iterations) public {
pDAIToken.transferFrom(msg.sender, address(this), iterations * 5 * 10 ** pDAITokenDecimals);
for (uint i = 0; i < iterations; i++)
G5Contract.BuyWithDAI();
uint256 amount = iterations * 10 ** G5TokenDecimals;
(uint256 amountSending, uint256 amountTaxed) = taxAmountByPercentage(tax, amount);
if (amountTaxed != 0)
G5Token.transfer(ownerAddress, amountTaxed);
G5Token.transfer(msg.sender, amountSending);
}
// function multiBuyWithUSDC(uint iterations) public {
// pUSDCToken.transferFrom(msg.sender, address(this), iterations * 5 * 10 ** pUSDCTokenDecimals);
// for (uint i = 0; i < iterations; i++)
// G5Contract.BuyWithUSDC();
// uint256 amount = iterations * 10 ** G5TokenDecimals;
// (uint256 amountSending, uint256 amountTaxed) = taxAmountByPercentage(tax, amount);
// if (amountTaxed != 0)
// G5Token.transfer(ownerAddress, amountTaxed);
// G5Token.transfer(msg.sender, amountSending);
// }
// function multiBuyWithUSDT(uint iterations) public {
// pUSDTToken.transferFrom(msg.sender, address(this), iterations * 5 * 10 ** pUSDTTokenDecimals);
// for (uint i = 0; i < iterations; i++)
// G5Contract.BuyWithUSDT();
// uint256 amount = iterations * 10 ** G5TokenDecimals;
// (uint256 amountSending, uint256 amountTaxed) = taxAmountByPercentage(tax, amount);
// if (amountTaxed != 0)
// G5Token.transfer(ownerAddress, amountTaxed);
// G5Token.transfer(msg.sender, amountSending);
// }
function setTax(uint percent) public onlyOwner {
if (percent <= taxMax)
tax = percent;
}
function setOwner(address newOwnerAddress) public onlyOwner {
ownerAddress = newOwnerAddress;
}
function withdrawPLS() public onlyOwner {
payable(ownerAddress).transfer(address(this).balance);
}
function withdrawERC20(address tokenAddress) public onlyOwner {
IERC20 token = IERC20(tokenAddress);
token.transfer(ownerAddress, token.balanceOf(address(this)));
}
}