HYSP Vault
Learn how to connect HYSP Vault staking through Everstake Wallet SDK.
Getting Started
The HYSP Vault SDK provides a simple interface for interacting with HYSP vault contracts on EVM 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$ yarn add @everstake/wallet-sdk-hyspStep 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 target blockchain:
Supported networks
Network types, which can be used for initialization:
eth_mainnet- Ethereum Mainnetbase- Base Mainnet
Deposit Flow Example
Here's a complete example showing how to deposit tokens:
Redeem Flow Example
Here's an example showing how to redeem collateral tokens back to USDC:
Next Steps
Now that you have the SDK set up, you can explore the available methods:
Getting Info- Retrieve vault information, balances, and feesDeposit Instant- Deposit tokens instantlyRedeem Instant- Redeem tokens instantlyRedeem Request- Create redeem requests for non-instant redemptions (no fee)Approve Issuance- Approve tokens for depositsApprove 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.
Get Minimum Redeem Amount
minRedeemAmount(outTokenAddress?): Retrieves the minimum redeem amount from the redemption vault contract.
Get Instant Deposit Fee
getInstantDepositFee(): Retrieves the instant deposit fee from the issuance vault contract.
Get Instant Redeem Fee
getInstantRedeemFee(): Retrieves the instant redeem fee from the redemption vault contract.
Get Oracle Price
getPrice(): Retrieves the price from the oracle contract.
Get Token Balance
balanceOf(address, erc20contractAddress?): Retrieves the balance of ERC20 token associated with vault or collateral token.
Get APY
getAPY(): Retrieves the vault APY (Annual Percentage Yield) from the Midas API as a decimal number (for example,0.05means5%). The value is returned as anumber.
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 sendertokenIn(string): The token address to deposit (must be supported by issuance vault)amount(BigNumberish): The amount to depositminReceiveAmount(BigNumberish): The minimum amount to receive (slippage protection)referrerId(string): The referrer ID as bytes32 (useZeroReferrerfor no referrer)
Code Example
Calculating minReceiveAmount
The minReceiveAmount can be calculated using the oracle price to provide slippage protection:
Prerequisites
Token must be approved for issuance vault before depositing (use
approveToIssuanceVault())Token must be in
hysp.supportedIssuanceTokensAddressesSufficient 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 sendertokenOut(string): The token address to redeem to (must be supported by redemption vault)amount(BigNumberish): The amount of mToken to redeemminReceiveAmount(BigNumberish): The minimum amount of tokenOut to receive (slippage protection)
Code Example
Prerequisites
Collateral tokens must be approved for redemption vault before redeeming (use
approveToRedemptionVault())Token must be in
hysp.supportedRedemptionTokensAddressesSufficient 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 sendertokenOut(string): The token address to redeem to (must be supported by redemption vault)amount(BigNumberish): The amount of mToken to redeem
Code Example
Prerequisites
Token must be in
hysp.supportedRedemptionTokensAddressesSufficient 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 sendertokenAddress(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
Prerequisites
Token must be in
hysp.supportedIssuanceTokensAddressesSufficient 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 senderamount(BigNumberish): The amount of collateral tokens to approve
Code Example
Prerequisites
Sufficient collateral token balance required
Sufficient ETH for gas fees

