Skip to content
This repository has been archived by the owner on Apr 25, 2024. It is now read-only.

How to use this lib to buy token on Arbitrum? #125

Open
winktool opened this issue May 3, 2023 · 1 comment
Open

How to use this lib to buy token on Arbitrum? #125

winktool opened this issue May 3, 2023 · 1 comment

Comments

@winktool
Copy link

winktool commented May 3, 2023

Thanks~

  const pool = await getPool(
    v5Provider,
    unitToken,
    targetToken,
    FeeAmount.HIGH,
    86185620
  );

  const trade = await V3Trade.fromRoute(
    new RouteV3([pool], unitToken, targetToken),
    CurrencyAmount.fromRawAmount(
      unitToken,
      ethers.parseEther(amount).toString()
    ),
    TradeType.EXACT_INPUT
  );
  console.log("trade", trade);

  const permit = makePermit(
    unitToken.address,
    ethers.parseUnits(amount, decimals).toString(),
    nonce,
    ROUTER_ADDRESS
  );
  const signature = await generatePermitSignature(
    permit,
    signer,
    chainId,
    "0x0000000000000000000000000000000000000002"
  );

  const methodParameters = SwapRouterUniversal.swapERC20CallParameters(
    buildTrade([trade]),
    {
      slippageTolerance: new Percent(25, 100),
      deadlineOrPreviousBlockhash: Math.floor(Date.now() / 1000) + 60 * 2,
      inputTokenPermit: toInputPermit(signature, permit),
    }
  );
@Vuong-Dao
Copy link

Hello, Could I have an example for swaping a token by using this sdk?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants