pancakeswap / pancake-swap-interface-v1

:pancakes: Pancake trading interface V1
https://exchange.pancakeswap.finance
GNU General Public License v3.0
315 stars 948 forks source link

PancakeSwap on Testnet with some liquidity using token from testnet faucet #365

Open BeezBeez opened 3 years ago

BeezBeez commented 3 years ago

Problem encountered :

When trying to develop protocol and apps using BSC it's blocking to don't be able to test some various swap though PCS in testnet. Uniswap seem like to support testnet swap already. There's always the solution to fork ourself PCS front-end and contracts on testnet but this is an individual version and it's more complicated to get more affinated data when we are alone on our testnet interface... There are already a Testnet PCS provided by the community but they or don't work, are dead, or just don't have liquidity at all... In short there's no viable solution for now...

Exemple : https://kiemtienonline360.github.io/bsc-swap-simulation/pancake/#/swap

Feature request :

Even if the testnet doesn't bring value to the PCS dev team. It could be really helpful to consider implementing PCS ecosystem (At least the swap/liquidity feature) to the BSC Testnet and provide liquidity to it ! 👍 The default liquidity should use the tokens from this official faucet and adopt them as a standard for BSC Testnet : https://testnet.binance.org/faucet-smart

More info about the situation :

The solution to fork the mainnet on a localnet doesn't seem like to work by using ganache-cli. Connecting the wallet in testnet on mainnet PCS Swap Application work but after you can't provide liquidity yourself or swap.

DaManJ commented 3 years ago

agree with the above.

Connecting the wallet in testnet on mainnet PCS Swap Application work but after you can't provide liquidity yourself or swap.

Had this same issue. Also tried running pancake swap on my local machine from the source code. But cannot run the version 2 stuff as all the V2 links redirect to the public internet. And the V1 stuff does not allow adding liquidity.

Also I can't find in the source-code where to put the address of the pancake swap router for binance testnet. Maybe i'm not looking hard enough but I would have thought this should live in the .env.development file.

Edit: ah, found in another comment router address is in the pancake-swap-interface-v1-master\src\constants\index.ts file.

DaManJ commented 3 years ago

well, if anyone else is facing this issue, you have to reverse the changes from this check-in to be able to test on testnet. That is until pancake-swap makes v2 available on github I presume.

https://github.com/pancakeswap/pancake-swap-interface-v1/pull/390/files/17f9b3102f44ab312c4e29805d9638bf6b364f08

The router address to put in this file (pancake-swap-interface-v1-master\src\constants\index.ts) for testnet is: 0xD99D1c33F9fC3444f8101754aBC46c52416550D1

.env file can contain the following:

REACT_APP_NETWORK_URL="https://data-seed-prebsc-1-s1.binance.org:8545" REACT_APP_CHAIN_ID="97" REACT_APP_GTAG = "GTM-PXLD3XW"

Edit: actually above still does not work. All I succeeded in doing was to create the liquidity pool and add liquidity to it. The swap & liquidity screens still can't find the pool after that pool is created. I've tried updating the WBNB address in the pancake code to it's testnet address (0xae13d989dac2f0debff460ac112a837c89baa7cd) where I could find it, as I was thinking the reason it can't find the pair after creation is because it is passing the wrong WBNB address into the function that generates the pair address. But I couldn't get that to work either.

Currently i'm trying this test version that someone deployed. https://kiemtienonline360.github.io/ It's router address is at 0x9ac64cc6e4415144c455bd8e4837fea55603e5c3.

DiveInto commented 3 years ago

hi @DaManJ , how did you "create the liquidity pool and add liquidity to it"?

simply call addLiquidityETH, pool will be auto-created if not existed yet

derekzx commented 3 years ago

Did you manage to withdraw liquidity? Removing liquidity gives me a ds-math-sub-underflow' error similar to this:

Pancakeswap Router: https://testnet.bscscan.com/tx/0x116536e075875c04223b0bf88247dc7c693f1323d4f5542e4a4e6972673d7159

Router that was posted above (0x9ac64.....): https://testnet.bscscan.com/tx/0x6f7400e899b3e14532cfc31e0e7878809f701ead9cceaf430a2890145d6df438

binpmxstn commented 3 years ago

We've managed to run PancakeSwap testnet. Here's a source code

https://github.com/neptune-mutual/pancakeswap-testnet

and the hosted version

https://pancake-test.pages.dev/

danvaneijck commented 3 years ago

I managed to add liquidity for my token on the test net using the link above. However once i receive the lp tokens, pancakeswap cannot see the liquidity pool so I cannot unstake

