Why do i keep get Gas estimation failed on Mainnet

Please i need some help on a smart contract am working on.
the contract works on Goerli testnet but when i try to deploy it on mainnet i get an error message saying Gas estimation failed.
(Gas estimation errored with the following message (see below). the transaction execution will likely fail. Do you want to force sending?
Returned error: {"jsonrpc":2.0","error":"contract creation code storage out of gas","id":799594..........}

Here is the code on Goerli testnet if anyone can check the code and let me know what am doing wrong as am trying to create a token.

Here is a way for you to find out:

  1. Compile the contract
  2. Create the deployment transaction (signed with your private key)
  3. Call estimateGas on the transaction created in step 2
  4. If step 3 failed, then remove the last line of code in the constructor and go back to step 1
  5. The problem is in the line of code which you have just removed

In order to speed up the process, you can remove a few lines of code at each iteration.
Specifically, you can remove a bunch of lines which seem harmless (e.g., simple initializations, etc).
Most likely, the problem is where you call a function in another contract (e.g., in the uniswap contract).

By the way, I tried my own suggestion above, and I was able to do so without changing anything in the code.

The gas required for this deployment is 6039645, which is very high, so perhaps that's where the problem is.

I didn't even compile the contract, I just used the Contract Creation Code from the Etherscan link in your question.

Here is the deployment script in case you're interested (based on web3.js):

const Web3 = require("web3");

const NODE_ADDRESS   = "https://mainnet.infura.io/v3/PasteYourInfuraProjectIdHere";
const CONTRACT_ABI   = Paste the `Contract ABI` in here;
const CONTRACT_CODE  = "Paste the `Contract Creation Code` in here";
const WALLET_ADDRESS = "0x0000000000000000000000000000000000000001";

async function run() {
    const web3        = new Web3(NODE_ADDRESS);
    const contract    = new web3.eth.Contract(CONTRACT_ABI);
    const options     = {data: CONTRACT_CODE};
    const transaction = contract.deploy(options);
    const gas         = await transaction.estimateGas({from: WALLET_ADDRESS});
    console.log(gas.toString());
    if (web3.currentProvider.disconnect) {
        web3.currentProvider.disconnect();
    }
}

run();

Note that WALLET_ADDRESS can be any 160-bit value, since we're not really using the private kwy of that wallet in order to sign the transaction - any value except for zero, in order to avoid execution reverted: ERC20: mint to the zero address, which would be thrown on your attempt to mint tokens for msg.sender at the very end of the contract's constructor.