Documentation v1.0 has been released! Staking Guide, Protocols, Glossary, FAQ, and Support sections have been added.

HYSP Vault

Getting Started

The HYSP Vault SDK provides a simple interface for interacting with HYSP vault contracts on Ethereum networks. It supports both issuance (deposit) and redemption (withdraw) operations for tokenized assets.

Option 1: TypeScript library

You can install and import Wallet SDK for Javascript/TypeScript.

Step 1: Installing the Library

Install the npm library or yarn by copying the code below.

$ npm install @everstake/wallet-sdk-hysp

Step 2: Import Wallet SDK

After installing the package, you can import the HYSP module and use the SDK:

Import ES6

// import module
import { HYSP, ZeroReferrer } from "@everstake/wallet-sdk-hysp";

Import ES5

// import module
const { HYSP, ZeroReferrer } = require("@everstake/wallet-sdk-hysp");

Step 3: Initialize the SDK

Before using any methods, you need to initialize the HYSP SDK with the desired network and vault type:

import { HYSP, NetworkType, HYSPVaultType } from "@everstake/wallet-sdk-hysp";

// Create a new HYSP instance
const hysp = new HYSP();

// Initialize with network and vault type
await hysp.init(
  "eth_mainnet" as NetworkType, // Optional network: defaults to 'eth_mainnet'
  "https://your-rpc-url" // Optional: Custom RPC URL
);

console.log("Supported deposit tokens:", hysp.supportedIssuanceTokensAddresses);
console.log(
  "Supported redeem tokens:",
  hysp.supportedRedemptionTokensAddresses
);

Deposit Flow Example

Here's a complete example showing how to deposit tokens:

import { HYSP, ZeroReferrer } from "@everstake/wallet-sdk-hysp";
import { ethers } from "ethers";

async function hyspExample() {
  // Initialize SDK
  const hysp = new HYSP();
  await hysp.init();

  const walletAddress = "0x..."; // Your wallet address
  const tokenAddress = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"; // USDC
  const depositAmount = 100.5; // Amount to deposit

  // 1. Check token balance
  const balance = await hysp.balanceOf(walletAddress, tokenAddress);
  console.log("Token balance:", balance.toString());

  // 2. Get deposit fee
  const depositFee = await hysp.getInstantDepositFee();
  console.log("Deposit fee:", depositFee, "%");

  // 3. Approve tokens for deposit
  const approveTx = await hysp.approveToIssuanceVault(
    walletAddress,
    tokenAddress,
    depositAmount
  );

  // ... (sign and send approveTx)

  // 4. Deposit tokens
  const depositTx = await hysp.depositInstant(
    walletAddress,
    tokenAddress,
    depositAmount,
    0, // minReceiveAmount
    ZeroReferrer
  );

  // ... (sign and send depositTx)

  console.log("Deposit completed!");
}

Redeem Flow Example

Here's an example showing how to redeem collateral tokens back to USDC:

async function redeemExample() {
  // Initialize SDK
  const hysp = new HYSP();
  await hysp.init();

  const walletAddress = "0x..."; // Your wallet address
  const usdcAddress = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"; // USDC
  const redeemAmount = 50.0; // Amount to redeem

  // 1. Check collateral balance
  const collateralBalance = await hysp.balanceOf(walletAddress);
  console.log("Collateral balance:", collateralBalance.toString());

  // 2. Check redemption liquidity
  const liquidity = await hysp.getInstantRedeemLiquidityAmount(usdcAddress);
  console.log("Available liquidity:", liquidity.toString());

  // 3. Approve collateral for redemption
  const approveTx = await hysp.approveToRedemptionVault(
    walletAddress,
    redeemAmount
  );

  // ... (sign and send approveTx)

  const redeemRequestTx = await hysp.redeemRequest(
    walletAddress,
    usdcAddress,
    redeemAmount
  );
  // ... (sign and send redeemRequestTx)
  console.log("Redeem request created!");
}

Network and Vault Types

Supported networks:

  • eth_mainnet - Ethereum Mainnet

Supported vault types depend on the network configuration. Common types include:

  • mEVUSD - HYSP mEVUSD Vault

Next Steps

Now that you have the SDK set up, you can explore the available methods:

  • Getting Info - Retrieve vault information, balances, and fees

  • Deposit Instant - Deposit tokens instantly

  • Redeem Instant - Redeem tokens instantly

  • Redeem Request - Create redeem requests for non-instant redemptions (no fee)

  • Approve Issuance - Approve tokens for deposits

  • Approve Redemption - Approve tokens for redemptions

Getting Info

