Working tree is now the canonical repo. Off-chain play-money + trustless on-chain (FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution, mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
35 lines
1.0 KiB
Solidity
35 lines
1.0 KiB
Solidity
// Copyright (C) 2020 d-xo
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
pragma solidity >=0.6.12;
|
|
|
|
import {ERC20} from "./ERC20.sol";
|
|
|
|
contract TransferFeeToken is ERC20 {
|
|
|
|
uint immutable fee;
|
|
|
|
// --- Init ---
|
|
constructor(uint _totalSupply, uint _fee) ERC20(_totalSupply) public {
|
|
fee = _fee;
|
|
}
|
|
|
|
// --- Token ---
|
|
function transferFrom(address src, address dst, uint wad) override public returns (bool) {
|
|
require(balanceOf[src] >= wad, "insufficient-balance");
|
|
if (src != msg.sender && allowance[src][msg.sender] != type(uint).max) {
|
|
require(allowance[src][msg.sender] >= wad, "insufficient-allowance");
|
|
allowance[src][msg.sender] = sub(allowance[src][msg.sender], wad);
|
|
}
|
|
|
|
balanceOf[src] = sub(balanceOf[src], wad);
|
|
balanceOf[dst] = add(balanceOf[dst], sub(wad, fee));
|
|
balanceOf[address(0)] = add(balanceOf[address(0)], fee);
|
|
|
|
emit Transfer(src, dst, sub(wad, fee));
|
|
emit Transfer(src, address(0), fee);
|
|
|
|
return true;
|
|
}
|
|
}
|