@parabolfi/core
Version:
Core utilities for Parabol SDK
247 lines • 9.68 kB
TypeScript
import { ParabolData, PartnerConfig, RawNoteDataType } from "../types";
import { Address, Hex } from "viem";
import type { SupportedChainId } from "../config/global";
/**
* Service class for handling Parabol calldata operations.
* This class follows the singleton pattern and should be accessed using getInstance().
*/
export declare class ParabolCalldata {
private static instance;
private parabolData?;
private partnerConfig?;
private constructor();
/**
* Gets the singleton instance of ParabolCalldata.
* @returns {ParabolCalldata} The singleton instance.
*/
static getInstance(): ParabolCalldata;
/**
* Initializes the ParabolCalldata with required data.
* @param {ParabolData} parabolData - The Parabol data.
* @param {PartnerConfig} [partnerConfig] - The partner configuration.
* @throws {ParabolSDKError} If any required data is missing.
*/
initialize(parabolData: ParabolData, partnerConfig?: PartnerConfig): void;
/**
* Sets the partner configuration.
* @param {PartnerConfig} partnerConfig - The partner configuration to set.
* @throws {ParabolSDKError} If the provided configuration is invalid.
*/
setPartnerConfig(partnerConfig: PartnerConfig): void;
/**
* Gets the calldata for approving ParabolUSD.
* @param {SupportedChainId} chainId - The chain ID.
* @param {bigint} value - The value to approve.
* @returns {string} The approval calldata.
*/
getApproveParabolUSDCalldata(chainId: SupportedChainId, value: string): string;
/**
* Gets the calldata for approving a Position token transfer.
* @param {SupportedChainId} chainId - The chain ID.
* @param {string} tokenId - The token ID.
* @returns {string} The approval calldata.
*/
getApprovePositionCalldata(chainId: SupportedChainId, tokenId: string): string;
/**
* Gets the calldata for approving the position operator.
* @param {SupportedChainId} chainId - The chain ID.
* @returns {string} The approval calldata.
*/
getApprovePositionOperatorCalldata(chainId: SupportedChainId): string;
/**
* Gets the calldata for lending.
* @param {Object} params - The parameters object.
* @param {Address} params.walletAddress - The wallet address.
* @param {number} params.maturity - The lending duration (maturity).
* @param {string} params.principal - The principal amount.
* @returns {Promise<string>} A promise that resolves to the lending calldata.
* @throws {ParabolSDKError} If the service is not initialized.
*/
getLendCalldata({ walletAddress, maturity, principal, }: {
walletAddress: Address;
maturity: number;
principal: string;
}): string;
/**
* Gets the calldata for claiming.
* @param {Object} params - The parameters object.
* @param {Address} params.walletAddress - The wallet address.
* @param {bigint} params.tokenId - The token ID.
* @returns {string} The claiming calldata.
*/
getClaimCalldata({ walletAddress, tokenId, }: {
walletAddress: Address;
tokenId: bigint;
}): string;
/**
* Gets the calldata for permit lending.
* @param {Object} params - The parameters object.
* @param {Address} params.walletAddress - The wallet address.
* @param {number} params.maturity - The lending duration.
* @param {string} params.principal - The principal amount.
* @param {ParabolLegacySignature} params.permitSignature - The permit signature.
* @param {bigint} params.deadline - The deadline for the permit.
* @returns {string} The permit lending calldata.
* @throws {ParabolSDKError} If the service is not initialized.
*/
getPermitLendCalldata({ walletAddress, maturity, principal, permitSignature, deadline, }: {
walletAddress: Address;
maturity: number;
principal: string;
permitSignature: Hex;
deadline: bigint;
}): string;
/**
* Gets the calldata for permit claiming.
* @param {Object} params - The parameters object.
* @param {Address} params.walletAddress - The wallet address.
* @param {bigint} params.tokenId - The token ID.
* @param {ParabolLegacySignature} params.permitSignature - The permit signature.
* @param {bigint} params.deadline - The deadline for the permit.
* @returns {string} The permit claiming calldata.
*/
getPermitClaimCalldata({ walletAddress, tokenId, permitSignature, deadline, }: {
walletAddress: Address;
tokenId: bigint;
permitSignature: Hex;
deadline: bigint;
}): string;
/**
* Gets the parameters for preparing a permit lend signature.
* @param {Object} params - The parameters object.
* @param {Address} params.walletAddress - The wallet address.
* @param {SupportedChainId} params.chainId - The chain ID.
* @param {string} params.principal - The principal amount.
* @param {bigint} params.nonce - The nonce (ParabolUSD ERC-20 Contract Nonce).
* @param {string} params.ParabolUSDName - The ParabolUSD name.
* @param {string} params.ParabolUSDVersion - The ParabolUSD version.
* @returns {ReturnType<typeof preparePermitLendSignature>} The prepared permit lend signature parameters.
*/
getPermitLendSignatureParams(params: {
walletAddress: Address;
chainId: SupportedChainId;
principal: string;
nonce: bigint;
ParabolUSDName: string;
ParabolUSDVersion: string;
}): {
domain: import("viem").TypedDataDomain;
types: {
readonly Permit: readonly [{
readonly name: "owner";
readonly type: "address";
}, {
readonly name: "spender";
readonly type: "address";
}, {
readonly name: "value";
readonly type: "uint256";
}, {
readonly name: "nonce";
readonly type: "uint256";
}, {
readonly name: "deadline";
readonly type: "uint256";
}];
};
data: {
owner: `0x${string}`;
spender: `0x${string}`;
value: bigint;
nonce: bigint;
deadline: bigint;
};
deadline: bigint;
};
/**
* Gets the parameters for preparing a permit claim signature.
* @param {Object} params - The parameters object.
* @param {SupportedChainId} params.chainId - The chain ID.
* @param {bigint} params.tokenId - The token ID.
* @param {bigint} params.nonce - The nonce (NonFungibleNotePosition Contract Nonce).
* @param {string} params.NonFungibleNotePositionName - The NonFungibleNotePosition name.
* @param {string} params.NonFungibleNotePositionVersion - The NonFungibleNotePosition version.
* @returns {ReturnType<typeof preparePermitClaimSignature>} The prepared permit claim signature parameters.
*/
getPermitClaimSignatureParams(params: {
chainId: SupportedChainId;
tokenId: bigint;
nonce: bigint;
NonFungibleNotePositionName: string;
NonFungibleNotePositionVersion: string;
}): {
domain: import("viem").TypedDataDomain;
types: {
readonly Permit: readonly [{
readonly name: "spender";
readonly type: "address";
}, {
readonly name: "tokenId";
readonly type: "uint256";
}, {
readonly name: "nonce";
readonly type: "uint256";
}, {
readonly name: "deadline";
readonly type: "uint256";
}];
};
data: {
spender: `0x${string}`;
tokenId: bigint;
nonce: bigint;
deadline: bigint;
};
deadline: bigint;
};
/**
* Gets the note data.
* @returns {Array<RawNoteDataType>} The note data.
* @throws {ParabolSDKError} If the service is not initialized.
*/
getNoteData(): Array<RawNoteDataType>;
/**
* Gets the partner configuration.
* @returns {PartnerConfig | undefined} The partner configuration.
*/
getPartnerConfig(): PartnerConfig | undefined;
/**
* Validates that the service is initialized.
* @private
* @throws {ParabolSDKError} If the service is not initialized.
*/
private validateParabolData;
/**
* Validates the Parabol data for a given maturity.
* @private
* @param {number} maturity - The maturity to validate.
* @throws {ParabolSDKError} If the maturity is invalid or not available.
*/
private validateMaturity;
/**
* Validates the lending input.
* @private
* @param {string} principal - The principal amount to validate.
* @throws {ParabolSDKError} If the principal is invalid or below the minimum lending limit.
*/
private validateLendInput;
/**
* Validates an Ethereum address.
* @private
* @param {Address} address - The address to validate.
* @throws {ParabolSDKError} If the address is invalid.
*/
private validateAddress;
/**
* Validates a token ID.
* @private
* @param {bigint} tokenId - The token ID to validate.
* @throws {ParabolSDKError} If the token ID is invalid (less than or equal to 0).
*/
private validateTokenId;
/**
* Resets the singleton instance.
*/
static reset(): void;
}
//# sourceMappingURL=ParabolCalldata.d.ts.map