I am trying to deploy a deflationary token to Uniswap V3.
pragma solidity ^0.8.0;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v4.1/contracts/token/ERC20/ERC20.sol";
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/release-v4.1/contracts/utils/math/SafeMath.sol";
contract SARToken is ERC20("Saren", "SAR") {
using SafeMath for uint256;
uint8 public decimals = 2;
address internal feeAccount;
uint256 internal maxTransferFee = 50000;
uint8 internal transferFeePercentage = 2;
constructor() public {
_mint(msg.sender, 1000000000 * (10 ** uint256(decimals())));
}
/**
* @dev Transfer tokens to a specified account after diverting a fee to a central account.
* @param _to The receiving address.
* @param _value The number of tokens to transfer.
*/
function transfer(address _to, uint256 _value) public returns (bool) {
require(_value % (uint256(10) ** decimals) == 0);
uint256 fee = Math.min256(_value.mul(transferFeePercentage).div(100), maxTransferFee);
uint256 taxedValue = _value.sub(fee);
require(super.transfer(feeAccount, fee));
require(super.transfer(_to, taxedValue));
return true;
}
}
Things I have tried
pragma solidity ^0.5.0;
import "@openzeppelin/upgrades/contracts/Initializable.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20Detailed.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20Mintable.sol";
import "@openzeppelin/contracts-ethereum-package/contracts/token/ERC20/ERC20Pausable.sol";
/**
* @title MyToken
* @dev ERC20 Token example, where all tokens are pre-assigned to the creator.
* Note they can later distribute these tokens as they wish using `transfer` and other
* `ERC20` functions.
*/
contract MyToken is Initializable, ERC20, ERC20Detailed, ERC20Mintable, ERC20Pausable {
uint256 private _minimumSupply;
/**
* @dev Gives holder all of existing tokens.
*/
function initialize(address holder, address minter, address pauser) public initializer {
ERC20Detailed.initialize("MyToken", "MYT", 18);
ERC20Mintable.initialize(minter);
ERC20Pausable.initialize(pauser);
_minimumSupply = 2000 * (10 ** 18);
_mint(holder, 10000 * (10 ** uint256(decimals())));
}
function transfer(address to, uint256 amount) public returns (bool) {
return super.transfer(to, _partialBurn(amount));
}
function transferFrom(address from, address to, uint256 amount) public returns (bool) {
return super.transferFrom(from, to, _partialBurn(amount));
}
function _partialBurn(uint256 amount) internal returns (uint256) {
uint256 burnAmount = _calculateBurnAmount(amount);
if (burnAmount > 0) {
_burn(msg.sender, burnAmount);
}
return amount.sub(burnAmount);
}
function _calculateBurnAmount(uint256 amount) internal view returns (uint256) {
uint256 burnAmount = 0;
// burn amount calculations
if (totalSupply() > _minimumSupply) {
burnAmount = amount.mul(3).div(100);
uint256 availableBurn = totalSupply().sub(_minimumSupply);
if (burnAmount > availableBurn) {
burnAmount = availableBurn;
}
}
return burnAmount;
}
}
https://github.com/OpenZeppelin/openzeppelin-contracts/issues/787
What I am looking for?
So I am a dev and just playing around with token transfer taxes etc for research purposes. My code works but there are some issues.
If you add seller tax to a token you cannot remove liquidity from uniswap v3 and if you add a buyer tax to a token you cannot add liquidity it to uniswap v3.
It does not give me an error it just gives me a failed
Error: MetaMask - RPC Error: The execution failed due to an exception.
With the data "Reverted"
I am just trying to understand what is causing this so I can implement another method to do this or find out if it simply cannot be done because of the Liquidity being added into NFT's instead of a token.