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

@xslo1x-test/custom-uniswap-v2-sdk

v3.2.1

Published

Custom Uniswap SDK V2 to use for multiple chains

Downloads

3

Readme

Custom Uniswap V2 SDK

Unit Tests Lint code style: prettier npm version npm bundle size (scoped version)

In-depth documentation on original SDK is available at uniswap.org.

Most blockchain with EVM compatibility will use Uniswap solutions to build a decentralized crypto exchange. However, the original Uniswap SDK has a factory address contract and the init code hash (used for getCreate2Address etherjs method) is locked in the source code.

The result is that everyone is cloning and creates their own version. And as a result, their own SDK is outdated with Uniswap latest fixes, upgrade and hard to check what changes with the original Uniswap SDK.

I forked and changes some code, so we can reuse Uniswap SDK without cloning and create our own.

Demo online

Install

npm i custom-uniswap-v2-sdk

or

yarn add custom-uniswap-v2-sdk

Changes

  • The forked SDK won't export FACTORY_ADDRESS and INIT_CODE_HASH anymore.

  • Exported computePairAddress method will require factory address, and init code hash.

// Example interface
interface ComputePairAddressArg {
  factoryAddress: string
  initCodeHash: string
  tokenA: Token
  tokenB: Token
}

export function computePairAddress(arg: ComputePairAddressArg) {
  // Example
}
  • Exported class Pair constructor will require factory address, and init code hash.
new Pair(currencyAmountA, tokenAmountB, factoryAddress, initCodeHash)
  • Exported class Pair static method getAddress will require factory address, and init code hash.
 public static getAddress(tokenA: Token, tokenB: Token, factoryAddress: string, initCodeHash: string): string {
    //
}
  • Exported class Pair constructor now support custom fees numerator and fees denominator (v3.1.0)

In the Uniswap SDK , feesNumerator and feesDenominator are constant JSBI.BigInt(997) and JSBI.BigInt(1000)

export const _997 = JSBI.BigInt(997)

export const _1000 = JSBI.BigInt(1000)

In PancakeSwap they change this to support different fee

export const FEES_NUMERATOR = JSBI.BigInt(9975)

export const FEES_DENOMINATOR = JSBI.BigInt(10000)

So in the custom SDK, ThePair class now can change the fees. If you do not add to the constructor, default fees will be used.

new Pair(currencyAmountA, tokenAmountB, factoryAddress, initCodeHash, feesNumerator, feesDenominator)
  • Router.swapCallParameters support custom contract method name that have ETH name in it.

For example, in the Avalance chain some contracts are using swapExactAVAXForTokens instead swapExactETHForTokens

Router.swapCallParameters(trade, {
  feeOnTransfer: false,
  allowedSlippage: new Percent(JSBI.BigInt(Math.floor(slippageTolerance)), JSBI.BigInt(10000)),
  recipient: wallet.account,
  ttl: deadline,
  etherMethods: {
    wapETHForExactTokens: 'swapAVAXForExactTokens',
    swapExactETHForTokens: 'swapExactAVAXForTokens',
    swapExactETHForTokensSupportingFeeOnTransferTokens: 'swapExactAVAXForTokensSupportingFeeOnTransferTokens',
    swapExactTokensForETH: 'swapExactTokensForAVAX',
    swapExactTokensForETHSupportingFeeOnTransferTokens: 'swapExactTokensForAVAXSupportingFeeOnTransferTokens',
    swapTokensForExactETH: 'swapTokensForExactAVAX'
  }
})