Code Monkey home page Code Monkey logo

swapr-sdk's People

Contributors

0xvenky avatar adamazad avatar berteotti avatar denciu avatar dependabot[bot] avatar diogomartf avatar elrodrigote avatar jorgedclopes avatar jpkcambridge avatar mi-lan avatar moodysalem avatar mwiniarsk avatar noahzinsmeister avatar seibelj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

swapr-sdk's Issues

Compute Uniswap v2 common pairs from The Graph

common pairs list is a collection of pairs that could link currencyA to currencyB. For instance, I trade from WETH to CRV. A possible trade route would be:

WETH > WETH-USDC > USDC-CRV > CRV

WETH-USDC and USDC-CRV are the common pairs between WETH and CRV. This is list is computed in the SDK by assuming that every token will have a pool of the token and a stablecoin or the native token of the given chain. For example, CRV will likely to have a pair of CRV-WETH and CRV-USDC. This approach discriminates against less known tokens by skipping potential pairs that would be more liquid and given better rates.

The solution is to utilize The Graph and find these pairs by running such query with the following conditions:

where token0 = tokenA OR token1 = tokenA OR token0 = tokenB OR token1 = tokenB

This yields all the pairs that have either currencyA or currencyB. The above query can include reserves, which leads to a slight gain in performance.

AC

The common pairs list is computed from the subgraph. If the subgraph query fails due to network, default to the current SDK implementation.

Curve Router not going through ETH pools

Description
When users tries to route through eth/seth, eth/steth, reth/eth etc...Router doesn't pick them up

Definition of done

  • All eth pools mentioned should return a quote from curve since they are liquid and existing

  • Swapr
    Screenshot 2022-07-28 at 17 47 07

  • Curve
    Screenshot 2022-07-28 at 17 48 07

Remove JSBI in favor of BigNumber

Jumping between JSBI and BigNumber/parseUnits from ethers.js is not ideal.

AC

  • JSBI is replaced with BigNumber instance and parseUnit/formatUnits

Add factory pools to Curve

Description

Curve v2 has a factory contract to deploy new Curve pools.

Acceptance Criteria

  • CurveTrade can find and get quotes from Curve v2 pools

Fix Uniswap support on Polygon

Uniswap underlying Ether implementation does not support MATIC. The solution is creating another NativeCurrecny called MaticNativeCurrency. This is what Uniswap interfaces use internally.

AC

UniswapTrade supports Polygon's Matic.

`Pair` class bug with default parameters

The Pair constructor parameter uses Swapr as the default platform:

https://github.com/levelkdev/swapr-sdk/blob/dae13a9fcd8aa7a6a05edaa298ce21e44ae64c74/src/entities/pair.ts#L114-L134

Pair.getOutputAmount and Pair.getInputAmount do not pass the same platform back to the construct when calling creating new Pair instances

https://github.com/levelkdev/swapr-sdk/blob/dae13a9fcd8aa7a6a05edaa298ce21e44ae64c74/src/entities/pair.ts#L205-L231

https://github.com/levelkdev/swapr-sdk/blob/dae13a9fcd8aa7a6a05edaa298ce21e44ae64c74/src/entities/pair.ts#L233-L263

When the wrong platform (Swapr for example on Polygon) is used, the Pair.getAddress throws an unsupported platform error:

https://github.com/levelkdev/swapr-sdk/blob/dae13a9fcd8aa7a6a05edaa298ce21e44ae64c74/src/entities/pair.ts#L84-L92

The fix is to pass back the instance platform property in Pair.getOutputAmount and Pair.getInputAmount.

This logic error affects any EVM chain where Swapr is not supported and potentially leads to calculating the wrong UniswapV2Pair address using keccak256 method.

AC

  • Pair.getOutputAmount and Pair.getInputAmount pass back the current instance's platform.
  • Platforms, where Swapr is not deployed, should return a trade list.

Add support for xDAI in Curve trade

Curve does not support the native xDAI token on Gnosis Chain. It only works with ERC20 stable tokens: WXDAI, USDC, and USDT.

AC

  • Curve Trade can return a quote for trading XDAI to/from USDC and USDT.
  • A multicall interceptor should wrap the XDAI before sending it to the Curve 3CRV pool.

Upgrade to Multicall3

Currently, the SDK uses Multicall2. Upgrade to Multicall3 and add a factory function.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.