Skip to content

V0.4 Release Candidate

Compare
Choose a tag to compare
@GalloDaSballo GalloDaSballo released this 14 Sep 22:34
· 9 commits to main since this release
b280f3e

Release Candidate for V4

Adds Price Feeds, see Readme

OnChainPricingMainnet

Given a tokenIn, tokenOut and AmountIn, returns a Quote from the most popular dexes

  • OnChainPricingMainnet -> Fully onChain math to find best, single source swap (no fragmented swaps yet)
  • OnChainPricingMainnetLenient -> Slippage tollerant version of the Pricer

Dexes Support

  • Curve
  • UniV2
  • UniV3
  • Balancer
  • Sushi

Covering >80% TVL on Mainnet. (Prob even more)

New with V4

V4 adds support for Chainlink Price Feeds, all feeds are supported via the Feeds Registry

Because V4 marks the separation between "executable prices" and "ideal prices" we added new functions.

Read below for full details

Example Usage

V4 functions are view

!!! V4 functions do not revert on error, they return 0 !!!

isPairSupported

Returns true if the pricer will return a non-zero quote
NOTE: This is not proof of optimality

    /// @dev Given tokenIn, out and amountIn, returns true if a quote will be non-zero
    /// @notice Doesn't guarantee optimality, just non-zero
    function isPairSupported(address tokenIn, address tokenOut, uint256 amountIn) external returns (bool)

In Brownie

quote = pricer.isPairSupported(t_in, t_out, amt_in)

findOptimalSwap

Finds the best quote available between the sources
Prioritizes price feeds

    function findOptimalSwap(address tokenIn, address tokenOut, uint256 amountIn) external virtual returns (Quote memory)

In Brownie

quote = pricer.findOptimalSwap(t_in, t_out, amt_in)

findExecutableSwap

Finds the best executable quote
Uses PriceFeeds (if available) to verify the quote is better than the feed

    function findExecutableSwap(address tokenIn, address tokenOut, uint256 amountIn) external virtual returns (Quote memory)

In Brownie

quote = pricer.findExecutableSwap(t_in, t_out, amt_in)

unsafeFindExecutableSwap

Finds the best executable quote
Doesn't check price feeds, use at your own risk

    function unsafeFindExecutableSwap(address tokenIn, address tokenOut, uint256 amountIn) external virtual returns (Quote memory)

In Brownie

quote = pricer.unsafeFindExecutableSwap(t_in, t_out, amt_in)