kowsikgelli commented 3 years ago

I managed to add liquidity for my token on the test net using the link above. However once i receive the lp tokens, pancakeswap cannot see the liquidity pool so I cannot unstake

yes same problem

kowsikgelli commented 3 years ago

https://pancake.kiemtienonline360.com try this , this works fine

dparadox commented 3 years ago

Hey @kowsikgelli, How did you solve it? Thanks in advance

safezerolife commented 3 years ago

https://pancake.kiemtienonline360.com try this , this works fine

Is there a reason it's using 0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3 contract as a router address instead of the 0xD99D1c33F9fC3444f8101754aBC46c52416550D1 ?

isingh108 commented 3 years ago

https://pancake.kiemtienonline360.com

can I get its setup detail and github?

ngocanhth commented 3 years ago

Is there pancakeswap for testnet because there is no need for a platform to demo and test, if while developing and testing on main, the fee is too expensive, many times deploy

newcreativegamer commented 3 years ago

We've managed to run PancakeSwap testnet. Here's a source code

https://github.com/neptune-mutual/pancakeswap-testnet

and the hosted version

https://pancake-test.pages.dev/

Lifesaver!

Tim5123 commented 3 years ago

Hi, @safezerolife I've created a test token TFT2 0x0531d452343ce449d570999ea339cb906844800a and added liquidity pool on https://pancake.kiemtienonline360.com for the full amount of token to 1BNB however, when I try to swap some BNB with it via a different Wallet it only says "The transaction cannot succeed due to error: undefined. This is probably an issue with one of the tokens you are swapping."

Would you know what this could be causing?

@newcreativegamer - what Router address are you using for https://pancake-test.pages.dev/ ?

derekzx commented 3 years ago

