Background:
Taxes are an important component for many token economies to balance inflationary emissions. Major AMMs such as Pancake Swap accommodate token taxes via slippage adjustments. The buyer/seller must adjust slippage to accommodate the tax to execute the transaction.
In the NEKO tokenomics there is a 5% tax on every swap. Half (2.5%) of the NEKO tax is automatically burned; creating a deflationary mechanic. The remaining 2.5% NEKO tax is deposited into the Fortune Cookie Vault where it is distributed back to the community.
The NEKO tax distribution is verifiable on chain. The burn and transfer to vault are logged inside every swap transaction receipt. Also, the NEKO tax percentage reduces over time as the emissions rate declines. This balances deflationary and inflationary pressures.
Issue:
Ref swaps do not support a tax on NEP-141 tokens.
Attempted Solutions:
We have tried two different methods to implement the NEKO 5% tax function. See below.
Process #1:
If we input 1000 NEKO on Ref swapping UI and have our contract calculate the tax in ft_transfer_call function, and pass the taxed amount to ft_on_transfer.
ext_fungible_token_receiver::ft_on_transfer(
sender_id.clone(),
amount_after_tax.into(),
msg,
receiver_id.clone(),
NO_DEPOSIT,
env::prepaid_gas() - GAS_FOR_FT_TRANSFER_CALL,
)then(ext_self::ft_resolve_transfer(…
Since Ref is expecting 1000 NEKO but only 950 (taxed) NEKO is actually transferred, Ref will return error : account not enough deposit
Process #2:
We don’t change the value pass to ft_on_transfer but instead tax user during ft_resolve_transfer ON TOP OF the amount they need to swap.
If we do process #2 the transaction will succeed. However, the user will never able to use the max swap amount again since they always need to have spare tokens to cover the 5% tax. This is very unintuitive and will result in frequent failed transactions.
Contract Upgrade:
Line 65:
const halfValue = percentOfBigNumber(50, max, token?.decimals);
//Addition check for NEKO
if (token.token_id == “ft.nekotoken.near”){
max = percentOfBigNumber(95, max, token?.decimals);
//Addition line end
}
Conclusion:
This contract upgrade can be implemented for future tokens that utilize a tax to balance their token economy.
The upgrade will allow tokens with more advanced tokenomics to flourish and evolve on NEAR Protocol. There has been at least one project that moved operations from NEAR to another chain due to the lack of token tax support by top AMMs. This is hurting the growth of the NEAR ecosystem.