@parabolfi/core
Version:
Core utilities for Parabol SDK
193 lines • 8.4 kB
TypeScript
import { Address, PrivateKeyAccount } from "viem";
import { ParabolData, PartnerConfig } from "../types";
import { SupportedChainId } from "../config/global";
/**
* ParabolAccount class for managing blockchain account operations for the Parabol protocol.
*/
export declare class ParabolAccount {
account: PrivateKeyAccount;
chainId: SupportedChainId;
parabolData?: Readonly<ParabolData>;
partnerConfig?: Readonly<PartnerConfig>;
/**
* Creates a new ParabolAccount instance.
* @param {PrivateKeyAccount} account - The private key account.
* @param {SupportedChainId} chainId - The chain ID.
*/
constructor(account: PrivateKeyAccount, chainId: SupportedChainId);
/**
* Creates a ParabolAccount instance from a private key.
* @param {Object} params - The parameters for creating the account.
* @param {string} params.privateKey - The private key.
* @param {SupportedChainId} params.chainId - The chain ID.
* @param {ParabolData} [params.parabolData] - Optional Parabol data.
* @param {PartnerConfig} [params.partnerConfig] - Optional partner configuration.
* @returns {ParabolAccount} The ParabolAccount instance.
* @throws {ParabolSDKError} If the chain ID is not supported or if the private key is invalid.
*/
static fromPrivateKey({ privateKey, chainId, parabolData, partnerConfig, }: {
privateKey: string;
chainId: SupportedChainId;
parabolData?: ParabolData;
partnerConfig?: PartnerConfig;
}): ParabolAccount;
/**
* Initializes the ParabolAccount with required data.
* @param {Object} params - The initialization parameters.
* @param {ParabolData} [params.parabolData] - Optional Parabol data.
* @param {PartnerConfig} [params.partnerConfig] - Optional partner configuration.
* @returns {Promise<void>}
* @private
*/
private initialize;
/**
* Sets the partner configuration for the ParabolAccount.
* @param {PartnerConfig} partnerConfig - The partner configuration to set.
*/
setPartnerConfig(partnerConfig: PartnerConfig): void;
/**
* Sets the Parabol data for the ParabolAccount.
* @param {ParabolData} parabolData - The Parabol data to set.
*/
setParabolData(parabolData: ParabolData): void;
/**
* Sets the chain ID for the ParabolAccount.
* @param {SupportedChainId} chainId - The chain ID to set.
* @throws {ParabolSDKError} If the chain ID is not supported.
*/
setChainId(chainId: SupportedChainId): void;
/**
* Creates a partnership with the specified partner vault and fee BPS.
* @param {Address} partnerVault - The partner vault address.
* @param {bigint} partnerFeeBPS - The partner fee BPS (100 = 1%).
* @returns {Promise<string>} The transaction hash.
* @throws {ParabolSDKError} If the transaction fails.
*/
createPartnership(partnerVault: Address, partnerFeeBPS: bigint): Promise<string>;
/**
* Approves the specified spender to spend the specified amount of ParabolUSD.
* @param {Address} spender - The spender address.
* @param {string} value - The amount to approve (in ether).
* @returns {Promise<string>} The transaction hash.
* @throws {ParabolSDKError} If the transaction fails.
*/
approveParabolUSD(spender: Address, value: string): Promise<string>;
/**
* Approves a specific token ID to be managed by the given address.
* @param {Address} to - The address to approve.
* @param {string} tokenId - The token ID to approve.
* @returns {Promise<string>} The transaction hash.
* @throws {ParabolSDKError} If the transaction fails.
*/
approvePosition(to: Address, tokenId: string): Promise<string>;
/**
* Approves or revokes an operator to manage all of the caller's note positions.
* @param {string} operator - The operator address.
* @param {boolean} approved - Whether to approve or revoke the operator.
* @returns {Promise<string>} The transaction hash.
* @throws {ParabolSDKError} If the transaction fails.
*/
operatorApprovePosition(operator: string, approved: boolean): Promise<string>;
/**
* Performs a lending operation.
* @param {Object} params - The lending parameters.
* @param {string} params.principal - The principal amount to lend.
* @param {number} params.maturity - The maturity period.
* @returns {Promise<string>} The transaction hash.
* @throws {ParabolSDKError} If the transaction fails or if the input is invalid.
*/
lend({ principal, maturity, }: {
principal: string;
maturity: number;
}): Promise<string>;
/**
* Claims a note position.
* @param {Object} params - The claim parameters.
* @param {string} params.tokenId - The token ID to claim.
* @returns {Promise<string>} The transaction hash.
* @throws {ParabolSDKError} If the transaction fails.
*/
claim({ tokenId }: {
tokenId: string;
}): Promise<string>;
/**
* Gets the address of the ParabolAccount.
* @returns {Address} The account address.
*/
getAddress(): Address;
/**
* Gets the ParabolUSD allowance for a specific spender.
* @param {Address} spender - The spender address.
* @returns {Promise<bigint>} The allowance amount.
* @throws {ParabolSDKError} If the read operation fails.
*/
getParabolUSDAllowance(spender: Address): Promise<bigint>;
/**
* Checks if a specific address is approved for a note position.
* @param {Address} to - The address to check.
* @param {string} tokenId - The token ID to check.
* @returns {Promise<boolean>} Whether the address is approved.
* @throws {ParabolSDKError} If the read operation fails.
*/
getApprovedNotePosition(to: Address, tokenId: string): Promise<boolean>;
/**
* Checks if an operator is approved to manage all note positions.
* @param {Address} operator - The operator address to check.
* @returns {Promise<boolean>} Whether the operator is approved.
* @throws {ParabolSDKError} If the read operation fails.
*/
getOperatorApprovedNotePosition(operator: Address): Promise<boolean>;
/**
* Gets the partner info by partner ID.
* @param {string} partnerId - The partner ID.
* @returns {Promise<PartnerConfig>} The partner info.
* @throws {ParabolSDKError} If the read operation fails.
*/
getPartnerConfigById(partnerId: string): Promise<PartnerConfig>;
/**
* Gets the partner info by owner.
* @param {Address} owner - The owner address.
* @param {number} [decrementNonceBy=1] - The nonce decrement value.
* @returns {Promise<PartnerConfig>} The partner info.
* @throws {ParabolSDKError} If the read operation fails.
*/
getPartnerConfigByOwner(owner: Address, decrementNonceBy?: number): Promise<PartnerConfig>;
/**
* Gets the chain ID of the ParabolAccount.
* @returns {SupportedChainId} The chain ID.
*/
getChainId(): SupportedChainId;
/**
* Validates the Parabol data for a given maturity.
* @param {number} maturity - The maturity to validate.
* @throws {ParabolSDKError} If the Parabol data is invalid or unavailable.
* @private
*/
private validateParabolData;
/**
* Validates the lending input.
* @param {string} principal - The principal amount to validate.
* @throws {ParabolSDKError} If the principal is invalid or below the minimum lending limit.
* @private
*/
private validateLendInput;
/**
* Writes a transaction to the blockchain.
* @param {T} transactionType - The transaction type.
* @param {TransactionParams<T>} params - The transaction parameters.
* @returns {Promise<string>} The transaction hash.
* @throws {ParabolSDKError} If the transaction fails.
* @private
*/
private write;
/**
* Reads data from the blockchain.
* @param {T} transactionType - The transaction type.
* @param {TransactionParams<T>} params - The transaction parameters.
* @returns {Promise<`0x${string}`>} The read data as a hex string.
* @throws {ParabolSDKError} If the read operation fails.
* @private
*/
private read;
}
//# sourceMappingURL=ParabolAccount.d.ts.map