This page describes methods for retrieving information about HYSP vaults, including balances, fees, and liquidity.

Get Instant Redeem Liquidity

  • getInstantRedeemLiquidityAmount(outTokenAddress?): Retrieves the liquidity available for instant redemption in the redemption vault contract.

import { HYSP } from "@everstake/wallet-sdk-hysp";

const hysp = new HYSP();
await hysp.init();

const usdcAddress = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48";
const liquidity = await hysp.getInstantRedeemLiquidityAmount(usdcAddress);
console.log("Available liquidity:", liquidity.toString());

Get Minimum Redeem Amount

  • minRedeemAmount(outTokenAddress?): Retrieves the minimum redeem amount from the redemption vault contract.

const minAmount = await hysp.minRedeemAmount(usdcAddress);
console.log("Minimum redeem amount:", minAmount.toString());

Get Instant Deposit Fee

  • getInstantDepositFee(): Retrieves the instant deposit fee from the issuance vault contract.

const depositFee = await hysp.getInstantDepositFee();
console.log("Instant deposit fee:", depositFee, "%");

Get Instant Redeem Fee

  • getInstantRedeemFee(): Retrieves the instant redeem fee from the redemption vault contract.

const redeemFee = await hysp.getInstantRedeemFee();
console.log("Instant redeem fee:", redeemFee, "%");

Get Oracle Price

  • getPrice(): Retrieves the price from the oracle contract.

const price = await hysp.getPrice();
console.log("Oracle price:", price.toString());

Get Token Balance

  • balanceOf(address, erc20contractAddress?): Retrieves the balance of ERC20 token associated with vault or collateral token.

const walletAddress = "0x...";

// Get USDC balance
const usdcBalance = await hysp.balanceOf(walletAddress, usdcAddress);
console.log("USDC balance:", usdcBalance.toString());

// Get collateral token balance (default)
const collateralBalance = await hysp.balanceOf(walletAddress);
console.log("Collateral balance:", collateralBalance.toString());

Deposit instant

  • depositInstant(sender, tokenIn, amount, minReceiveAmount, referrerId): Prepares an instant deposit transaction that will deposit tokens with auto mint if account fits daily limit and token allowance. The prepared transaction will transfer token from the user, fee in tokenIn to feeReceiver, and mint collateral to user.

Parameters

  • sender (string): The address of the transaction sender

  • tokenIn (string): The token address to deposit (must be supported by issuance vault)

  • amount (BigNumberish): The amount to deposit

  • minReceiveAmount (BigNumberish): The minimum amount to receive (slippage protection)

  • referrerId (string): The referrer ID as bytes32 (use ZeroReferrer for no referrer)

Code Example

import { HYSP, ZeroReferrer } from "@everstake/wallet-sdk-hysp";
import { ethers } from "ethers";

// Initialize SDK
const hysp = new HYSP();
await hysp.init();

const walletAddress = "0x...";
const usdcAddress = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48";
const depositAmount = 100.0;

// Create deposit transaction
const depositTx = await hysp.depositInstant(
  walletAddress,
  usdcAddress,
  depositAmount,
  0, // minReceiveAmount
  ZeroReferrer
);

// Sign and send transaction
const signer = await ethers.getSigner();
const txResponse = await signer.sendTransaction(depositTx);
await txResponse.wait();

Calculating minReceiveAmount

The minReceiveAmount can be calculated using the oracle price to provide slippage protection:

// Calculate minimum receive amount with slippage protection
const price = await hysp.getPrice();
const depositFee = await hysp.getInstantDepositFee();
const slippageTolerance = 0.01; // 1% slippage tolerance

// Calculate expected output after fees
const grossOutput = new BigNumber(depositAmount).multipliedBy(price);
const feeAmount = grossOutput.multipliedBy(depositFee / 100);
const expectedOutput = grossOutput.minus(feeAmount);

// Apply slippage tolerance
const minReceiveAmount = expectedOutput.multipliedBy(1 - slippageTolerance);

// Create deposit transaction with slippage protection
const depositTx = await hysp.depositInstant(
  walletAddress,
  usdcAddress,
  depositAmount,
  minReceiveAmount,
  ZeroReferrer
);

Prerequisites

  • Token must be approved for issuance vault before depositing (use approveToIssuanceVault())

  • Token must be in hysp.supportedIssuanceTokensAddresses

  • Sufficient token balance required

Redeem Instant

  • redeemInstant(sender, tokenOut, amount, minReceiveAmount): Prepares an instant redeem transaction that will redeem mToken to tokenOut if daily limit and allowance not exceeded. The prepared transaction will burn mToken from the user, transfer fee in mToken to feeReceiver, and transfer tokenOut to user.

