npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ape.swap/zap-tx-builder

v0.0.2

Published

Zap Tx Builder is a utility tool that helps in creating encoded data for zap.

Downloads

11

Readme

Zap Tx Builder

Zap Tx Builder is a utility tool that helps in creating encoded data for zap.

Contracts

Zap Contracts: https://github.com/ApeSwapFinance/apeswap-hardhat-zap

Router Contracts: https://github.com/ApeSwapFinance/swap-router-contracts

Usage

npm i @ape.swap/zapTxBuilder

yarn add @ape.swap/zapTxBuilder

ZapBuilderFrom0xPath

!! CHECK test/zapTxBuilder.spec.tx FOR MORE EXAMPLES !!

Example zapping WMATIC to ApeV2 BANANA-BUSD LP

With swap routing best path found by 0x API (https://0x.org/docs/0x-swap-api/api-references/overview)

import { ZapBuilderFrom0xPath } from "@ape.swap/zapTxBuilder";

const provider: providers.Provider = new providers.JsonRpcProvider(
  "https://polygon.llamarpc.com"
);

const zapBuilder = new ZapBuilderFrom0xPath(provider, 137);
const zapLP = await zapBuilder.toLP(
  WMATIC, //InputToken
  AMOUNT, //Amount tof inputToken to zap
  BANANA, //First token of LP
  BUSD, //Second token of LP
  APEV2, //LP router/factory
  ADDRESS_THIS //Recipient (default: MSG_SENDER)
);
return zapLP.populatedTx; //Encoded data to zap into LP

ZapBuilder

!! CHECK test/zapTxBuilder.spec.tx FOR MORE EXAMPLES !!

Example zapping WMATIC to ApeV2 BANANA-BUSD LP

With swap routing:

  • WMATIC --UniV3--> ETH --ApeV2--> BANANA
  • WMATIC --PcsV2--> BUSD
import { ZapBuilder } from "@ape.swap/zapTxBuilder";

const provider: providers.Provider = new providers.JsonRpcProvider(
  "https://polygon.llamarpc.com"
);

const swapPath00: Path = {
  swapRouter: UNIV3Factory,
  swapType: SwapType.V3,
  path: [WMATIC, ETH],
  uniV3PoolFees: [500],
};

const swapPath01: Path = {
  swapRouter: APEV2Router,
  swapType: SwapType.V2,
  path: [ETH, BANANA],
  uniV3PoolFees: [],
};

const swapPath10: Path = {
  swapRouter: PCSV2Router,
  swapType: SwapType.V2,
  path: [WMATIC, BUSD],
  uniV3PoolFees: [],
};

const liquidityPath: LiquidityPath = {
  lpRouter: APEV2Router,
  liquidityType: LPType.V2,
  tickLower: 0,
  tickUpper: 0,
  uniV3PoolLPFee: 0,
  arrakisFactory: ZERO_ADDRESS,
};

const swapReturnsParams: SwapReturnsParams = {
  inputAmount: ether("0.01").toString(),
  path0: [swapPath00, swapPath01],
  path1: [swapPath1],
  liquidityPath: liquidityPath,
};

const zapBuilder = new ZapBuilder(provider, 137);
const zapLP = await zapBuilder.toLPFromPath(swapReturnsParams);
return zapLP.populatedTx; //Encoded data to zap into LP

Extra extensions

const zapBill = await zapLP.toBill({
  bill: USDCWOMBATBOND,
  inputAmount: 0,
  maxPrice: "23382705930",
  recipient: "0x5c7C7246bD8a18DF5f6Ee422f9F8CCDF716A6aD2",
});
return zapBill.populatedTx; //Encoded data to zap into Bill

const zapPool = await zapLP.toPool({
  inputAmount: 0,
  pool: "0xA3c3A929Ae19Bfc56E2A9B0f23e99bae8Bf6F11A",
  recipient: MSG_SENDER,
});
return zapPool.populatedTx; //Encoded data to zap into Pool

const zapVault = await zapLP.toVault({
  inputAmount: 0,
  maximizerVaultApe: KEEPER_MAXIMIZER_VAULT_APE,
  vaultPid: 0,
  recipient: MSG_SENDER,
});
return zapVault.populatedTx; //Encoded data to zap into Vault

const zapMiniApe = await zapLP.toMiniApe({
  inputAmount: 0,
  miniApe: MINI_APE_V2,
  pid: 0,
  recipient: MSG_SENDER,
});
return zapMiniApe.populatedTx; //Encoded data to zap into Mini Ape