1.0.7 • Published 12 months ago

@steerprotocol/uniswap-position-quoter v1.0.7

Weekly downloads
-
License
BUSL-1.1
Repository
-
Last release
12 months ago

Uniswap Position Quoter

Description

Steer Position Quoter provides re-balance calculations for multi position strategies with 99% accuracy.

How to install

Node Package Manager

    npm install --save @steerprotocol/uniswap-position-quoter

Yarn

    yarn add @steerprotocol/uniswap-position-quoter

How to use

    import {CustomRouter, Position} from '@steerprotocol/uniswap-position-quoter'
    import {utils} from 'ethers'
    const QUOTER_ADDRESS = '0xb27308f9F90D607463bb33eA1BeBb41C27CE5AB6'
    const POOL_ADDRESS = '0x0000000000000000000000000000000000000000'
    const TOKEN0_ADDRESS = '0x0000000000000000000000000000000000000000'
    const TOKEN1_ADDRESS = '0x0000000000000000000000000000000000000000'
    const POOL_FEE = '3000'

    const quoterContract = new Contract(
        QUOTER_ADDRESS,
        new Interface(QuoterV2Artifact.abi)
    );

    const PositionQuoter = new CustomRouter(quoterContract)

    const positions = [
        {
            lowerTick: 62342,
            upperTick: -62342,
            weight: 1,
        },
        {
            lowerTick: 32342,
            upperTick: -32342,
            weight: 3,
        },
    ]

    // Returns single swap amount to have proper liquidity for position re-balancing
    const swapResult = await PositionQuoter.getSwapAmount(
        POOL_ADDRESS,
        positions,
        utils.parseEther('100'),
        utils.parseEther('100'),
        TOKEN0_ADDRESS,
        TOKEN1_ADDRESS,
        POOL_FEE,
        0,
    )