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: REST API
You can use REST API to call methods which are described in Swagger with detailed examples
https://wallet-sdk-api.everstake.one
Option 2: TypeScript library
You can install and import Wallet SDK for Javascript/TypeScript.
Step 1: Installing the Library
Install the npm library by copying the code below.
$ npm install @everstake/wallet-sdk-hysp
or you can also use yarn
$ yarn add @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, // Network: 'eth_mainnet'
"mmev" as HYSPVaultType, // Vault type: 'mmev'
"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("eth_mainnet", "mmev");
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("eth_mainnet", "mmev");
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:
mmev
- HYSP mMEV Vault, works witheth_mainnet
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