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

Emergency Exit

Check activation and redeem tokens after the Factory Owner completes Emergency Exit.

Check redemption availability

Only the Factory Owner can trigger Emergency Exit, after a launch remains swept for seven days from sweptAt. The delay alone does not activate redemption. Offer redemption only after the launch reaches emergencyExited and its Distributor is deployed and activated.

const graduation = await client.getGraduation(token);
if (graduation.status !== "emergencyExited") {
  throw new Error("Emergency Exit has not completed");
}

Approve and redeem

After Exit completes, confirm the Distributor state below. Set tokenIn to a positive raw token amount. The holder approves the launch token to the Distributor, then previews and submits the redemption.

const { distributor, deployed } = await client.getEmergencyDistributor({
  launchToken: token,
  quoteToken,
});
if (!deployed) throw new Error("Emergency Exit has not completed");
const exitState = await client.getEmergencyExitState(distributor);
if (!exitState.activated) throw new Error("Redemption is not active");

const approval = await client.prepareApprove({
  asset: token,
  spender: distributor,
  amount: tokenIn,
});
const approvalHash = await client.send(approval);
const approved = await client.wait(approvalHash, { confirmations: chain.confirmations });
if (approved.status !== "confirmed") throw new Error("Approval reverted");

const redemption = await client.prepareEmergencyRedeem({ distributor, tokenIn });
// Show redemption.preview.quoteOut before the user confirms.
const redemptionHash = await client.send(redemption);
const result = await client.wait(redemptionHash, { confirmations: chain.confirmations });
if (result.status !== "confirmed") throw new Error("Redemption reverted");

Understand the payout

Redemption uses the current totalSupply(). Burns without redemption increase the payout per remaining token; the final redeemer receives the remainder. Refresh the quote immediately before submission.

Redemption burns the submitted tokens. The contract has no minimum-output parameter; the preview is an estimate. Refresh the quote before signing and display the confirmed payout.

Last updated

Was this helpful?