Skip to content

multi hop swap support in zora sdk #540

@huahuayu

Description

@huahuayu

Hi guys, here is the example you provided in the Zora docs. I wonder if you support multi-hop swap, e.g., for A->B->C, and I just need to set the param sell A, buy C, you automatically do the routing.

import { TradeParameters, tradeCoin } from "@zoralabs/coins-sdk";
 
const tradeParameters: TradeParameters = {
  sell: {
    type: "erc20",
    address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913", // USDC
  },
  buy: {
    type: "erc20",
    address: "0x9b13358e3a023507e7046c18f508a958cda75f54", // @jacob Creator Coin
  },
  amountIn: BigInt(4 * 10 ** 6), // 4 USDC (6 decimals)
  slippage: 0.04, // 4% slippage
  sender: account.address,
};
 
const receipt = await tradeCoin({
  tradeParameters,
  walletClient,
  account,
  publicClient,
});

I used to encode the call data for such needs by Uniswap SDK. For example, I want to use weth to buy a creater coin, but the coin only has a USDC pair, so actually the path is weth-usdc-creator coin, but I can't encode it because the usdc-creator pool has hooks and needs a specific encoding which can only be handled by your SDK.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions