Burn and static reflection on every trade functions to include in my smart contract

Hey everyone, I’ve been lurking around on this forum and you guys are amazing with the resolution of issues people may have so I hope you will be able to help me out

I started to write my BSC token’s smart contract and I believe I’m almost done. All I need left is to include a 11% tax on every transactions (4% redistributed to all holders of the token + 7% burned) but my issue is that I don’t know how to write those functions properly… I’ve found different answers about it on the forum but it always look like they are fitted for the poster’s demand/contract and I don’t want to just copy and paste and make a mistake.
I would also need a function to prevent from burning the whole supply to 0 cause this a long term project.

Could you guys help me out on this one please? Thank you so much I’d appreciate it

Also is there a special function to allocate a % of the total supply to the founders of the project or should I do it manually at the launch?

I included a screenshot of the smart contract as it is right now so you can check it out.

Thanks. Kind regards

2 Likes

No one is able is help me…? Frustrating…

1 Like

Hi @Egoleg , welcome to the forums this is quite a complicated and a somewhat philosophical question you are asking.

In your question you say

include a 11% tax on every transactions (4% redistributed to all holders of the token + 7% burned)

But then you say

I would also need a function to prevent from burning the whole supply to 0 cause this a long term project.

This a contradiction. When using a burn address you are making a deflationary token. But because you are using %, it won’t ever go to 0 because it’s taking less of an amount each time. But the point remains the same, if this is a long term token, then at some point you may reach supply issues. Some tokens opt to have a mint function based on what amount is being burned. It’s really up to your vision on what you want to do. Personally I disagree with deflationary and burn tokenomics.

Also is there a special function to allocate a % of the total supply to the founders of the project or should I do it manually at the launch?

This is up to you. When you deploy, where do you want your total supply to go? Does it go all to the owner, as it is typically done, then the owner disperses. Or does it go to holders that you have already decided?

I don’t know how to write those functions properly

Then it’s time to learn. Start with the basics of how to implement basic total supply and then experiment with splitting the total supply among a userbase upon deployment. The tutorials are great here and the template ERC20 token has all the functionality you need.

The hot project of the month is SafeMoon, which uses a combination of LIQ and RFI.

It has functionality you are desiring. If you are determined to take a tax and send it directly to the burn address then add a tax that specifically does that, using the RFI mechanisms.

Also read this if you haven’t already.

I hope this helps, and if you have specifics on why your function working, or how a function works then we will help answer that.

3 Likes

Thank you for your answer.

This a contradiction. When using a burn address you are making a deflationary token. But because you are using %, it won’t ever go to 0 because it’s taking less of an amount each time. But the point remains the same, if this is a long term token, then at some point you may reach supply issues.

I understand, thank you for pointing that out, sounds like I’ll have to change my plans.

Then it’s time to learn.

The hot project of the month is SafeMoon, which uses a combination of LIQ and RFI.
It has functionality you are desiring. If you are determined to take a tax and send it directly to the burn address then add a tax that specifically does that, using the RFI mechanisms.

I got this and once again I tried to learn from safemoon and RFI contracts, but there are so many lines that I can’t figure out which ones I should learn from, or even how they (or I in my case) set the amount that they’d like to be taxed,

That’s my issue, that’s the exact reason I was asking in my original post which exact funtions would work as a “4% redistribution and a 7% burn” cause looking at those contracts are confusing me more than anything, there are way too many lines for a beginner to understand how each function is working and can give the result he is looking for.

Also read this if you haven’t already.

The original poster said “I can’t figure out how to implement your burn code into my contract code.” and that’s the thing, there are a lot of lines and we can’t figure out which ones we should work with or personalize them for our contracts, you get my point?

And I know all those lines are working as one in the end, they all “pack” together to give the final effect they are set for, but how to personalize them for our needs?

I’d just need something with my numbers and exact purpose (no extra lines that would confuse me) to understand exactly which functions burn and which ones redistribute and how the amount is set up/calculated, you got my point?

1 Like

Hi @Egoleg,

You may want to post for Developer Wanted https://forum.openzeppelin.com/tag/developer-wanted if you want to partner with a developer or pay someone to create a contract for you.

Also some systems may have issues with deflationary tokens: see: Points to consider when creating a fungible token (ERC20, ERC777)

2 Likes

there are way too many lines for a beginner to understand how each function is working and can give the result he is looking for.

I understand that completely, if you see some of my topics I ask questions on RFI code too because some of it is not really clearly explained and even I don’t understand some of it. It’s tough being new to development, but there are forums to help you learn.

For SafeMoon let’s start with the variables.

uint256 public _taxFee = 5;

This looks suspiciously like a fee that is taken on every transaction. You can trace down the logic of where the code uses _taxFee to understand how the tax is being taken. And from there you would do the same to implement a new Fee variable.

If you have questions about specific code and how it works I can help as much as I can.

If your intent is to code these projects yourself, you should start with the beginner tutorials and work your way up. If you want someone else to code for you then I think you should look for developers here, reddit, discord, and telegram. There are plenty out there, but they will take a fee of some kind usually.

2 Likes

Hey, welcome!

A little complex, such as if you add the liquidity of your token and usdc in the uniswap, so now, the unsiwap contract is the token holder, and in your case, for every transaction, the uniswap will get external token, but it does not distribute to people who add liquidity, cause actually, they are token holders.

2 Likes

Hey, yes it’s definitely way more complex than I thought it would be.

I’m trying to crack up the safemoon code part mentioned by Tsushima, I’ll keep you guys updated…

2 Likes

I started by looking at the SFM protocol too.
Many tokens have copy pasted the same code, including SFM.
reflect.finance seems to be the base where all others copied from.
This is their .sol : https://github.com/reflectfinance/reflect-contracts/blob/main/contracts/REFLECT.sol

I understand a lot more now although I am still working on knowing all the details.

I think I found a way to add burn fees. So the contract will have 3 types of fees:

  1. fee to holders
  2. fee to burn address
  3. fee to liquidity

Is this only a fee Section or the whole Code ?

I think it’s the whole code.

if you need check here: https://github.com/FreezyEx

in your contract on github U have removed liquidity fee for charity fee. How is the lp supplied then? and Can you have all 4 using the burn address as one of the holders; thus adding liquidity with the same fee to holders?

Depend which contract are you looking to. Btw there are contracts which don’t have liquidity fee

Yes if you look at FuturovGovernance you will find a contract with 4 fees: LP, Holders, Marketing and Burn

1 Like

Can you please share the code for all the 3 , please ?

Have a look at my Safemoon rewrite which supports (in theory) as many fees as you’d like. The limit is only given by the max slippage a DEX will let you use … https://github.com/solidity-guru/safetoken

Also, if you have more questions check out our discord (see my profile for the link)

Hi Freezy, Your Sample of GuturovGovernance has in description only 3 fees, Burn, Lp and Holders. Can you send me a msg via tg : @Pistachio_Lounge ? I don’t understand how to change to specified percentage of the fees. In code is writed as a taxfee of “10**8” (your code has a 4.2069% taxfee) which i can’t understand how it comes to “10 ** 8”. I want to change the Tax fee with 12%, where 2% LP and 10% Holders. If you like to have a little talk on tg about this, i appreciate it!

The FuturovGovernanceToken code has been made based on determinated requests. I suggest to look at Deflationary Token