Search…
⌃K
Links
💰

Taxes

sERC20 takes full control when handling tax rates, there's no restrictions to the types of taxes you can have, there are however limits on the total round trip tax rate.

Restrictions

The buy tax threshold can be set as high as 35%, however the combination of the buy and sell tax thresholds can not exceed 35%.
The sell tax threshold can be set as high as 35%, however the combination of the buy and sell tax thresholds can not exceed 35%.
Round trip tax rates can not exceed 35%

Setting up taxes

constructor()
SERC20(
...
15,
15
)
{
...
uint256[] memory buyTaxes = new uint256[](2);
// Dev Tax
buyTaxes[0] = 8;
​
// Liq Tax
buyTaxes[1] = 2;
​
uint256[] memory sellTaxes = new uint256[](2);
// Dev Tax
sellTaxes[0] = 8;
​
// Liq Tax
sellTaxes[1] = 2;
​
_sercSetTaxes(buyTaxes, true);
_sercSetTaxes(sellTaxes, false);
...
}

Changing tax rates

The sERC20 contract does not implement any functionality to externally change your tax rates. This is because there are a wide variety of options available for taxing. To avoid restricting this customisability you are free to implement these methods yourself.

Examples

constructor()
SERC20(
...
15,
15
)
{
...
uint256[] memory buyTaxes = new uint256[](1);
// Dev Tax
buyTaxes[0] = 8;
​
uint256[] memory sellTaxes = new uint256[](1);
// Dev Tax
sellTaxes[0] = 8;
​
_sercSetTaxes(buyTaxes, true);
_sercSetTaxes(sellTaxes, false);
...
}
function setBuyTax(uint256 buyDevTax)
external
onlyOwner
{
uint256[] memory buyTaxes = new uint256[](1);
buyTaxes[0] = buyDevTax;
​
// uint256[] taxes, bool isBuy
_sercSetTaxes(buyTaxes, true);
}
​
function setSellTax(uint256 sellDevTax)
external
onlyOwner
{
uint256[] memory sellTaxes = new uint256[](1);
sellTaxes[0] = sellDevTax;
// uint256[] taxes, bool isBuy
_sercSetTaxes(buyTaxes, false);
}
constructor()
SERC20(
...
15,
15
)
{
...
uint256[] memory buyTaxes = new uint256[](3);
// Dev Tax
buyTaxes[0] = 4;
// Marketing Tax
buyTaxes[1] = 4;
​
// Liq Tax
buyTaxes[2] = 2;
​
uint256[] memory sellTaxes = new uint256[](3);
// Dev Tax
sellTaxes[0] = 8;
// Marketing Tax
sellTaxes[1] = 4;
​
// Liq Tax
sellTaxes[2] = 2;
_sercSetTaxes(sellTaxes, false);
...
}
function setBuyTax(uint256 buyDevTax, uint256 buyMarketingTax, uint256 buyLiqTax)
external
onlyOwner
{
uint256[] memory buyTaxes = new uint256[](3);
buyTaxes[0] = buyDevTax;
buyTaxes[1] = buyMarketingTax;
buyTaxes[2] = buyLiqTax;
// uint256[] taxes, bool isBuy
_sercSetTaxes(buyTaxes, true);
}
​
function setSellTax(uint256 sellDevTax, uint256 sellMarketingTax, uint256 sellLiqTax)
external
onlyOwner
{
uint256[] memory sellTaxes = new uint256[](3);
sellTaxes[0] = sellDevTax;
sellTaxes[1] = sellMarketingTax;
sellTaxes[2] = sellLiqTax;
​
// uint256[] taxes, bool isBuy
_sercSetTaxes(sellTaxes, false);
}

Reading tax rates

The sERC20 contract exposes functions for reading the current tax rates. You should NEVER handle these yourself, always refer to our built in methods to maintain your sERC20 implementation integrity.

Retrieve the array of buy taxes

// External usage
function sercBuyTax() public view returns (uint256[] memory)
​
// Internal usage
function _sercBuyTax() internal view returns (uint256[] memory)

Retrieve the total buy taxes

// External usage
function sercBuyTotalTax() public view returns (uint256)
​
// Internal usage
function _sercBuyTotalTax() internal view returns (uint256)

Retrieve the array of sell taxes

// External usage
function sercSellTax() public view returns (uint256[] memory)
​
// Internal usage
function _sercSellTax() internal view returns (uint256[] memory)

Retrieve the total sell taxes

// External usage
function sercSellTotalTax() public view returns (uint256)
​
// Internal usage
function _sercSellTotalTax() internal view returns (uint256)
Remember! ALWAYS use our build in methods any time you access state that can be controlled by sERC20, doing otherwise compromises your implementation integrity.