Redemption request
Create a redemption request on the shares contract to exit a fund.
Redeeming is a single step; no approval is needed, because the shares contract pulls the shares you already hold into escrow:
function requestRedemption(
uint256 sharesIn, // amount of shares to redeem
uint256 minAssetsOut, // slippage protection, applied AFTER the redemption fee
address redemptionAsset,// must be approved for redemptions (canRedeem = true)
address receiver // who receives the assets
) external returns (uint256 requestId);Example
Redeeming 500 shares (18 decimals) for USDC. We read the fund's current share price (see Calculate share price), deduct the redemption fee, convert the remainder with sharesToAssets, and apply a 0.5% example tolerance to get minAssetsOut.
import { createWalletClient, createPublicClient, http, parseAbi, parseUnits } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { mainnet } from "viem/chains";
const SHARES = "0x..."; // fund shares contract
const USDC = "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48";
const sharesAbi = parseAbi([
"function sharesToAssets(uint256 shares, uint256 sharesPrice, address redemptionAsset) view returns (uint256)",
"function redemptionFeeRate() view returns (uint256)",
"function requestRedemption(uint256 sharesIn, uint256 minAssetsOut, address redemptionAsset, address receiver) returns (uint256)",
]);
const account = privateKeyToAccount("0x...");
const pub = createPublicClient({ chain: mainnet, transport: http() });
const wallet = createWalletClient({ account, chain: mainnet, transport: http() });
const sharesIn = parseUnits("500", 18); // 500 shares
// 1. Current share price in 8-decimal USD — compute it onchain per Calculate share price.
const sharePrice = await getSharePrice(pub); // bigint, 8 decimals — see Calculate share price
// 2. Deduct the redemption fee, convert the remainder, then apply your tolerance.
const feeRate = await pub.readContract({ address: SHARES, abi: sharesAbi, functionName: "redemptionFeeRate" });
const netShares = sharesIn - (sharesIn * feeRate) / 10000n;
const expectedAssets = await pub.readContract({
address: SHARES, abi: sharesAbi, functionName: "sharesToAssets",
args: [netShares, sharePrice, USDC],
});
const minAssetsOut = (expectedAssets * 9950n) / 10000n; // 0.5% is only an example — set your own tolerance
const hash = await wallet.writeContract({
address: SHARES, abi: sharesAbi, functionName: "requestRedemption",
args: [sharesIn, minAssetsOut, USDC, account.address],
});Events
Creating a redemption request emits a RedemptionRequest event containing the requestId, cancelableFrom, and expiryAt. Track it as described in Monitor a request.


Last updated