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

nimbora-liquity

v0.0.3

Published

Nimbora liquity sdk

Downloads

33

Readme

Nimbora - SDK

About us

Nimbora is a platform that offers you the opportunity to interact with your favorite Layer 1 (L1) protocols at a fraction of the cost of Layer 2 (L2) solutions.

You can learn more about Nimbora by follow us on Medium, Twitter, or join our Telegram group.

About the SDK

This SDK helps you integrate with Nimbora YieldDex.

Contents:

Token Manager

Installation

$ npm install nimbora-token-manager
$ yarn add nimbora-token-manager

All methods

Setup a Token Manager

import { TokenManager } from 'nimbora-token-manager';
import { RpcProvider } from 'starknet';

const tokenManagerAddress: string = '';
const provider = new RpcProvider({ nodeUrl: 'https://starknet-goerli.g.alchemy.com/v2/XXX' });

const accountAddress = process.env.ACCOUNT_ADDRESS;
const accountPrivateKey = process.env.ACCOUNT_PRIVATE_KEY;
const account = new Account(provider, accountAddress, accountPrivateKey);

const tokenManager = new TokenManager(tokenManagerAddress, provider, account);

Deposit

Deposit tokens into the Layer 2 Token Manager contract by calling deposit function. This function can execute a multi-call if the allowance to the token manager is insufficient [allowance + deposit].

...
try {
    const { shares, hash } = await tokenManager.deposit({
        amount: "100",
        receiver: account.address, // The shares receiver account address.
        referral: account.address, // The referral account address.
        onTxStageChange: txStageChangeCallback, // Optional callback for getting information about transaction stage
    })
} catch (e) {
    // Handle Errors
}

Request Withdrawal

A withdrawal request from a token manager can be made by invoking the requestWithdrawal function, specifying the amount of shares the user wishes to exchange for underlying tokens.

...
try {
    const { id, hash } = await tokenManager.requestWithdrawal({
        shares: "100", // Total shares to exchange for the underlying token.
        onTxStageChange: txStageChangeCallback, // Optional callback for getting information about transaction stage.
    })
} catch (e) {
    // Handle Errors
}

Claim Withdrawal

Claim a withdrawal from a token manager can be done by calling the claimWithdrawal.

...
try {
    const hash = await tokenManager.claimWithdrawal({
        claimWithdrawal: "1", // The request withdrawal id.
        onTxStageChange: txStageChangeCallback, // Optional callback for getting information about transaction stage.
    })
} catch (e) {
    // Handle Errors
}

performanceFees

Returns the protocol performance fee

...
try {
    const fee = await tokenManager.performanceFees()
} catch (e) {
    // Handle Errors
}

depositLimitLow

Returns the minimum amount allowed to deposit into the token manager

...
try {
    const amount = await tokenManager.depositLimitLow()
} catch (e) {
    // Handle Errors
}

depositLimitHigh

Returns the maximum amount allowed to deposit into the token manager

...
try {
    const amount = await tokenManager.depositLimitHigh()
} catch (e) {
    // Handle Errors
}

withdrawalLimitLow

Returns the minimum amount allowed to withdraw from the token manager

...
try {
    const amount = await tokenManager.withdrawalLimitLow()
} catch (e) {
    // Handle Errors
}

withdrawalLimitHigh

Returns the maximum amount allowed to withdraw from the token manager

...
try {
    const amount = await tokenManager.withdrawalLimitHigh()
} catch (e) {
    // Handle Errors
}

withdrawalEpochDelay

Returns the epoch delay before the request withdrawal is processed by the pooling manager

...
try {
    const epoch = await tokenManager.withdrawalEpochDelay()
} catch (e) {
    // Handle Errors
}

epoch

Returns the current epoch

...
try {
    const epoch = await tokenManager.epoch()
} catch (e) {
    // Handle Errors
}

lastProcessedEpoch

Returns the epoch reported and where withdrawals were processed

...
try {
    const epoch = await tokenManager.lastProcessedEpoch()
} catch (e) {
    // Handle Errors
}

l1NetAssetValue

Returns the L1 net asset value

...
try {
    const nav = await tokenManager.l1NetAssetValue()
} catch (e) {
    // Handle Errors
}

totalAssets

This returns the Total Value Locked (TVL) in the underlying token. It includes the buffered tokens on both L1, L2, as well as the tokens in transit (currently bridged).

...
try {
    const tvl = await tokenManager.totalAssets()
} catch (e) {
    // Handle Errors
}

withdrawalExchangeRate

The exchange rate to convert the shares<>underlying tokens per epoch.

...
try {
    const epoch = 1
    const rate = await tokenManager.withdrawalExchangeRate(epoch)
} catch (e) {
    // Handle Errors
}

listUserRequestWithdrawal

List all the users request withdrawal

...
try {
    const address = account.address // user address
    const withdrawals = await tokenManager.listUserRequestWithdrawal(address)
} catch (e) {
    // Handle Errors
}

lastUserRequestWithdrawal

Return the last request withdrawal made by the user.

...
try {
    const address = account.address // user address
    const withdrawal = await tokenManager.lastUserRequestWithdrawal(address)
} catch (e) {
    // Handle Errors
}

shareToUnderlying

Convert the shares to underlying token

...
try {
    const shares = "100" // amount in shares
    const underlyingAmount = await tokenManager.shareToUnderlying(shares)
} catch (e) {
    // Handle Errors
}

UnderlyingToShare

Convert the underlying to shares token.

...
try {
    const underlyingAmount = "100" // amount in shares
    const shares = await tokenManager.UnderlyingToShare(underlyingAmount)
} catch (e) {
    // Handle Errors
}

underlying

Returns the underlying contract

...
try {
    const underlingContract = await tokenManager.underlying()
    const balance = await underlingContract.call('balance_of', [account.address])
} catch (e) {
    // Handle Errors
}

token

Returns the token share contract

...
try {
    const tokenContract = await tokenManager.token()
    const balance = await tokenContract.call('balance_of', [account.address])
} catch (e) {
    // Handle Errors
}

Learn more