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

skytale-liquidity-pools

v1.0.17

Published

library to fetch and process liquidity pools from various providers.

Downloads

24

Readme

skytale-liquidity-pools

Library to get APR/APY of Liquidity pools and invest in them.

Installation

npm install skytale-liquidity-pools

Usage

import { liquidityPools } from  'skytale-liquidity-pools';

const providers = liquidityPools.getProviders();
// output: ['balancer', 'mstable']

const balancerService = liquidityPools.getProvider(provider);

Supported Pools

  • Balancer
    • Ethereum
    • Polygon
    • Arbitrum
  • Mstable (joinPool for Mstable is not supported yet.)
    • Ethereum
    • Polygon
  • RefFinace(https://app.ref.finance/) (Only Pools List Join pool Not yet supported.)
    • NEAR

    Set Currency (usd by default)

const balancerService = liquidityPools.getProvider('balancer').setCurrency('eur');

/**
 * only usd usd and eur supported
 * /

Get Paginated Pools By Chain

balancerService.getPools(CHAIN_ID, PAGE_NO, PAGE_SIZE)
    .then((pools) => console.log(pools))
    .catch((error) => console.log(error));

/** output: 
  [
    {
        apr: {
        min: 1.2851894678129268,
        max: 1.2851894678129268,
        base: 1.2851894678129268
        },
        apy: {
        min: 1.2934606026798967,
        max: 1.2934606026798967,
        base: 1.2934606026798967
        },
        id: '0x231e687c9961d3a27e6e266ac5c433ce4f8253e4000200000000000000000023',
        liquidity: '6482128.171858008',
        poolName: 'Balancer 50 SRM 50 WETH',
        tokens: [
            {
                address: '0x476c5e26a75bd202a9683ffd34359c0cc15be0ff',
                balance: 3877214.902257,
                decimals: 6,
                name: undefined,
                symbol: 'SRM',
                weight: 0.5
            },
            {
                address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
                balance: 3070.3491080134445,
                decimals: 18,
                name: undefined,
                symbol: 'WETH',
                weight: 0.5
            }
        ],
        volume: '5966901.794115081',
        linearPoolTokensMap: undefined,
        wrappedTokens: undefined,
        mainTokens: undefined,
        chainId: 1
    }
    ...
    ...
    ...
  ]

**/

Get Pool By Id

balancerService.getPool(POOL_ID, CHAIN_ID)
    .then((pools) => console.log(pool))
    .catch((error) => console.log(error));

/** output: 
{
    apr: {
    min: 1.2851894678129268,
    max: 1.2851894678129268,
    base: 1.2851894678129268
    },
    apy: {
    min: 1.2934606026798967,
    max: 1.2934606026798967,
    base: 1.2934606026798967
    },
    id: '0x231e687c9961d3a27e6e266ac5c433ce4f8253e4000200000000000000000023',
    liquidity: '6482128.171858008',
    poolName: 'Balancer 50 SRM 50 WETH',
    tokens: [
        {
            address: '0x476c5e26a75bd202a9683ffd34359c0cc15be0ff',
            balance: 3877214.902257,
            decimals: 6,
            name: undefined,
            symbol: 'SRM',
            weight: 0.5
        },
        {
            address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',
            balance: 3070.3491080134445,
            decimals: 18,
            name: undefined,
            symbol: 'WETH',
            weight: 0.5
        }
    ],
    volume: '5966901.794115081',
    linearPoolTokensMap: undefined,
    wrappedTokens: undefined,
    mainTokens: undefined,
    chainId: 1
}
**/

Get Pools With Investment Details of Wallet Address

balancerService.getUserPools(WALLETS)
    .then((userPools) => console.log(userPools))
    .catch((error) => console.log(error));

/** output:
    [
        {
            walletAddress: 'WALLET_ADDRESS',
            chain: 'polygon',
            userPoolShare: {
                balance: '0.793507214668472709',
                currency: 'EUR',
                investedAmount: 5.7703065445532875,
                userAddress: 'Mywallet',
                pool: {
                    apr: { base: 13.972187871832457 },
                    apy: { base: 14.992318305052832 },
                    id: '0x0297e37f1873d2dab4487aa67cd56b58e2f27875000100000000000000000002',
                    liquidity: 2842802.1908321516,
                    poolName: 'Balancer Polygon Base Pool',
                    tokens: [
                        {
                            address: '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270',
                            balance: 1695842.946616207,
                            decimals: 18,
                            symbol: 'WMATIC',
                            weight: 0.25
                        },
                        {
                            address: '0x2791bca1f2de4661ed88a30c99a7a9449aa84174',
                            balance: 740560.659314,
                            decimals: 6,
                            symbol: 'USDC',
                            weight: 0.25
                        },
                        {
                            address: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',
                            balance: 724.2606535552587,
                            decimals: 18,
                            symbol: 'WETH',
                            weight: 0.25
                        },
                        {
                            address: '0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3',
                            balance: 171873.59791679878,
                            decimals: 18,
                            symbol: 'BAL',
                            weight: 0.25
                        },
                        chainId: 1,
                    ],
                    volume: 5966901.794115081
                }
            }
        }
        ...
        ...
        ...

    ]
**/

Get Investment Details of Wallet in a Specific Pool

service invocation:

balancerService.getUserPool(POOL_ID, WALLET)
    .then((userPool) => console.log(userPool))
    .catch((error) => console.log(error));

output:

{
    "walletAddress": "WALLET_ADDRESS",
    "chain": "polygon",
    "userPoolShare": {
        "balance": "0.793507214668472709",
        "currency": "EUR",
        "investedAmount": 5.7703065445532875,
        "userAddress": "Mywallet",
        "pool": {
            "apr": { "base": 13.972187871832457 },
            "apy": { "base": 14.992318305052832 },
            "id": "0x0297e37f1873d2dab4487aa67cd56b58e2f27875000100000000000000000002",
            "liquidity": 2842802.1908321516,
            "poolName": "Balancer Polygon Base Pool",
            "tokens": [
                {
                    "address": "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
                    "balance": 1695842.946616207,
                    "decimals": 18,
                    "symbol": "WMATIC",
                    "weight": 0.25
                },
                {
                    "address": "0x2791bca1f2de4661ed88a30c99a7a9449aa84174",
                    "balance": 740560.659314,
                    "decimals": 6,
                    "symbol": "USDC",
                    "weight": 0.25
                },
                {
                    "address": "0x7ceb23fd6bc0add59e62ac25578270cff1b9f619",
                    "balance": 724.2606535552587,
                    "decimals": 18,
                    "symbol": "WETH",
                    "weight": 0.25
                },
                {
                    "address": "0x9a71012b13ca4d3d0cdc72a177df3ef03b0e76a3",
                    "balance": 171873.59791679878,
                    "decimals": 18,
                    "symbol": "BAL",
                    "weight": 0.25
                },
            ],
            "chainId": 137,
            "volume": 5966901.794115081
        }
    }
}

Add Liquidity to a Pool

TOKEN_VALUE_MAP = { '0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270' : 1, '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619': 0, 'token_address': amount to invest }

hasInfiniteAllowance : true if the token allowance must be set to exact amount to be invested. false if the allowance is to be set to infinity.

balancerService.joinPool(POOL_ID, TOKENS, TOKEN_ADDRESSES, CHAIN_ID, TOKEN_VALUE_MAP, WALLET_ADDRESS, hasInfiniteAllowance, WEB3_INSTANCE, JOIN_KIND)
    .then((tx) => console.log(tx))
    .catch((error) => console.log(error));

/**
Outputs the transaction hash
**/

Get Gas Cost Estimate to Add Liquidity to Pool

balancerService.getEstimatedGasCost(POOL_ID, TOKENS, TOKEN_ADDRESSES, CHAIN_ID, TOKEN_VALUE_MAP, WALLET_ADDRESS, WEB3_INSTANCE JOIN_KIND)
    .then((gas) => console.log(gas))
    .catch((error) => console.log(error));
/**
Outputs gas in token and in fiat
**/

Get an Estimated Value of Investment in Fiat Currency

balancerService.getEstimatedInvestmentValue(TOKEN_VALUE_MAP, CHAIN_ID)
    .then((value) => console.log(values))
    .catch((error) => console.log(error));
/**
Outputs estimated values and minimum BAL received
**/

Subgraphs Used

Contributors

Skytale Commons is developed by the Skytale team.

||| |---|---| |Dominic Fernandes | @dominic.fernandes| |Massimiliano Gerardi | @massi.gerardi | |Martin Mali | @martinheti | |Avinash Buddana | @avinash.buddana1 | |Enrico Mariotti | @boulder225 | |Joris Borsboom | @jorisborsboom | |Patrik Csokas | @patricck |