Claim

The claim method allows you to claim a note position in the Parabol protocol. This operation is typically performed when a lending position has matured and you want to retrieve your principal plus any earned interest.

Usage

import { ParabolAccount, SupportedChainIds } from "@parabolfi/core";
 
async function claimNotePosition() {
  const privateKey = "0x..."; // Your private key
  const chainId = SupportedChainIds.ZKSYNC;
 
  const account = await ParabolAccount.fromPrivateKey({
    privateKey,
    chainId,
  });
 
  try {
    const txHash = await account.claim({ tokenId: "26" });
    console.log("Claim transaction hash:", txHash);
  } catch (error) {
    console.error("Error claiming note position:", error);
  }
}

Parameters

The claim method takes an object with the following property:

  • tokenId: string - The ID of the note position token to claim.

Returns

  • Hex - A promise that resolves to the transaction hash of the claim transaction.

Important Notes

Before claiming, the method checks if the Reserve Stability Pool (RSP) contract is approved to manage the note position. If the RSP is not approved, the method will automatically call approveNotePosition before proceeding with the claim. The account must be the owner of the note position being claimed.

Errors

This method may throw a ParabolSDKError in the following cases:

  • If the note position approval fails.
  • If the claim transaction fails for any reason (e.g., the position is not mature, network issues).

Always wrap the call in a try-catch block to handle potential errors.

  • approveNotePosition: Used internally to approve the RSP contract if necessary.
  • getApprovedNotePosition: Checks if a specific address is approved for a note position.
  • getOperatorApprovedNotePosition: Checks if an operator is approved to manage all note positions.