Skip to content

Releases: joshstevens19/simple-uniswap-sdk

Support ESM

27 Jul 09:29
Compare
Choose a tag to compare

Lib now supports both ESM and CSJ

fix the watcher trade changes

26 Jul 15:57
Compare
Choose a tag to compare

The new price subscription was not always acting as it should, it would emit old pairs you created. This fixes it so now you should only get newPrice alerts on your pair and if its changed.

Add WBTC in base currencies

22 Jul 09:15
Compare
Choose a tag to compare
  • WBTC sometimes gives a better route when included so put in the base currencies
  • Also add DAI > USDT + DAI > USDC in common lookups

Allow ETH and WETH work side by side - BREAKING CHANGE!

07 Jul 13:55
9053803
Compare
Choose a tag to compare

The old approach assumed everything was native eth but you had to pass in weth contract address. This also meant you could not do a ETH > WETH swap and you also got all WETH context back all the time. This change now makes it very clear when your using ETH and when your using WETH. From the interface point of view not much has changed you now can use the native eth using:

import { UniswapPair, ChainId, UniswapVersion, ETH } from 'simple-uniswap-sdk';

const uniswapPair = new UniswapPair({
  // the contract address of the token you want to convert FROM
  fromTokenContractAddress: ETH.MAINNET().contractAddress,
  // the contract address of the token you want to convert TO
  toTokenContractAddress: '0x1985365e9f78359a9B6AD760e32412f4a445E862',
  // the ethereum address of the user using this part of the dApp
  ethereumAddress: '0xB1E6079212888f0bE0cf55874B2EB9d7a5e02cD9',
  ethereumProvider: YOUR_WEB3_ETHERS_OR_CUSTOM_ETHEREUM_PROVIDER,
  settings: new UniswapPairSettings({
    // if not supplied it will use `0.005` which is 0.5%
    // please pass it in as a full number decimal so 0.7%
    // would be 0.007
    slippage: 0.005,
    // if not supplied it will use 20 a deadline minutes
    deadlineMinutes: 20,
    // if not supplied it will try to use multihops
    // if this is true it will require swaps to direct
    // pairs
    disableMultihops: false,
    // for example if you only wanted to turn on quotes for v3 and not v3
    // you can only support the v3 enum same works if you only want v2 quotes
    // if you do not supply anything it query both v2 and v3
    uniswapVersions: [UniswapVersion.v2, UniswapVersion.v3],
  }),
});

// now to create the factory you just do
const uniswapPairFactory = await uniswapPair.createFactory();

WETH class has been renamed to WETHContract so people who upgrade get compile-time errors to alert them they need to change their approach. WETH can be used using WETHContract.MAINNET().contractAddress.

Also we have removed the flag useWETHAsERC20Route on the settings as this approach felt wrong and hidden away. We have also added toBalance on the TradeContext interface response now.

Thanks!

feat: support the ability to set useWETHAsERC20Route as true and it go WETH > TOKEN erc20 > erc20 instead of native

02 Jul 13:53
Compare
Choose a tag to compare

feature-request here - #9

  • swap native ETH > token but force the lib to treat ETH as WETH doing token > token
    // if not supplied it will be false by default
    // when this is false it will class WETH as native eth
    // and call methods like `swapETHForExactTokens` etc
    // so if you swapped AAVE > WETH you would get native ETH and
    // not the erc20 WETH
    // when this is false it treat WETH as a erc20 token
    // and call methods like `swapExactTokensForTokens`,
    // so if you swapped AAVE > WETH you would get ERC20 WETH and
    // not the native ETH
    useWETHAsERC20Route: false,

bug fixes

01 Jul 16:14
Compare
Choose a tag to compare
  • bug fixes related to different ethereum providers

feat: support passing in ethereum provider directly

01 Jul 10:14
ba8c640
Compare
Choose a tag to compare
  • You can now pass in an ethereum provider to the UniswapPair creation
  • breaking change on the public factories as you now have to pass it ChainIdAndProvider | EthereumProvider

You can now get quotes from input and output directions

18 Jun 16:52
Compare
Choose a tag to compare

You can get quotes from input and output directions. You use the same interface to execute the quote but we have an optional parameter now which allows you to pass in a different direction.

/**
   * Generate trade - this will return amount but you still need to send the transaction
   * if you want it to be executed on the blockchain
   * @param amount The amount you want to swap formatted. Aka if you want to swap 1 AAVE you pass in 1
   * @param direction The direction you want to get the quote from
   */
async trade(amount: string, direction: TradeDirection = TradeDirection.input): Promise<TradeContext>

This will generate all the same stuff it did before but it have properties like maximumSent defined instead of minAmountConvertQuote. The transaction would all of been built for you as a different output direction takes you down a different contract call. So all in all it should be very easy to quote both ways now without any changes to the interface!

Package has been deployed in 2.3.0 👍