Verified contractPartialMIT
ETFSwap
Address0xf43eee4feb1e2c84000622780f93f1090e856433
- Balance
0 ETH
- Transactions
4
- Compiler
solc 0.8.19
- Same code
Only this contract
Details
- Compiler
- solc 0.8.19+commit.7dd6d404
- Language
- solidity
- Optimization
- No
- EVM version
- paris
- License
- MIT
- Match
- Partialcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 19,691,276
- Creation transaction
- 0xc698fad286…8174b2c733
2 files
- ETFSwap.solmain7.72 KB
- IERC20.sol1.29 KB
ETFSwap.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import "./IERC20.sol";
// Main contract for the ETFSwap token
contract ETFSwap {
string public constant name = "ETFSwap";
string public constant symbol = "ETFS";
uint8 public constant decimals = 18;
uint256 public constant TOTAL_SUPPLY = 1_000_000_000 * (10 ** uint256(decimals));
// Define initial allocation constants
uint256 public constant PRESALE_ALLOCATION = 400_000_000 * (10 ** uint256(decimals));
uint256 public constant ECOSYSTEM_ALLOCATION = 240_000_000 * (10 ** uint256(decimals));
uint256 public constant LIQUIDITY_ALLOCATION = 120_000_000 * (10 ** uint256(decimals));
uint256 public constant TEAM_ALLOCATION = 60_000_000 * (10 ** uint256(decimals));
uint256 public constant MM_ALLOCATION = 60_000_000 * (10 ** uint256(decimals));
uint256 public constant CASHBACK_ALLOCATION = 50_000_000 * (10 ** uint256(decimals));
uint256 public constant PARTNERS_ALLOCATION = 30_000_000 * (10 ** uint256(decimals));
uint256 public constant COMMUNITY_REWARDS_ALLOCATION = 40_000_000 * (10 ** uint256(decimals));
// Tax rates
uint8 public sellTaxRate;
uint8 public buyTaxRate;
// Address of the contract owner
address public owner;
// Mapping to store token balances of addresses
mapping(address => uint256) balances;
// Mapping to store allowances for token transfers
mapping(address => mapping(address => uint256)) allowed;
// Liquidity Pair Address
address public liquidityPairAddress;
// Constructor to initialize contract and mint initial allocations
constructor() {
owner = msg.sender;
// Mint initial allocations
balances[msg.sender] += PRESALE_ALLOCATION;
balances[msg.sender] += ECOSYSTEM_ALLOCATION;
balances[msg.sender] += LIQUIDITY_ALLOCATION;
balances[msg.sender] += CASHBACK_ALLOCATION;
balances[msg.sender] += PARTNERS_ALLOCATION;
balances[msg.sender] += COMMUNITY_REWARDS_ALLOCATION;
balances[msg.sender] += MM_ALLOCATION;
balances[msg.sender] += TEAM_ALLOCATION;
uint256 TOTAL_TOKENS_TRANSFERRED = PRESALE_ALLOCATION +
ECOSYSTEM_ALLOCATION +
LIQUIDITY_ALLOCATION +
CASHBACK_ALLOCATION +
PARTNERS_ALLOCATION +
COMMUNITY_REWARDS_ALLOCATION +
MM_ALLOCATION +
TEAM_ALLOCATION;
emit Transfer(address(0), msg.sender, TOTAL_TOKENS_TRANSFERRED);
}
// Modifier to restrict access to the owner
modifier onlyOwner() {
require(msg.sender == owner, "Only the owner can call this function.");
_;
}
// Function to return the total token supply
function totalSupply() public pure returns (uint256) {
return TOTAL_SUPPLY;
}
// Function to return the balance of the specified address
function balanceOf(address tokenOwner) public view returns (uint256 balance) {
return balances[tokenOwner];
}
// Function to set liquidity pair address
function setLiquidityPairAddress(address _liquidityPairAddress) external onlyOwner {
require(_liquidityPairAddress != address(0), "Liquidity Pair can't be a null address");
require(_liquidityPairAddress != liquidityPairAddress, "New liquidity pair address is the same as the current one");
liquidityPairAddress = _liquidityPairAddress;
emit LiquidityPairAddressSet(_liquidityPairAddress, msg.sender, block.timestamp);
}
// Internal function to handle token transfer
function _transferTokens(address from, address to, uint256 tokens) internal {
require(to != address(0), "Invalid address");
require(balances[from] >= tokens, "Insufficient balance");
uint256 taxAmount = calculateTaxAmount(from, to, tokens);
uint256 transferAmount = tokens - (taxAmount);
balances[from] = balances[from] - (tokens);
balances[to] = balances[to] + (transferAmount);
balances[owner] = balances[owner] + (taxAmount);
emit Transfer(from, to, transferAmount);
emit Transfer(from, owner, taxAmount);
}
// Function to transfer tokens from the caller's account to the specified recipient
function transfer(address to, uint256 tokens) public returns (bool success) {
_transferTokens(msg.sender, to, tokens);
return true;
}
// Function to handle token transfers from one address to another using allowances
function transferFrom(address from, address to, uint256 tokens) public returns (bool success) {
require(allowed[from][msg.sender] >= tokens, "Allowance exceeded");
_transferTokens(from, to, tokens);
allowed[from][msg.sender] = allowed[from][msg.sender] - (tokens);
return true;
}
//INCREASE ALLOWANCE
function increaseAllowance(address spender, uint256 addedValue) public returns (bool) {
require(spender != address(0), "Invalid spender address");
allowed[msg.sender][spender] += addedValue;
emit Approval(msg.sender, spender, allowed[msg.sender][spender]);
return true;
}
// DECREASE ALLOWANCE
function decreaseAllowance(address spender, uint256 subtractedValue) public returns (bool) {
require(spender != address(0), "Invalid spender address");
uint256 oldValue = allowed[msg.sender][spender];
if (subtractedValue >= oldValue) {
allowed[msg.sender][spender] = 0;
} else {
allowed[msg.sender][spender] -= subtractedValue;
}
emit Approval(msg.sender, spender, allowed[msg.sender][spender]);
return true;
}
// Function to calculate tax amount based on sender and recipient addresses
function calculateTaxAmount(address from, address to, uint256 tokens) private view returns (uint256) {
if (from == liquidityPairAddress) {
// Apply buy tax rate if the tokens are being transferred by the owner
return (tokens * buyTaxRate) / (100);
} else if (to == address(0) || to == owner || to == liquidityPairAddress) {
// Apply sell tax rate if the tokens are being transferred to owner, zero address, or liquidity pair
return (tokens * sellTaxRate) / (100);
} else {
// No tax for other cases
return 0;
}
}
// Function to set the sell tax rate
function setSellTaxRate(uint8 newSellTaxRate) external onlyOwner {
require(newSellTaxRate <= 25, "Sell tax rate must be less than or equal to 25%");
sellTaxRate = newSellTaxRate;
emit SellTaxRateSet(newSellTaxRate);
}
// Function to set the buy tax rate
function setBuyTaxRate(uint8 newBuyTaxRate) external onlyOwner {
require(newBuyTaxRate <= 25, "Buy tax rate must be less than or equal to 25%");
buyTaxRate = newBuyTaxRate;
emit BuyTaxRateSet(newBuyTaxRate);
}
//RENOUNCE OWNERSHIP
function renounceOwnership() public onlyOwner {
emit OwnershipTransferred(owner, address(0));
owner = address(0);
}
// Events
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
event SellTaxRateSet(uint256 newSellTaxRate);
event BuyTaxRateSet(uint256 newBuyTaxRate);
event LiquidityPairAddressSet(address indexed pairAddress, address indexed setter, uint256 timestamp);
}
IERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
interface IERC20 {
// Returns the total token supply
function totalSupply() external view returns (uint256);
// Returns the token balance of the specified address
function balanceOf(address account) external view returns (uint256);
// Transfers tokens from the caller's account to the specified recipient
function transfer(address recipient, uint256 amount) external returns (bool);
// Returns the remaining number of tokens that spender will be allowed to spend on behalf of owner
function allowance(address owner, address spender) external view returns (uint256);
// Sets amount as the allowance of spender over the caller's tokens
function approve(address spender, uint256 amount) external returns (bool);
// Moves amount tokens from sender to recipient using the allowance mechanism
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
// Triggered when tokens are transferred
event Transfer(address indexed from, address indexed to, uint256 value);
// Triggered when the allowance of a spender for an owner is set by a call to approve
event Approval(address indexed owner, address indexed spender, uint256 value);
}Compiler settingsShow
{
"metadata": {
"bytecodeHash": "ipfs"
},
"libraries": {},
"optimizer": {
"runs": 200,
"enabled": false
},
"evmVersion": "paris",
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.