Verified contractExactMIT
DeFiUnitedFund
Address0x5e29f34883bc93359d07a2aaaa973880c5b2c648
- Balance
0 ETH
- Transactions
177
- Compiler
solc 0.8.24
- Same code
Only this contract
Details
- Compiler
- solc 0.8.24+commit.e11b9ed9
- Language
- solidity
- Optimization
- Yes, 200 runs
- License
- MIT
- Match
- Exactcreation code: yes, runtime code: yes
- Verified on Sourcify
- Created in block
- 24,951,818
- Creation transaction
- 0xf890a5f136…3ab9b7f201
Defi United.sol
// SPDX-License-Identifier: MIT
/*
* DeFi United Fund ($DU) — v2
*
* 5% tax on every buy and sell. Tax accumulates as DU inside the contract,
* then auto-swaps to ETH on the next sell (when threshold is reached) and
* forwards the ETH directly to the DeFi United Fund multisig.
*
* https://defiunited.world/
*
*/
pragma solidity 0.8.24;
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
}
interface IERC20 {
function totalSupply() external view returns (uint256);
function balanceOf(address account) external view returns (uint256);
function transfer(address recipient, uint256 amount) external returns (bool);
function allowance(address owner, address spender) external view returns (uint256);
function approve(address spender, uint256 amount) external returns (bool);
function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
}
contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() { _owner = _msgSender(); emit OwnershipTransferred(address(0), _msgSender()); }
function owner() public view returns (address) { return _owner; }
modifier onlyOwner() { require(_owner == _msgSender(), "Ownable: caller is not the owner"); _; }
function renounceOwnership() public virtual onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
}
interface IUniswapV2Factory {
function createPair(address tokenA, address tokenB) external returns (address pair);
}
interface IUniswapV2Router02 {
function factory() external pure returns (address);
function WETH() external pure returns (address);
function swapExactTokensForETHSupportingFeeOnTransferTokens(
uint amountIn,
uint amountOutMin,
address[] calldata path,
address to,
uint deadline
) external;
}
contract DeFiUnitedFund is Context, IERC20, Ownable {
// Immutable tax destination. Cannot be changed.
address public constant FUND_WALLET = 0x0fCa5194baA59a362a835031d9C4A25970effE68;
uint256 public constant TAX_BPS = 500; // 5%
mapping(address => uint256) private _balances;
mapping(address => mapping(address => uint256)) private _allowances;
uint8 private constant _decimals = 18;
uint256 private constant _tTotal = 1_000_000_000 * 10 ** _decimals;
string private constant _name = "DeFi United Fund";
string private constant _symbol = "DU";
uint256 public _maxTxAmount = _tTotal / 100; // 1%
uint256 public _maxWalletSize = _tTotal / 100; // 1%
bool public limitsEnabled = true;
bool public tradingOpen;
// Auto-swap tax config
uint256 public swapThreshold = _tTotal / 10000; // 0.01% = 100,000 DU accumulated triggers a swap
uint256 public maxSwap = _tTotal / 100; // 1% max per swap (keeps price impact bounded)
bool public swapEnabled = true;
bool private _inSwap;
IUniswapV2Router02 public immutable uniswapV2Router;
address public immutable uniswapV2Pair;
event LimitsRemoved();
event TradingOpened();
event TaxSwapped(uint256 tokensSwapped);
modifier lockSwap { _inSwap = true; _; _inSwap = false; }
constructor() {
_balances[_msgSender()] = _tTotal;
uniswapV2Router = IUniswapV2Router02(0x7a250d5630B4cF539739dF2C5dAcb4c659F2488D);
uniswapV2Pair = IUniswapV2Factory(uniswapV2Router.factory())
.createPair(address(this), uniswapV2Router.WETH());
emit Transfer(address(0), _msgSender(), _tTotal);
}
// Accept ETH (router refunds dust after unwrap)
receive() external payable {}
// --- ERC20 views ---
function name() public pure returns (string memory) { return _name; }
function symbol() public pure returns (string memory) { return _symbol; }
function decimals() public pure returns (uint8) { return _decimals; }
function totalSupply() public pure override returns (uint256) { return _tTotal; }
function balanceOf(address a) public view override returns (uint256) { return _balances[a]; }
function allowance(address o, address s) public view override returns (uint256) { return _allowances[o][s]; }
// --- ERC20 writes ---
function transfer(address to, uint256 amt) public override returns (bool) {
_transfer(_msgSender(), to, amt);
return true;
}
function approve(address s, uint256 amt) public override returns (bool) {
_approve(_msgSender(), s, amt);
return true;
}
function transferFrom(address from, address to, uint256 amt) public override returns (bool) {
_transfer(from, to, amt);
uint256 current = _allowances[from][_msgSender()];
if (current != type(uint256).max) {
_approve(from, _msgSender(), current - amt);
}
return true;
}
function _approve(address o, address s, uint256 amt) private {
require(o != address(0) && s != address(0));
_allowances[o][s] = amt;
emit Approval(o, s, amt);
}
// --- core transfer ---
function _transfer(address from, address to, uint256 amount) private {
require(from != address(0) && to != address(0) && amount > 0);
bool isBuy = (from == uniswapV2Pair);
bool isSell = (to == uniswapV2Pair);
bool isPrivileged = (from == owner() || to == owner() || from == address(this));
uint256 tax = 0;
if (!isPrivileged && !_inSwap) {
require(tradingOpen, "trading not open");
if (limitsEnabled) {
if (isBuy || isSell) require(amount <= _maxTxAmount, "maxTx");
if (!isSell) require(balanceOf(to) + amount <= _maxWalletSize, "maxWallet");
}
if (isBuy || isSell) {
tax = amount * TAX_BPS / 10_000;
}
// Auto-swap accumulated tax on SELLS (piggyback on existing sell pressure)
if (isSell && swapEnabled && _balances[address(this)] >= swapThreshold) {
uint256 swapAmt = _balances[address(this)];
if (swapAmt > maxSwap) swapAmt = maxSwap;
_swapTokensForEth(swapAmt);
}
}
_balances[from] -= amount;
_balances[to] += amount - tax;
emit Transfer(from, to, amount - tax);
if (tax > 0) {
_balances[address(this)] += tax;
emit Transfer(from, address(this), tax);
}
}
function _swapTokensForEth(uint256 tokenAmount) private lockSwap {
address[] memory path = new address[](2);
path[0] = address(this);
path[1] = uniswapV2Router.WETH();
_approve(address(this), address(uniswapV2Router), tokenAmount);
uniswapV2Router.swapExactTokensForETHSupportingFeeOnTransferTokens(
tokenAmount, 0, path, FUND_WALLET, block.timestamp
);
emit TaxSwapped(tokenAmount);
}
// --- owner controls ---
// Manual drain if auto-swap is ever disabled or stuck.
function manualTaxSwap() external onlyOwner {
uint256 bal = _balances[address(this)];
require(bal > 0, "no tax to swap");
uint256 amt = bal > maxSwap ? maxSwap : bal;
_swapTokensForEth(amt);
}
function setSwapConfig(uint256 threshold, uint256 maxPerSwap, bool enabled) external onlyOwner {
swapThreshold = threshold;
maxSwap = maxPerSwap;
swapEnabled = enabled;
}
function removeLimits() external onlyOwner {
limitsEnabled = false;
_maxTxAmount = _tTotal;
_maxWalletSize = _tTotal;
emit LimitsRemoved();
}
function openTrading() external onlyOwner {
require(!tradingOpen, "already open");
tradingOpen = true;
emit TradingOpened();
}
}
Compiler settingsShow
{
"optimizer": {
"runs": 200,
"enabled": true
},
"remappings": []
}Source code and metadata: Sourcify.
The source code belongs to the authors of the contract.