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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@blockswaplab/keth-sdk

v0.0.3

Published

SDK for kETH protocol

Downloads

10

Readme

@blockswaplab/keth-sdk

KETH SDK is a typescript SDK which can be used to interact with the kETH protocol.

Installation

To install the SDK use the command npm i @blockswaplab/keth-sdk

Using the KETH SDK

One of the ways to import and initialise the SDK is:

import { KETH } from "@blockswaplab/keth-sdk";
import { ethers } from "ethers";

const provider = new ethers.InfuraProvider(
  "mainnet",
  INFURA_PROJECT_ID,
  INFURA_PROJECT_SECRET
);

const signer = new ethers.Wallet(PRIV_KEY, provider);

const sdk = new KETH(signer);

The SDK supports both holesky and mainnet, hence the user should choose the network as per the need.

Please note that the SDK is an ethers.js based SDK and hence requires ethers based signer instance. It also returns values in ethers.js supported format. For example, it returns BigInt for the smart contract view functions that might return uint (BigNumber in case of ethers v5).

Also note that KETH SDK uses ethers v6. If you are using ethers v5 (not recommended), please create the signer and provider instances in the following way:

const provider = new ethers.providers.InfuraProvider("mainnet", {
    projectId: INFURA_PROJECT_ID,
    projectSecret: INFURA_PROJECT_SECRET
});
const signer = new ethers.Wallet(PRIV_KEY, provider);

The SDK exposed following sub-classes:

utils sub-class

The following readme describes all the functions and their parameters exposed by the utils class of the KETH SDK.

add0x function

This function can be used to append 0x towards the start of a string to convert it into a hex string accepted by the contracts. If the input string already contains the 0x, the function will return the string as is.

Input Parameters

data: string which needs to be appended by 0x

Using add0x function

await sdk.utils.add0x(data);

Return Parameter

Returns hex string

remove0x function

This function removes 0x from the beginning of a string. If the input string doesn't contain 0x, it will return the string as is.

Input Parameters

data: string to remove 0x from

Using remove0x function

await sdk.utils.remove0x(data);

Return Parameter

Returns string without 0x in the beginning.

contracts sub-class

The SDK also exposes the contractInstance sub-class which provides an instance for contracts used in the KETH protocol. These instances can be used to call smart contract functions that may or may not exist in the SDK.

Contract instances exposed by the sub-class

  • assetRegistry
  • dETHVault
  • kETHStrategy
  • kETHVault
  • kontroller
  • ETHToDETH
  • ETHToGiantLP
  • GiantLPToDETH
  • RETHToDETH
  • RETHToETH
  • RETHToGiantLP
  • WstETHToDETH
  • WstETHToETH
  • WstETHToGiantLP
  • YETHToDETH
  • YETHToETH
  • YETHToGiantLP
  • yETHAggregator

Using the contracts class

const assetRegistryContractInstance = await sdk.contracts.assetRegistry();
const dETHVaultContractInstance = await sdk.contracts.dETHVault();
const kETHStrategyContractInstance = await sdk.contracts.kETHStrategy();
const kETHVaultContractInstance = await sdk.contracts.kETHVault();
const kontrollerContractInstance = await sdk.contracts.kontroller();
const ETHToDETHContractInstance = await sdk.contracts.ETHToDETH();
const ETHToGiantLPContractInstance = await sdk.contracts.ETHToGiantLP();
const GiantLPToDETHContractInstance = await sdk.contracts.GiantLPToDETH();
const RETHToDETHContractInstance = await sdk.contracts.RETHToDETH();
const RETHToETHContractInstance = await sdk.contracts.RETHToETH();
const RETHToGiantLPContractInstance = await sdk.contracts.RETHToGiantLP();
const WstETHToDETHContractInstance = await sdk.contracts.WstETHToDETH();
const WstETHToETHContractInstance = await sdk.contracts.WstETHToETH();
const WstETHToGiantLPContractInstance = await sdk.contracts.WstETHToGiantLP();
const YETHToDETHContractInstance = await sdk.contracts.YETHToDETH();
const YETHToETHContractInstance = await sdk.contracts.YETHToETH();
const YETHToGiantLPContractInstance = await sdk.contracts.YETHToGiantLP();
const yETHAggregatorContractInstance = await sdk.contracts.yETHAggregator();

