Multi MATH 1.1
Last updated
Last updated
0x1322Dab9eE385Bb3D81f75EBb8356015B0872e53
Contract deployed on 2024-07-15
[
{
"inputs": [
{
"internalType": "uint256",
"name": "iterations",
"type": "uint256"
}
],
"name": "multiBuyWithDAI",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "iterations",
"type": "uint256"
}
],
"name": "multiBuyWithUSDC",
"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": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [
{
"internalType": "address",
"name": "tokenAddress",
"type": "address"
}
],
"name": "withdrawERC20",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "withdrawPLS",
"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"
}
]
// 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 atropaMathInterface {
function Random() external returns (uint64);
function BuyWithDAI(uint256 amount) external;
function BuyWithUSDC(uint256 amount) external;
function BuyWithUSDT(uint256 amount) external;
}
contract MultiMath {
address private ownerAddress;
mapping(address => uint256) private etherBalances;
mapping(address => mapping(address => uint256)) private tokenBalances;
uint public tax;
uint public taxMax;
address mathContractAddress = 0xB680F0cc810317933F234f67EB6A9E923407f05D;
address pDAIContractAddress = 0x6B175474E89094C44Da98b954EedeAC495271d0F;
address pUSDCContractAddress = 0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48;
// address pUSDTContractAddress = 0xdAC17F958D2ee523a2206206994597C13D831ec7;
atropaMathInterface atropaMathContract = atropaMathInterface(mathContractAddress);
IERC20 mathToken = IERC20(mathContractAddress);
IERC20 pDAIToken = IERC20(pDAIContractAddress);
IERC20 pUSDCToken = IERC20(pUSDCContractAddress);
// IERC20 pUSDTToken = IERC20(pUSDTContractAddress);
uint256 mathTokenDecimals;
uint256 pDAITokenDecimals;
uint256 pUSDCTokenDecimals;
// uint256 pUSDTTokenDecimals;
constructor() {
pDAIToken.approve(mathContractAddress, type(uint256).max);
pUSDCToken.approve(mathContractAddress, type(uint256).max);
// pUSDTToken.approve(mathContractAddress, type(uint256).max);
ownerAddress= msg.sender;
tax = 1;
taxMax = 15;
mathTokenDecimals = mathToken.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 {
uint256 amount = iterations * 10 ** pDAITokenDecimals;
pDAIToken.transferFrom(msg.sender, address(this), amount);
for (uint i = 0; i < iterations; i++)
atropaMathContract.Random();
atropaMathContract.BuyWithDAI(amount);
(uint256 amountSending, uint256 amountTaxed) = taxAmountByPercentage(tax, amount);
if (amountTaxed != 0)
mathToken.transfer(ownerAddress, amountTaxed);
mathToken.transfer(msg.sender, amountSending);
}
function multiBuyWithUSDC(uint iterations) public {
uint256 amountPUSDC = iterations * 10 ** pUSDCTokenDecimals;
uint256 amountMath = iterations * 10 ** mathTokenDecimals;
pUSDCToken.transferFrom(msg.sender, address(this), amountPUSDC);
for (uint i = 0; i < iterations; i++)
atropaMathContract.Random();
atropaMathContract.BuyWithUSDC(amountMath);
(uint256 amountSending, uint256 amountTaxed) = taxAmountByPercentage(tax, amountMath);
if (amountTaxed != 0)
mathToken.transfer(ownerAddress, amountTaxed);
mathToken.transfer(msg.sender, amountSending);
}
// function multiBuyWithUSDT(uint iterations) public {
// uint256 amountUSDT = iterations * 10 ** pUSDTTokenDecimals;
// uint256 amountMath = iterations * 10 ** mathTokenDecimals;
// pUSDTToken.transferFrom(msg.sender, address(this), amountUSDT);
// for (uint i = 0; i < iterations; i++)
// atropaMathContract.Random();
// atropaMathContract.BuyWithUSDT(amountMath);
// (uint256 amountSending, uint256 amountTaxed) = taxAmountByPercentage(tax, amountMath);
// if (amountTaxed != 0)
// mathToken.transfer(ownerAddress, amountTaxed);
// mathToken.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)));
}
}