Instant Redeem
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
ts
import { HYSP } from "@everstake/wallet-sdk-hysp";
import { ethers } from "ethers";
// Initialize SDK
const hysp = new HYSP();
await hysp.init("eth_mainnet", "mmev");
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