For the complete documentation index, see llms.txt. This page is also available as Markdown.

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, with a 0.5% slippage tolerance.

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 previewRedemption(uint256 shares, uint256 sharesPrice, address redemptionAsset) 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

// Estimate assets out (net of the redemption fee) at the last settled price, then apply slippage.
const expectedAssets = await pub.readContract({
  address: SHARES, abi: sharesAbi, functionName: "previewRedemption",
  args: [sharesIn, 0n, USDC],
});
const minAssetsOut = (expectedAssets * 9950n) / 10000n;

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.

Redemption flow example

Last updated