libAtropaMath v1.1 (MATH)
Last updated
Last updated
0xB680F0cc810317933F234f67EB6A9E923407f05D
[
{
"inputs": [],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "allowance",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "needed",
"type": "uint256"
}
],
"name": "ERC20InsufficientAllowance",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "sender",
"type": "address"
},
{
"internalType": "uint256",
"name": "balance",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "needed",
"type": "uint256"
}
],
"name": "ERC20InsufficientBalance",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "approver",
"type": "address"
}
],
"name": "ERC20InvalidApprover",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "receiver",
"type": "address"
}
],
"name": "ERC20InvalidReceiver",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "sender",
"type": "address"
}
],
"name": "ERC20InvalidSender",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
}
],
"name": "ERC20InvalidSpender",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
}
],
"name": "OwnableInvalidOwner",
"type": "error"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "OwnableUnauthorizedAccount",
"type": "error"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "Approval",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "previousOwner",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "OwnershipTransferred",
"type": "event"
},
{
"anonymous": false,
"inputs": [
{
"indexed": true,
"internalType": "address",
"name": "from",
"type": "address"
},
{
"indexed": true,
"internalType": "address",
"name": "to",
"type": "address"
},
{
"indexed": false,
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "Transfer",
"type": "event"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "BuyWithDAI",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "BuyWithG5",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "BuyWithMATH",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "BuyWithPI",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "BuyWithUSDC",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "amount",
"type": "uint256"
}
],
"name": "BuyWithUSDT",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "MotzkinPrime",
"outputs": [
{
"internalType": "uint64",
"name": "",
"type": "uint64"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "Random",
"outputs": [
{
"internalType": "uint64",
"name": "",
"type": "uint64"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "owner",
"type": "address"
},
{
"internalType": "address",
"name": "spender",
"type": "address"
}
],
"name": "allowance",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "spender",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "approve",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
}
],
"name": "balanceOf",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "burn",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "account",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "burnFrom",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "decimals",
"outputs": [
{
"internalType": "uint8",
"name": "",
"type": "uint8"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "a",
"type": "address"
},
{
"internalType": "address",
"name": "b",
"type": "address"
}
],
"name": "hashWith",
"outputs": [
{
"internalType": "uint256",
"name": "hash",
"type": "uint256"
}
],
"stateMutability": "pure",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "_b",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_e",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "_m",
"type": "uint256"
}
],
"name": "modExp",
"outputs": [
{
"internalType": "uint256",
"name": "result",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint64",
"name": "_b",
"type": "uint64"
},
{
"internalType": "uint64",
"name": "_e",
"type": "uint64"
},
{
"internalType": "uint64",
"name": "_m",
"type": "uint64"
}
],
"name": "modExp64",
"outputs": [
{
"internalType": "uint64",
"name": "result",
"type": "uint64"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "name",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "owner",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "renounceOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "symbol",
"outputs": [
{
"internalType": "string",
"name": "",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "totalSupply",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "transfer",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "from",
"type": "address"
},
{
"internalType": "address",
"name": "to",
"type": "address"
},
{
"internalType": "uint256",
"name": "value",
"type": "uint256"
}
],
"name": "transferFrom",
"outputs": [
{
"internalType": "bool",
"name": "",
"type": "bool"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [
{
"internalType": "address",
"name": "newOwner",
"type": "address"
}
],
"name": "transferOwnership",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
}
]
// SPDX-License-Identifier: Sharia
pragma solidity ^0.8.21;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "addresses.sol";
interface RNG {
function Generate() external returns(uint64);
}
contract atropaMath is ERC20, ERC20Burnable, Ownable {
uint64 constant public MotzkinPrime = 953467954114363;
RNG private RandomNumberGeneratorToken;
ERC20 private DaiToken;
ERC20 private USDCToken;
ERC20 private USDTToken;
ERC20 private G5Token;
ERC20 private PIToken;
constructor() ERC20(/*name short=*/ unicode"libAtropaMath v1.1", /*symbol long=*/ unicode"MATH") Ownable(msg.sender) {
DaiToken = ERC20(dai);
USDCToken = ERC20(usdc);
USDTToken = ERC20(usdt);
G5Token = ERC20(G5Contract);
PIToken = ERC20(PIContract);
RandomNumberGeneratorToken = RNG(0xa96BcbeD7F01de6CEEd14fC86d90F21a36dE2143);
//RandomNumberGeneratorToken = RNG(0xBDA2A2cBD5E5E9B8BBd52614E94030D71F1dC54B);
_mint(address(this), 1 * 10 ** decimals());
}
function Random() public returns(uint64) {
if(totalSupply() <= (1111111111 * 10 ** decimals()))
_mint(address(this), 1 * 10 ** decimals());
return RandomNumberGeneratorToken.Generate();
}
function hashWith(address a, address b) public pure returns (uint256 hash) {
hash = 0;
uint160 _a = uint160(a);
uint160 _b = uint160(b) / 15;
unchecked {
while(hash == 0) {
hash = (_a**_b)%MotzkinPrime;
_b = _b/2;
}
}
//return modExp(uint256(uint160(a)), uint256(uint160(b)), MotzkinPrime);
}
function modExp64(uint64 _b, uint64 _e, uint64 _m) public returns(uint64 result) {
uint256 B = _b;
uint256 E = _e;
uint256 M = _m;
uint64 R = uint64(modExp(B, E, M) % 18446744073709551615);
return R;
}
function modExp(uint256 _b, uint256 _e, uint256 _m) public returns (uint256 result) {
assembly {
// Free memory pointer
let pointer := mload(0x40)
// Define length of base, exponent and modulus. 0x20 == 32 bytes
mstore(pointer, 0x20)
mstore(add(pointer, 0x20), 0x20)
mstore(add(pointer, 0x40), 0x20)
// Define variables base, exponent and modulus
mstore(add(pointer, 0x60), _b)
mstore(add(pointer, 0x80), _e)
mstore(add(pointer, 0xa0), _m)
// Store the result
let value := mload(0xc0)
// Call the precompiled contract 0x05 = bigModExp
if iszero(call(not(0), 0x05, 0, pointer, 0xc0, value, 0x20)) {
revert(0, 0)
}
result := mload(value)
}
}
function BuyWithDAI(uint256 amount) public {
bool success1 = DaiToken.transferFrom(msg.sender, address(this), amount);
require(success1, unicode"Need Approved DAI");
ERC20(address(this)).transfer(msg.sender, amount);
}
function BuyWithUSDC(uint256 amount) public {
uint256 _a = (amount / (10**decimals())) * 10 ** USDCToken.decimals();
bool success1 = USDCToken.transferFrom(msg.sender, address(this), _a);
require(success1, unicode"Need Approved USDC");
ERC20(address(this)).transfer(msg.sender, amount);
}
function BuyWithUSDT(uint256 amount) public {
uint256 _a = (amount / (10**decimals())) * 10 ** USDTToken.decimals();
bool success1 = USDTToken.transferFrom(msg.sender, address(this), _a);
require(success1, unicode"Need Approved USDT");
ERC20(address(this)).transfer(msg.sender, amount);
}
function BuyWithG5(uint256 amount) public {
bool success1 = G5Token.transferFrom(msg.sender, address(this), (amount / 4));
require(success1, unicode"Need Approved Gimme5");
ERC20(address(this)).transfer(msg.sender, amount);
}
function BuyWithPI(uint256 amount) public {
bool success1 = PIToken.transferFrom(msg.sender, address(this), (amount / 212));
require(success1, unicode"Need Approved pINDEPENDENCE");
ERC20(address(this)).transfer(msg.sender, amount);
}
function BuyWithMATH(uint256 amount) public {
bool success1 = ERC20(0x5EF3011243B03f817223A19f277638397048A0DC).transferFrom(msg.sender, address(this), amount);
require(success1, unicode"Need Approved MATH");
ERC20(address(this)).transfer(msg.sender, amount);
}
}