New answers tagged

0

yo creia que en contrato le introducian el codigo function sell(uint256 amount) public { require(amount > 0, "You need to sell at least some tokens"); uint256 allowance = token.allowance(msg.sender, address(this)); require(allowance >= amount, "Check the token allowance"); token.transferFrom(msg.sender, address(this), amount); msg....


0

function swapExactTokensForTokens( uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline ) external returns (uint[] memory amounts); swapExactTokensForTokens allows you to swap your token for USDT, DAI, or whatever. function swapMyTokenToUSDT(uint amountToken) external { address[] memory path = new ...


0

Hmm, why do you need a smart contract for this? If you just want to interact with Uniswap's router contract, you can do it via Etherscan's API in the contract's page.


0

"UniswapV2 addLiquidity revert ds-math-sub-underflow" error happened because "msg.value" parameter has not been provided for calling "addLiquidity" method. Now call the addLiquidity method as: await uniswapV2Router02.addLiquidity(token0.address, token1.address, 500, 250, 250 , 125, accounts[0], 1618158769, {value : "125&...


1

Yes, it's possible. You can directly interact with UniswapV3 or Sushiswap router contracts to swap ETH to DAI and send that to a particular receiver address. Here's the example with Sushiswap (UniswapV2) router: payableAmount: ETH amount you want to swap path: [WETH, DAI] to: walletB


0

You can't. The point of WETH() in uniswapV2Router is to return the address of the wrapped version of the chains native token. If you need WETH address somewhere in your code just hardcode it. Edit : i'm assuming you're building on top of uniswapV2Router. If you're forking it and you want to change what WETH returns ehh.. dont. It'll break all the functions ...


2

Disclaimer: I don't think this is the correct method to calculate the price impact but it's almost 100% accurate for price impacts of less than 1%. This calculation method assumes that multi-hop is disabled i.e. swapping is restricted to direct pairs. I've only tested this calculation method on PancakeSwap and it is less accurate for larger trade sizes ...


1

Iv run into similar issues. In your truffle configuration file, make sure you enable optimization i. The compiler settings. Setting to 200 is fine. Essentially the fact that the contract code isn't optimized, you end up running out of gas Hope this helps, Alex


0

It is likely that one takes into account the 0.3% liquidity provider fee and the other does not.


0

Yes, a flash swap will trigger the same events as a normal swap. The only difference is that in a flash swap, the contract that called the swap can perform some arbitrary code between the moment it receives tokens from the pair and the moment that the swap function checks if it received enough input token (the calculation of the k constant).


0

i am trying to make a flash loan too. i saw some codes on how to buy on kyber and sell on uniswap https://github.com/jklepatch/eattheblocks/tree/master/profitable-flashloans/24-buy-kyber-sell-uniswap you can check it out.. you can email me so we talk more about it forsonfranklin @gmail


1

This is because IUniswapV2Router02.sol inherits IUniswapV2Router01.sol. Therefore you may think of Router02 interface as an extension of Router01 interface with all of its functions.


0

Before you do the swap ETH -> WETH, you cannot make the mistake of entering just "WETH". Some (scam?) coin called weth (whose logo is depicted below) will appar, but that is not the real WETH. Any funds sent there will be lost forever and not be returned as the WETH funds you want. Be sure to add the real WETH to your Metamask by searching for ...


1

If you're swapping tokens with hard coded tax inside on their smart contract (in your case 10%). The "minimum token" appearing on the website is wrong, because it is based on normal token contract with no tax/fees.


0

The AMM itself has no way of knowing how many tokens are deducted for fees. It can only calculate on the knowledge it has inside itself, so it gives you data based on its own numbers. However, a frontend for such AMM may try to emulate such transaction to see how many tokens would be received. But I think at least Uniswap's website doesn't calculate the ...


1

There's a website for this, built and maintained by Uniswap Labs. It's info.uniswap.org: Alternatively you might use the Uniswap V3 subgraph.


2

To answer the question, first you need to calculate the liquidity Liquidity_x that is provided by the asset x given the current price and price range. From the whitepaper it can be derived that if the current price is within the range then: Liquidity_x = x * sqrt(price) * sqrt(price_high) / (sqrt(price_high) - sqrt(price)) See this article for more details....


0

There are only three fee tiers possible in Uniswap v3 at the moment: 1%, 0.3%, and 0.05%. In the future, more might be added, but it's unlikely there will be many more. In the code, the fee tiers are expressed in basis points (1/100 of percents) multiplied by 100: for 0.05% pools the fee tier is 500 for 0.3% pools the fee tier is 3000 for 1% pools the fee ...


0

Try using Yarn, it helped me. If not check if you have the correct node version.


0

The problem were in one of the token address!


0

I managed to fix this by using directly the generatedParams parameter into the trade function without any encoding and it worked.


0

From BEP20 documentation What is BEP20? A token protocol on BSC which is compatible with BEP2 and ERC20. It extends ERC20 and contains more interfaces, such as getOwner and decimals. BEP-20 compliant doesn't require any support for Pancakeswap.


0

You can add tokens in @uniswap/build/uniswap-default.tokenlist.json These will show up inthe default list.


Top 50 recent answers are included