All the contract instances can be directly accessed without any input parameter.

assetRegistry sub-class

The following readme describes all the functions and their parameters exposed by the assetRegistry class of the KETH SDK.

assetValue function

This function returns the ETH value for a given asset from the following: ETH, dETH, GiantLP, wstETH, rETH, savETH.

Input Parameters

asset: The asset contract address
balance: The asset balance

Using assetValue function

await sdk.assetRegistry.assetValue(asset, balance);

Return Parameter

Returns the asset ETH value

dETHVault sub-class

The following readme describes all the functions and their parameters exposed by the dETHVault class of the KETH SDK.

amountToShare function

This function takes the ETH/dETH amount as the input and converts it to the equivalent LP Token amount.

Input Parameters

amount: The ETH/dETH amount

Using amountToShare function

await sdk.dETHVault.amountToShare(amount);

Return Parameter

Returns the LP Token amount

deposit function

This function allows the user to deposit dETH and get LP Tokens in return.

Input Parameters

amount: Amount of dETH to be deposited
recipient: The recipient address

Using deposit function

await sdk.dETHVault.deposit(amount, recipient);

Return Parameter

Transaction details if the transaction is successful.

reserves function

This function returns the reserve value of the given token.

Input Parameters

token: The token address

Using reserves function

await sdk.dETHVault.reserves(token);

Return Parameter

Returns the reserve value of the token

shareToAmount function

This function takes the LP Token amount as the input and converts it to the equivalent ETH/dETH amount.

Input Parameters

share: The LP Token amount

Using shareToAmount function

await sdk.dETHVault.shareToAmount(share);

Return Parameter

Returns the ETH/dETH amount

swapETHToDETH function

This function allows the user to deposit ETH and get dETH in return.

Input Parameters

recipient: The recipient address value: The ETH value to be deposited

Using swapETHToDETH function

await sdk.dETHVault.swapETHToDETH(recipient, value);

Return Parameter

Transaction details if the transaction is successful.

totalAssets function

This function returns the total ETH/dETH balance of the vault.

Using totalAssets function

await sdk.dETHVault.totalAssets();

Return Parameter

Returns the total ETH/dETH balance of the vault

withdrawToDETH function

This function allows the user to burn their LP Tokens and get their deposited dETH back.

Input Parameters

share: The LP Token amount to be burnt
recipient: The recipient address

Using withdrawToDETH function

await sdk.dETHVault.withdrawToDETH(share, recipient);

Return Parameter

Transaction details if the transaction is successful.

withdrawToETH function

This function allows the user to burn their LP Tokens and get their deposited ETH back.

Input Parameters

share: The LP Token amount to be burnt
recipient: The recipient address

Using withdrawToETH function

await sdk.dETHVault.withdrawToETH(share, recipient);

Return Parameter

Transaction details if the transaction is successful.

kETHStrategy sub-class

The following readme describes all the functions and their parameters exposed by the kETHStrategy class of the KETH SDK.
(asset: string, balance: bigint | string)

assetValue function

This function returns the ETH value for a given asset from the following: ETH, dETH, GiantLP, wstETH, rETH, savETH.

Input Parameters

asset: The asset contract address
balance: The asset balance

Using assetValue function

await sdk.kETHStrategy.assetValue(asset, balance);

Return Parameter

Returns the asset ETH value

assetsRatio function

This function returns the assets ratio.

Using assetsRatio function

await sdk.kETHStrategy.assetsRatio();

Return Parameter

Returns the assets ratio.

balance function

This function returns the current balance of the strategy contract for the given token.

Input Parameters

token: The token address

Using balance function

await sdk.kETHStrategy.balance(token);

Return Parameter

Returns the token balance of the strategy.

