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

Cancel a request

Recover tokens from a stale, still-pending request after its TTL has elapsed.

A subscription or redemption request can be cancelled by its investor or receiver, provided it is still pending (not yet approved or denied) and its cancellation TTL has elapsed. This lets users recover tokens from stale requests.

function cancelSubscription(uint256 id) external; // returns escrowed assets to the investor
function cancelRedemption(uint256 id) external;   // returns escrowed shares to the investor

The TTL after which a request becomes cancellable is the cancelableFrom timestamp in the request's creation event (timestamp + subscriptionRequestTtl / + redemptionRequestTtl). Calling before then reverts with RequestNotPastTtl; calling on a non-pending request reverts with RequestNotPending.

import { createWalletClient, http, parseAbi } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { mainnet } from "viem/chains";

const SHARES = "0x...";
const abi = parseAbi([
  "function cancelSubscription(uint256 id)",
  "function cancelRedemption(uint256 id)",
]);

const account = privateKeyToAccount("0x...");
const wallet = createWalletClient({ account, chain: mainnet, transport: http() });

await wallet.writeContract({ address: SHARES, abi, functionName: "cancelSubscription", args: [42n] });
import { ethers } from "ethers";

const SHARES = "0x...";
const abi = ["function cancelSubscription(uint256 id)", "function cancelRedemption(uint256 id)"];

const provider = new ethers.JsonRpcProvider("https://eth.llamarpc.com");
const signer = new ethers.Wallet("0x...", provider);
const shares = new ethers.Contract(SHARES, abi, signer);

await (await shares.cancelSubscription(42n)).wait();

Events

Cancelling emits a SubscriptionCancellation or RedemptionCancellation event with the request id and the canceller's address.

Last updated