Approve Position

The ParabolAccount class provides two methods for approving note positions:

  • approvePosition: Approves a specific token ID to be managed by a given address.
  • operatorApprovePosition: Approves or revokes an operator to manage all of the caller’s note positions.
⚠️

Be careful when using the operatorApprovePosition method. It can approve or revoke an operator to manage ALL of the caller’s note positions.

Approve Position (approvePosition)

This method approves a specific address to manage a particular note position token.

Usage

import { ParabolAccount } from "@parabolfi/core";
 
const account = new ParabolAccount(Account, chainId);
 
const to = "0x..."; // Address to approve
const tokenId = "123"; // ID of the note position token
 
try {
  const txHash = await account.approvePosition(to, tokenId);
  console.log("Approval transaction hash:", txHash);
} catch (error) {
  console.error("Error approving position:", error);
}

Parameters

  • to: Address - The address to approve for managing the note position.
  • tokenId: string - The ID of the note position token to approve.

Operator Approve Position (operatorApprovePosition)

This method approves or revokes an operator to manage all of the caller’s note positions.

Usage

import { ParabolAccount } from "@parabolfi/core";
 
const account = new ParabolAccount(Account, chainId);
 
const to = "0x..."; // Address to approve
 
try {
  const txHash = await account.operatorApprovePosition(to, true); // true for approve, false for revoke
  console.log("Approval transaction hash:", txHash);
} catch (error) {
  console.error("Error approving position:", error);
}

Returns

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

Errors

Both methods throw a ParabolSDKError if the transaction fails. Always wrap the calls in try-catch blocks to handle potential errors.