invokeSwap function

This function allows the user to invoke the swap function for a pair of tokens.

Input Parameters

swapper: The swapper contract address
tokenIn: The input token address
amountIn: The input token amount
tokenOut: The output token address
minAmountOut: The minimum output token amount
extraData: Optional extra calldata to be attached

Using invokeSwap function

await sdk.kETHStrategy.invokeSwap(swapper, tokenIn, amountIn, tokenOut, minAmountOut, extraData);

Return Parameter

Transaction details if the transaction is successful.

isHoldingAsset function

This function returns true if the given holding asset is supported, else false.

Input Parameters

asset: The asset address

Using isHoldingAsset function

await sdk.kETHStrategy.isHoldingAsset(asset);

Return Parameter

Returns true if the given holding asset is supported, else false

isUnderlyingAsset function

This function returns true if the given underlying asset is supported, else false

Input Parameters

underlying: The underlying asset address

Using isUnderlyingAsset function

await sdk.kETHStrategy.isUnderlyingAsset(underlying);

Return Parameter

Returns true if the given underlying asset is supported, else false

totalAssets function

This function returns the total assets value of strategy in ETH.

Using totalAssets function

await sdk.kETHStrategy.totalAssets();

Return Parameter

Returns the total assets value of strategy in ETH

underlyingAssets function

This function returns a list of the supported underlying assets.

Using underlyingAssets function

await sdk.kETHStrategy.underlyingAssets();

Return Parameter

Returns an array of supported underlying assets

kETHVault sub-class

The following readme describes all the functions and their parameters exposed by the kETHVault class of the KETH SDK.

deposit function

This function allows the user to deposit the underlying asset.

Input Parameters

underlying: The underlying asset adddress
amount: The underlying asset amount
recipient: The recipient address
sell: If true then autosell is enabled
value: ETH value to be deposited if underlying asset is ETH
referralAddress:

Using deposit function

await sdk.kETHVault.deposit(underlying, amount, recipient, sell, value, referralAddress);

Return Parameter

Transaction details if the transaction is successful.

totalAssets function

This function returns the total assets value of vault in ETH

Using totalAssets function

await sdk.kETHVault.totalAssets();

Return Parameter

Returns the total assets value of vault in ETH.

withdraw function

This function allows the user to burn their kETH and get their deposited ETH and dETH back.

Input Parameters

share: The kETH amount to be burnt recipient: The recipient address

Using withdraw function

await sdk.kETHVault.withdraw(share, recipient);

Return Parameter

Transaction details if the transaction is successful.

priceAggregators sub-class

The following readme describes all the functions and their parameters exposed by the priceAggregators class of the KETH SDK. This sub-class exposes the values returned by priceAggregators individually.

latestRoundDataYETH function

This function returns the latest round data for the yETH token.

Using latestRoundDataYETH function

await sdk.priceAggregators.latestRoundDataYETH();

Return Parameter

Returns the latest round data for the yETH token.

swappers sub-class

The following readme describes all the functions and their parameters exposed by the swappers class of the KETH SDK. This sub-class exposes the swap functions on the different swapper contracts induvidually as a part of a single class.

swapETHToDETH function

This function allows the user to swap ETH for dETH.

Input Parameters

amountIn: The input token amount
value: ETH value to be deposited, equal to amountIn
minAmountOut: The minimum output token amount, 0 by default
callData: Optional extra calldata to be attached

Using swapETHToDETH function

await sdk.swappers.swapETHToDETH(amountIn, value, minAmountOut, callData);

Return Parameter

Transaction details if the transaction is successful.

swapETHToGiantLP function

This function allows the user to swap ETH for GiantLP.

Input Parameters

amountIn: The input token amount
value: ETH value to be deposited, equal to amountIn
minAmountOut: The minimum output token amount, 0 by default
callData: Optional extra calldata to be attached

Using swapETHToGiantLP function

await sdk.swappers.swapETHToGiantLP(amountIn, value, minAmountOut, callData);

Return Parameter

Transaction details if the transaction is successful.

