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

branded-lst-sdk

v0.0.31

Published

This is the Dinero Branded LST SDK. It provides a set of functions to be able to easier interact with blockchain contract interactions related to your Branded LST implementation. The sdk is built on top of [viem](https://viem.sh).

Downloads

32

Readme

Dinero Branded LST SDK

This is the Dinero Branded LST SDK. It provides a set of functions to be able to easier interact with blockchain contract interactions related to your Branded LST implementation. The sdk is built on top of viem.

Installation

yarn add branded-lst-sdk

Usage

Set up the SDK

Initialize the SDK using your Branded LST Mainnet and L2 details. Example below:

import BrandedLstSdk from 'branded-lst-sdk'
import { modeTestnet, holesky } from 'viem/chains'

const sdk = new BrandedLstSdk({
  l2Details: {
    chain: modeTestnet,
    rpcUrl: 'https://sepolia.mode.network',
    syncPool: '0x7950cD6317d88068Ad2DE6461dB3C5eBDE298896',
    lst: '0xBbF1EC701f3214578f14282d9182E016682b729D',
    lzEndpointId: 40260,
  },
  mainnetDetails: {
    chain: holesky,
    rpcUrl: 'https://ethereum-holesky-rpc.publicnode.com',
    lockBox: '0xBbF1EC701f3214578f14282d9182E016682b729D',
    lzEndpointId: 40217,
  },
})

Deposit ETH into LST

There are two possibilities when depositing into your LST. You can either deposit ETH from mainnet, or you can deposit ETH from L2. Either way, the user will receive the LST on L2. Depending on the chain specified as an argument will determine which route the deposit flow goes through.

The second argument is a callback function which allows use of the transaction hashes for multi step processes involved with cross chain transactions.

Below is an example of a deposit using wagmi (react wrapper for viem):

import type { Chain, WalletClient } from 'viem'
import { holesky } from 'viem/chains'
import { useAccount, useBalance, useWalletClient } from 'wagmi'

const { address: walletAddress } = useAccount()
const { data: client } = useWalletClient()

const callbackFn = ({ srcTxHash, dstTxHash, state }) => {
    console.log('srcTxHash', srcTxHash)
    console.log('dstTxHash', dstTxHash)
    console.log('state', state)
}

const dstTxHash = await sdk.deposit(
    {
        // Need to coerce types if using wagmi
        walletClient: client as WalletClient,
        receiver: walletAddress!,
        amount: BigInt(depositAmount),
        chain: holesky,
    }, 
    callbackFn
)

Withdraw LST from L2

Withdrawals can only be done from L2 -> Mainnet so no chain argument is necessary but the rest is the same as the deposit flow, including the typing of the callback function.

const dstTxhash = await sdk.withdraw(
    {
        walletClient: client as WalletClient,
        receiver: walletAddress!,
        amount: BigInt(withdrawAmount),
    },
    callbackFn
)

Layer Zero quotes

To receive the fee required for the crosschain transaction, you can use the quoteWithdraw() or quoteDeposit() functions. The quoteWithdraw function will return the fee required to withdraw from L2 to Mainnet, and the quoteDeposit function will return the fee required to deposit from Mainnet to L2. This fee will be automatically included in the transaction when using the sdk but is exposed if you want to display the fee on your UI.

const lzWithdrawFee = await sdk.quoteWithdraw({
    receiver: walletAddress!,
    amount: BigInt(withdrawAmount),
})

const lzDepositFee = await sdk.quoteDeposit({
    receiver: walletAddress!,
    amount: BigInt(depositAmount),
})