Parameters

  • sender (string): The address of the transaction sender

  • tokenOut (string): The token address to redeem to (must be supported by redemption vault)

  • amount (BigNumberish): The amount of mToken to redeem

  • minReceiveAmount (BigNumberish): The minimum amount of tokenOut to receive (slippage protection)

Code Example

import { HYSP } from "@everstake/wallet-sdk-hysp";
import { ethers } from "ethers";

// Initialize SDK
const hysp = new HYSP();
await hysp.init();

const walletAddress = "0x...";
const usdcAddress = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48";
const redeemAmount = "50.0";

// Create redeem transaction
const redeemTx = await hysp.redeemInstant(
  walletAddress,
  usdcAddress,
  redeemAmount,
  0 // minReceiveAmount
);

// Sign and send transaction
const signer = await ethers.getSigner();
const txResponse = await signer.sendTransaction(redeemTx);
await txResponse.wait();

Prerequisites

  • Collateral tokens must be approved for redemption vault before redeeming (use approveToRedemptionVault())

  • Token must be in hysp.supportedRedemptionTokensAddresses

  • Sufficient collateral balance required

  • Vault must have sufficient liquidity for instant redemption

Redeem Request

  • redeemRequest(sender, tokenOut, amount): Prepares a redeem request transaction if tokenOut is not fiat. The prepared transaction will transfer amount in mToken to contract and fee in mToken to feeReceiver. This method is used when instant redemption is not possible due to liquidity constraints.

Parameters

  • sender (string): The address of the transaction sender

  • tokenOut (string): The token address to redeem to (must be supported by redemption vault)

  • amount (BigNumberish): The amount of mToken to redeem

Code Example

import { HYSP } from "@everstake/wallet-sdk-hysp";
import { ethers } from "ethers";

// Initialize SDK
const hysp = new HYSP();
await hysp.init();

const walletAddress = "0x...";
const usdcAddress = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48";
const redeemAmount = "500.0";

// Create redeem request transaction
const redeemRequestTx = await hysp.redeemRequest(
  walletAddress,
  usdcAddress,
  redeemAmount
);

// Sign and send transaction
const signer = await ethers.getSigner();
const txResponse = await signer.sendTransaction(redeemRequestTx);
await txResponse.wait();

Prerequisites

  • Token must be in hysp.supportedRedemptionTokensAddresses

  • Sufficient collateral balance required

  • Token must not be a fiat token

Approve Issuance

  • approveToIssuanceVault(sender, tokenAddress, amount): Prepares an approval transaction that will approve the issuance vault to spend a specified amount of a given token on behalf of the sender. This transaction must be executed before depositing tokens.

Parameters

  • sender (string): The address of the transaction sender

  • tokenAddress (string): The address of the ERC20 token to approve (must be supported by issuance vault)

  • amount (BigNumberish): The amount of tokens to approve

Code Example

import { HYSP } from "@everstake/wallet-sdk-hysp";
import { ethers } from "ethers";

// Initialize SDK
const hysp = new HYSP();
await hysp.init();

const walletAddress = "0x...";
const usdcAddress = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48";
const approveAmount = "100.0";

// Create approval transaction
const approveTx = await hysp.approveToIssuanceVault(
  walletAddress,
  usdcAddress,
  approveAmount
);

// Sign and send transaction
const signer = await ethers.getSigner();
const txResponse = await signer.sendTransaction(approveTx);
await txResponse.wait();

Prerequisites

  • Token must be in hysp.supportedIssuanceTokensAddresses

  • Sufficient token balance required

  • Sufficient ETH for gas fees

Approve Redemption

  • approveToRedemptionVault(sender, amount): Prepares an approval transaction that will approve the redemption vault to spend a specified amount of the collateral token on behalf of the sender. This transaction must be executed before redeeming tokens.

Parameters

  • sender (string): The address of the transaction sender

  • amount (BigNumberish): The amount of collateral tokens to approve

Code Example

import { HYSP } from "@everstake/wallet-sdk-hysp";
import { ethers } from "ethers";

// Initialize SDK
const hysp = new HYSP();
await hysp.init();

const walletAddress = "0x...";
const redeemAmount = "50.0";

// Create approval transaction
const approveTx = await hysp.approveToRedemptionVault(
  walletAddress,
  redeemAmount
);

// Sign and send transaction
const signer = await ethers.getSigner();
const txResponse = await signer.sendTransaction(approveTx);
await txResponse.wait();

Prerequisites

  • Sufficient collateral token balance required

  • Sufficient ETH for gas fees