@Tim5123 have you tried to increase the slippage? (That's the first answer that google gives me)

Tim5123 commented 3 years ago

Thanks @derekzx . yes I did increase the slippage to 11%. I guess I wanted to receive too much. Lower amount had worked. Now I'm wondering why the LP is not increasing or decreasing. Shouldn't it move down by the amount which someone has swapped for my token and move up for the bought amount on BNB?

newcreativegamer commented 3 years ago

Hi, @safezerolife I've created a test token TFT2 0x0531d452343ce449d570999ea339cb906844800a and added liquidity pool on https://pancake.kiemtienonline360.com for the full amount of token to 1BNB however, when I try to swap some BNB with it via a different Wallet it only says "The transaction cannot succeed due to error: undefined. This is probably an issue with one of the tokens you are swapping."

Would you know what this could be causing?

@newcreativegamer - what Router address are you using for https://pancake-test.pages.dev/ ?

Yeah, I encountered that issue and fixed it by using the other one posted: https://pancake.kiemtienonline360.com/#/swap and updating the router address to the one in their docs: https://bsc.kiemtienonline360.com/ 0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3

nwaelti commented 3 years ago

Hello, Could someone give me please a hint, I'm trying to provide liquidity and it does not work: image I've used in my code this router 0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3 and to create the pair, I've used the 0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd WBNB (based on https://bsc.kiemtienonline360.com/), there is something I just don't get

newcreativegamer commented 3 years ago

Hello, Could someone give me please a hint, I'm trying to provide liquidity and it does not work: image I've used in my code this router 0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3 and to create the pair, I've used the 0xae13d989daC2f0dEbFf460aC112a837C89BAa7cd WBNB (based on https://bsc.kiemtienonline360.com/), there is something I just don't get

I also hit this one. Did you approve the router address? Approve it for your full supply first. Don't forget to include the number of zero's equal to your decimal places when approving.

nwaelti commented 3 years ago

I just did, but the result is the same :(

mindfulme commented 3 years ago

use Tenderly to debug your transactions (google it)

nwaelti commented 3 years ago

use Tenderly to debug your transactions (google it)

I did'nt know, great, thanks a lot for the tip

vtn-dev2016 commented 3 years ago

well, if anyone else is facing this issue, you have to reverse the changes from this check-in to be able to test on testnet. That is until pancake-swap makes v2 available on github I presume.

https://github.com/pancakeswap/pancake-swap-interface-v1/pull/390/files/17f9b3102f44ab312c4e29805d9638bf6b364f08

The router address to put in this file (pancake-swap-interface-v1-master\src\constants\index.ts) for testnet is: 0xD99D1c33F9fC3444f8101754aBC46c52416550D1

.env file can contain the following:

REACT_APP_NETWORK_URL="https://data-seed-prebsc-1-s1.binance.org:8545" REACT_APP_CHAIN_ID="97" REACT_APP_GTAG = "GTM-PXLD3XW"

Edit: actually above still does not work. All I succeeded in doing was to create the liquidity pool and add liquidity to it. The swap & liquidity screens still can't find the pool after that pool is created. I've tried updating the WBNB address in the pancake code to it's testnet address (0xae13d989dac2f0debff460ac112a837c89baa7cd) where I could find it, as I was thinking the reason it can't find the pair after creation is because it is passing the wrong WBNB address into the function that generates the pair address. But I couldn't get that to work either.

Currently i'm trying this test version that someone deployed. https://kiemtienonline360.github.io/ It's router address is at 0x9ac64cc6e4415144c455bd8e4837fea55603e5c3.

You have to do these things.

  1. clone https://www.npmjs.com/package/@pancakeswap-libs/sdk
  2. change WETH address and factory
    • cahnge WETH here entities -> token.ts
    • cahnge FACTORY_ADDRESS and INIT_CODE_HASH here constants.ts file
  3. npm run build
  4. install local lib to pancakeswap frontend
kokoskiwi commented 3 years ago

0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3

I am using this router address in my token code 0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3 . I still get this undefined error at the website https://pancake.kiemtienonline360.com/#/swap . I am using the standard testnet address from the binance website. https://academy.binance.com/en/articles/connecting-metamask-to-binance-smart-chain

or do i need to use another testnet? am i doin something wrong?

thx

kokoskiwi commented 3 years ago

i tried to use now bakery testnet pancakeswap from this website https://bsc.kiemtienonline360.com/ Now I am getting this error image

edit I was able to get the error message away because of Caps/lowcase mistakes now I am still getting this message while deploying... image

Tim5123 commented 3 years ago

@newcreativegamer @derekzx do you also have issues removing liquidity from your own liquidity pool?

For me its always failing. Getting until the "Confirm" button shows up and then when clicking it nothing happens. Checked the Chrome Developer Extension and it shows below

Tim5123 commented 3 years ago

i tried to use now bakery testnet pancakeswap from this website https://bsc.kiemtienonline360.com/ Now I am getting this error image

edit I was able to get the error message away because of Caps/lowcase mistakes now I am still getting this message while deploying... image

What happens if you hit "Send Transaction"? Did you try to set the "Slippage tolerance" higher on the Swap settings? like 12 or 13%?

ibhagwan commented 3 years ago

You have to do these things.

  1. clone https://www.npmjs.com/package/@pancakeswap-libs/sdk
  2. change WETH address and factory

    • cahnge WETH here entities -> token.ts
    • cahnge FACTORY_ADDRESS and INIT_CODE_HASH here constants.ts file
  3. npm run build
  4. install local lib to pancakeswap frontend

For anyone interested, loosely based on the instructions from @vtn-dev2016, I forked pancake-swap-interface-v1 as well as pancakeswap-sdk-v2 and modified both to be able to work with any testnet v2 router (the v1/v2 interfaces aren't really that different).

I'm probably going to host an online instance hosted an online instace against the 0xD99D1c33F9fC3444f8101754aBC46c52416550D1 router at https://pancakeswap.ibhagwan.workers.dev. You can also build it yourself with detailed instructions in my repo.

If you clone both my repos you can avoid any editing and work right away with the 0xD99D1c33F9fC3444f8101754aBC46c52416550D1 router, unfortuntely it doesn't have much liquidity, I tested adding liquidity and it works, you're welcome to add more so we can have a proper testnet environment.

Alternatively the 0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3 already has some decent liquidity pools, you can edit the files as per my instructions (very easy) to work with this router instead or use https://pancake.kiemtienonline360.com directly.

EDIT: added published instance at https://pancakeswap.ibhagwan.workers.dev

kir486680 commented 3 years ago

We've managed to run PancakeSwap testnet. Here's a source code

https://github.com/neptune-mutual/pancakeswap-testnet

and the hosted version

https://pancake-test.pages.dev/

Hey. Do I need to change my IUniswapV2Router02 address to add liquidity? Because when I paste my token address nothings happens.

ibhagwan commented 3 years ago

We've managed to run PancakeSwap testnet. Here's a source code https://github.com/neptune-mutual/pancakeswap-testnet and the hosted version https://pancake-test.pages.dev/

Hey. Do I need to change my IUniswapV2Router02 address to add liquidity? Because when I paste my token address nothings happens.

Can you try https://pancakeswap.ibhagwan.workers.dev and let me know if it works for you?

kanedaaaa commented 3 years ago

So if someone here has issues with

I fixed the first two but still getting errors while swapping which, I suppose is impossible on testnet (?)

Anyways, here is the steps you should take:

and here is the code for calculating hash correctly

const UniswapV2Pair = artifacts.require('PancakePair.sol'); // here this could be Pancakev2Pair or smth like that, don't remember correctly
module.exports = async (callback) => {
  console.log(
    'UniswapV2Pair bytecode hash (Look for INIT_CODE_HASH):\n%s',
    (web3.utils.keccak256(UniswapV2Pair.bytecode))
  );
  callback();
}

run this with truffle exec (ganache-cli to ganache should be running as well)

note, this will return 0xinitcodehash for sdk/constants.ts, for periphery/PancakeLibrary.sol - remove 0x

UPDATE I might find the source of why swapping isn't working, when I'm checking the console for errors, it gives me Pancake: K error, I traced that into core and found this require statement in swap function: require(balance0Adjusted.mul(balance1Adjusted) >= uint(_reserve0).mul(_reserve1).mul(1000**2), 'Pancake: K');

I also noticed that removing liquidity doesn't works, console gives me index.js:1 estimateGas failed 0 removeLiquidityWithPermit error

rudolfnep commented 3 years ago

We've managed to run PancakeSwap testnet. Here's a source code https://github.com/neptune-mutual/pancakeswap-testnet and the hosted version https://pancake-test.pages.dev/

Hey. Do I need to change my IUniswapV2Router02 address to add liquidity? Because when I paste my token address nothings happens.

Can you try https://pancakeswap.ibhagwan.workers.dev and let me know if it works for you?

Note that your Cloudflare account will get suspended and flagged as a domain which performs phishing attack if you host it online. Maybe remove the PancakeSwap logo and change the branding. Someone must have falsely reported that we were doing a phishing attack against PancakeSwap. We faced an unwanted headache getting our DNS flagged which was a punishment to us even when we acted in a good faith.

We have now archived the repository which contains the customization to support the BSC testnet. It will be deleted as soon as our issue with CloudFlare is solved.

ibhagwan commented 3 years ago

We've managed to run PancakeSwap testnet. Here's a source code https://github.com/neptune-mutual/pancakeswap-testnet and the hosted version https://pancake-test.pages.dev/

Hey. Do I need to change my IUniswapV2Router02 address to add liquidity? Because when I paste my token address nothings happens.

Can you try https://pancakeswap.ibhagwan.workers.dev and let me know if it works for you?

Note that your Cloudflare account will get suspended and flagged as a domain which performs phishing attack if you host it online. Maybe remove the PancakeSwap logo and change the branding. Someone must have falsely reported that we were doing a phishing attack against PancakeSwap. We faced an unwanted headache getting our DNS flagged which was a punishment to us even when we acted in a good faith.

We have now archived the repository which contains the customization to support the BSC testnet. It will be deleted as soon as our issue with CloudFlare is solved.

Thank you for the heads up, I can see why it might be confusing, for now, I removed the site altogether, I’ll work on adding a banner to it clarifying this is testnet only.

The site is back at https://pancakeswap.ibhagwan.workers.dev, added a banner clarifying it's for use on the testnet only and also disabled all functionality when connecting to mainnet - hopefully this is enough to not get banned on Cloudflare.

image

nicolai22 commented 3 years ago

Hi, i am facing issues on both testnet websites. I can add liquidity pool. i can swap that token against BNB frow the owner account, the charity account for exemple.

But when i try from different account, i cant swap ! That happen to me from different contract.

Is that normal ?

Thanks for your work, its really helpfull !

ibhagwan commented 3 years ago

Hi, i am facing issues on both testnet websites. I can add liquidity pool. i can swap that token against BNB frow the owner account, the charity account for exemple.

But when i try from different account, i cant swap ! That happen to me from different contract.

Is that normal ?

Thanks for your work, its really helpfull !

It would be helpful if you can provide the contract address of (at least one of) the tokens with the error, even more so if you can also provide the error message or failed transaction on testnet.bscscan.com.

kanedaaaa commented 3 years ago

Hi, i am facing issues on both testnet websites. I can add liquidity pool. i can swap that token against BNB frow the owner account, the charity account for exemple.

But when i try from different account, i cant swap ! That happen to me from different contract.

Is that normal ?

Thanks for your work, its really helpfull !

I suppose it's modified safemoon fork, so in that case you are messing up with router address. Auto-liquidation protocol needs router address so it can provide taken fees to liquidity pool, but since owner is excluded from those fees, contract doesn't uses the swap and liquify function.

Try turning off that function, i think it's called enableSwapAndLiquify or something like this, then try again, if it works thus you have problem with hardcoded router address.

If you are swapping on pancakeswap, dont mess up v1 and v2 router addresses, you can't provide liquidity to v1 anymore so you have to find the v2 address.

Note, it seems they dont have tesntet address.

update

function setSwapAndLiquifyEnabled(bool _enabled) public onlyOwner {
        swapAndLiquifyEnabled = _enabled;
        emit SwapAndLiquifyEnabledUpdated(_enabled);
    }

This function can set swapAndLiquifyEnabled false, confirm contract on BSCscan and set this on false, then try swapping with non-owner account.

Pancake v2 router - 0x10ED43C718714eb63d5aA57B78B54704E256024E

If this is the case, only way to fix it is re-deploying contract.

atropos0902 commented 3 years ago

We've managed to run PancakeSwap testnet. Here's a source code

https://github.com/neptune-mutual/pancakeswap-testnet

and the hosted version

https://pancake-test.pages.dev/

Looks like https://pancake-test.pages.dev/ is down. Any interface we could trade our test tokens?

zakaria1159 commented 3 years ago

Hello guys,

I'm experimenting with SGO contract and trying to get the transaction to work on testnet, but having the same issues as above, which means only the main wallet is able to do swap, different wallet transactions keeps failing.

I did set swapAndLiquifyEnabled to false, but nothing happened.

I am using

https://pancake.kiemtienonline360.com/

with this address

0xD99D1c33F9fC3444f8101754aBC46c52416550D1

atropos0902 commented 3 years ago

Hello guys,

I'm experimenting with SGO contract and trying to get the transaction to work on testnet, but having the same issues as above, which means only the main wallet is able to do swap, different wallet transactions keeps failing.

I did set swapAndLiquifyEnabled to false, but nothing happened.

I am using

https://pancake.kiemtienonline360.com/

with this address

0xD99D1c33F9fC3444f8101754aBC46c52416550D1

Please try to use this address. 0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3

zakaria1159 commented 3 years ago

Hello guys, I'm experimenting with SGO contract and trying to get the transaction to work on testnet, but having the same issues as above, which means only the main wallet is able to do swap, different wallet transactions keeps failing. I did set swapAndLiquifyEnabled to false, but nothing happened. I am using https://pancake.kiemtienonline360.com/ with this address 0xD99D1c33F9fC3444f8101754aBC46c52416550D1

Please try to use this address. 0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3

Thanks for your answer, I tried with the address you suggested and it gave me the same error. only the owner of the contract can do transactions.

kanedaaaa commented 3 years ago

Hello guys,

I'm experimenting with SGO contract and trying to get the transaction to work on testnet, but having the same issues as above, which means only the main wallet is able to do swap, different wallet transactions keeps failing.

I did set swapAndLiquifyEnabled to false, but nothing happened.

I am using

https://pancake.kiemtienonline360.com/

with this address

0xD99D1c33F9fC3444f8101754aBC46c52416550D1

Show us the code

zakaria1159 commented 3 years ago

It's a fork from Sportemon GO with small edits. please check it on bscscan https://testnet.bscscan.com/address/0xcb7c525D3fe88127D953736392C43792Cc921542#code

atropos0902 commented 3 years ago

It's a fork from Sportemon GO with small edits. please check it on bscscan https://testnet.bscscan.com/address/0xcb7c525D3fe88127D953736392C43792Cc921542#code

I tried to buy/sell on my local and it was working fine.

Screen Shot 2021-06-20 at 10 27 21 AM
zakaria1159 commented 3 years ago

It's a fork from Sportemon GO with small edits. please check it on bscscan https://testnet.bscscan.com/address/0xcb7c525D3fe88127D953736392C43792Cc921542#code

I tried to buy/sell on my local and it was working fine.

Screen Shot 2021-06-20 at 10 27 21 AM

Hi, I tried again with a high slippage and it worked, thank you. May I know what makes the slippage go high and low ?

MHG1990 commented 3 years ago

We've managed to run PancakeSwap testnet. Here's a source code

https://github.com/neptune-mutual/pancakeswap-testnet

and the hosted version

https://pancake-test.pages.dev/

Please, I am getting 404 when I am trying to access the mentioned Repo.. can anyone re-share the source code please?

zakaria1159 commented 3 years ago

Hi guys, is it possible to test the fees distributions on TestNet ? The transactions go correctly but no fees is distributed to the different wallets ?