swapGiantLPToDETH function

This function allows the user to swap GiantLP for dETH.

Input Parameters

amountIn: The input token amount
minAmountOut: The minimum output token amount, 0 by default
callData: Optional extra calldata to be attached

Using swapGiantLPToDETH function

await sdk.swappers.swapGiantLPToDETH(amountIn, minAmountOut, callData);

Return Parameter

Transaction details if the transaction is successful.

swapRETHToDETH function

This function allows the user to swap RETH for dETH.

Input Parameters

amountIn: The input token amount
minAmountOut: The minimum output token amount, 0 by default
callData: Optional extra calldata to be attached

Using swapRETHToDETH function

await sdk.swappers.swapRETHToDETH(amountIn, minAmountOut, callData);

Return Parameter

Transaction details if the transaction is successful.

swapRETHToETH function

This function allows the user to swap RETH for ETH.

Input Parameters

amountIn: The input token amount
minAmountOut: The minimum output token amount, 0 by default
callData: Optional extra calldata to be attached

Using swapRETHToETH function

await sdk.swappers.swapRETHToETH(amountIn, minAmountOut, callData);

Return Parameter

Transaction details if the transaction is successful.

swapRETHToGiantLP function

This function allows the user to swap RETH for GiantLP.

Input Parameters

amountIn: The input token amount
minAmountOut: The minimum output token amount, 0 by default
callData: Optional extra calldata to be attached

Using swapRETHToGiantLP function

await sdk.swappers.swapRETHToGiantLP(amountIn, minAmountOut, callData);

Return Parameter

Transaction details if the transaction is successful.

swapWstETHToDETH function

This function allows the user to swap WstETH for dETH.

Input Parameters

amountIn: The input token amount
minAmountOut: The minimum output token amount, 0 by default
callData: Optional extra calldata to be attached

Using swapWstETHToDETH function

await sdk.swappers.swapWstETHToDETH(amountIn, minAmountOut, callData);

Return Parameter

Transaction details if the transaction is successful.

swapWstETHToETH function

This function allows the user to swap WstETH for ETH.

Input Parameters

amountIn: The input token amount
minAmountOut: The minimum output token amount, 0 by default
callData: Optional extra calldata to be attached

Using swapWstETHToETH function

await sdk.swappers.swapWstETHToETH(amountIn, minAmountOut, callData);

Return Parameter

Transaction details if the transaction is successful.

swapWstETHToGiantLP function

This function allows the user to swap WstETH for GiantLP.

Input Parameters

amountIn: The input token amount
minAmountOut: The minimum output token amount, 0 by default
callData: Optional extra calldata to be attached

Using swapWstETHToGiantLP function

await sdk.swappers.swapWstETHToGiantLP(amountIn, minAmountOut, callData);

Return Parameter

Transaction details if the transaction is successful.

swapYETHToDETH function

This function allows the user to swap yETH for dETH.

Input Parameters

amountIn: The input token amount
minAmountOut: The minimum output token amount, 0 by default
callData: Optional extra calldata to be attached

Using swapYETHToDETH function

await sdk.swappers.swapYETHToDETH(amountIn, minAmountOut, callData);

Return Parameter

Transaction details if the transaction is successful.

swapYETHToETH function

This function allows the user to swap yETH for ETH.

Input Parameters

amountIn: The input token amount
minAmountOut: The minimum output token amount, 0 by default
callData: Optional extra calldata to be attached

Using swapYETHToETH function

await sdk.swappers.swapYETHToETH(amountIn, minAmountOut, callData);

Return Parameter

Transaction details if the transaction is successful.

swapYETHToGiantLP

This function allows the user to swap yETH for GiantLP.

Input Parameters

amountIn: The input token amount
minAmountOut: The minimum output token amount, 0 by default
callData: Optional extra calldata to be attached

Using swapYETHToGiantLP function

await sdk.swappers.swapYETHToGiantLP(amountIn, minAmountOut, callData);

Return Parameter

Transaction details if the transaction is successful.