I can't find how/when PancakeSwap take it 0.25% fee from trades, Nothing points to it taking any fees!

What I tried:

-Fetched my bnb balance.

-Fetched Liquidity pool of a token.

-Made a buy transaction.

-Fetched Liquidity pool of a token again.

-Fetched my bnb balance again.


-Initial BNB balance: 0.061694940013323232

-After buy transaction: 0.060829815013323232 (Buy 0.00001 + Gas 0.000855125)

-Token address: 0xc709878167ed069aea15fd0bd4e9758ceb4da193 (Day Of Defeat 19% TAX)

-Buy transaction: https://bscscan.com/tx/0xa660eb5e16d872e29bf7caf7d7c5ef999a36cfdb488c05c1554587543d7151cf

-Initial LP: 4306.338723965573665600 BNB 1793846330848.225230596341489117 DOD

-After transaction LP: 4306.338733965573665600 BNB 1793846326693.044169436006428854 DOD

-Received tokens: 4155.181061160335060263 - 19% TAX = 3365.696659539871398814 DOD


LP BNB DIFF: 4306.338733965573665600 - 4306.338723965573665600 = 0.00001

LP TOKEN DIFF: 1793846330848.225230596341489117 - 1793846326693.044169436006428854 = 4155.181061160335060263

As you can see swap fee no where to be seen...

So my question is, When does PancakeSwap take it 0.25% fee from trades ?

1 Answer 1


I asked the question in Reddit and got a response.


Took me some time.The fee is already included in all the transactions. When you put in 0.00001 BNB and the contract decides to give you 4155 DOD, that amount that it decides to spit out reflects the 0.25% fee. If there was no fee, the contract would have decided to give you instead 4165. This would be the case if the calculation was a simple k = tok1balance * tok2balance, but it is changed to reflect the fee.

// if fee is on, mint liquidity equivalent to 8/25 of the growth in sqrt(k)
function _mintFee(uint112 _reserve0, uint112 _reserve1) private returns (bool feeOn) { 
    address feeTo = IPancakeFactory(factory).feeTo();
    feeOn = feeTo != address(0);
    uint _kLast = kLast; // gas savings
    if (feeOn) {
        if (_kLast != 0) { 
            uint rootK = Math.sqrt(uint(_reserve0).mul(_reserve1));
            uint rootKLast = Math.sqrt(_kLast);
            if (rootK > rootKLast) { 
                uint numerator = totalSupply.mul(rootK.sub(rootKLast)).mul(8); 
                uint denominator = rootK.mul(17).add(rootKLast.mul(8)); 
                uint liquidity = numerator / denominator;
                if (liquidity > 0) 
                    _mint(feeTo, liquidity);
    } else if (_kLast != 0) { 
        kLast = 0; 

from https://bscscan.com/address/0xf26d328178cf6f011a3150dfe0282ff0f7c33a27#code


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.