@parabolfi/server
Version:
Server utilities for Parabol SDK
191 lines • 10 kB
TypeScript
import { GraphQueryType, QueryExecutionResult, ChainSpecificResult, FloatingIncome, PARABOL_ENV, ExtendedRawPositionInfo, RawNoteDataType, SupportedChainId } from "@parabolfi/core";
import { Address } from "viem";
/**
* ParabolServer class for interacting with the Parabol API
*/
export declare class ParabolServer {
private apiKey;
private endpoint;
private env;
private logger;
/**
* Creates an instance of ParabolServer.
* @param {Object} options - Configuration options
* @param {string} [options.apiKey] - The API key for authentication
* @param {PARABOL_ENV} [options.env] - The environment to use
* @param {function} [options.logger] - Custom logger function
* @throws {Error} If API key is not provided
*/
constructor(options?: {
apiKey?: string;
env?: PARABOL_ENV;
logger?: (message: string, level: "info" | "error") => void;
});
/**
* Fetches Parabol data for a specific chain and maturity
* @param {SupportedChainId} [chain] - The chain ID
* @param {number[]} [maturity] - Array of maturity periods
* @returns {Promise<Object>} Parabol data including notes, maturities, and rates
* @throws {ParabolSDKError} If there's an error fetching the data
*/
fetchParabolData(options?: {
chain?: SupportedChainId;
maturity?: number[];
}): Promise<{
data: Array<RawNoteDataType>;
availableMaturities: Array<number>;
marketRate: string;
floatingRate: string;
}>;
/**
* Fetches Parabol configuration for specified chains
* @param {SupportedChainId[]} chains - Array of chain IDs
* @returns {Promise<QueryExecutionResult>} Parabol configuration data
* @throws {ParabolSDKError} If there's an error fetching the configuration
*/
fetchParabolConfig(chains: SupportedChainId[]): Promise<QueryExecutionResult<typeof GraphQueryType.FETCH_PARABOL_CONFIG>>;
/**
* Fetches minimum lend limit for a specific chain
* @param {SupportedChainId} chain - The chain ID
* @returns {Promise<QueryExecutionResult>} Minimum lend limit data
* @throws {ParabolSDKError} If there's an error fetching the minimum lend limit
*/
fetchMinLendLimit(chain: SupportedChainId): Promise<QueryExecutionResult<typeof GraphQueryType.FETCH_MIN_LEND_LIMIT>>;
/**
* Fetches lending parameters for a specific chain
* @param {SupportedChainId} chain - The chain ID
* @returns {Promise<Object>} Lending parameters including minimum lend limit and available maturities
* @throws {ParabolSDKError} If there's an error fetching the parameters
*/
fetchLendParameters(chain: number): Promise<{
minLendLimit: string;
data: Array<RawNoteDataType>;
availableMaturities: Array<number>;
}>;
/**
* Fetches all positions for a given wallet address across specified chains
* @param {Address} walletAddress - Wallet address to fetch positions for
* @param {SupportedChainId[]} chains - Array of chain IDs
* @param {Array<FloatingIncome>} [inputFloatingIncomes] - Optional array of floating incomes
* @returns {Promise<ChainSpecificResult>} Chain-specific position data
* @throws {ParabolSDKError} If there's an error fetching the positions
*/
fetchAllPositions(walletAddress: Address, chains: SupportedChainId[], inputFloatingIncomes?: Array<FloatingIncome>): Promise<ChainSpecificResult<{
positions: Array<ExtendedRawPositionInfo>;
active: Array<ExtendedRawPositionInfo>;
claimed: Array<ExtendedRawPositionInfo>;
totalLoaned: string;
totalEarned_fixed: string;
totalEarned_bonus: string;
}>>;
/**
* Fetches lend transactions for a given wallet address across specified chains
* @param {Address} walletAddress - Wallet address to fetch transactions for
* @param {SupportedChainId[]} chains - Array of chain IDs
* @returns {Promise<QueryExecutionResult>} Lend transaction data
* @throws {ParabolSDKError} If there's an error fetching the transactions
*/
fetchLendTransactions(walletAddress: Address, chains: SupportedChainId[]): Promise<QueryExecutionResult<typeof GraphQueryType.FETCH_LEND_TRANSACTIONS>>;
/**
* Fetches claimed positions for a given wallet address across specified chains
* @param {Address} walletAddress - Wallet address to fetch claimed positions for
* @param {SupportedChainId[]} chains - Array of chain IDs
* @returns {Promise<QueryExecutionResult>} Claimed position data
* @throws {ParabolSDKError} If there's an error fetching the claimed positions
*/
fetchClaimedPositions(walletAddress: Address, chains: SupportedChainId[]): Promise<QueryExecutionResult<typeof GraphQueryType.FETCH_CLAIMED_POSITIONS>>;
/**
* Fetches position transfers for a given wallet address across specified chains
* @param {Address} walletAddress - Wallet address to fetch position transfers for
* @param {SupportedChainId[]} chains - Array of chain IDs
* @returns {Promise<QueryExecutionResult>} Position transfer data
* @throws {ParabolSDKError} If there's an error fetching the position transfers
*/
fetchPositionTransfers(walletAddress: Address, chains: SupportedChainId[]): Promise<QueryExecutionResult<typeof GraphQueryType.FETCH_POSITION_TRANSFERS>>;
/**
* Fetches partner info for a given wallet address
* @param {Address} walletAddress - Wallet address to fetch partner info for
* @param {SupportedChainId[]} chains - Array of chain IDs
* @returns {Promise<QueryExecutionResult>} Partner info data
* @throws {ParabolSDKError} If there's an error fetching the partner info
*/
fetchPartnerConfig(walletAddress: Address, chains: SupportedChainId[]): Promise<QueryExecutionResult<typeof GraphQueryType.FETCH_PARTNER_CONFIG>>;
/**
* Fetches ParabolUSD balance for a given wallet address
* @param {Address} walletAddress - Wallet address to fetch balance for
* @param {SupportedChainId[]} chains - Array of chain IDs
* @returns {Promise<QueryExecutionResult>} ParabolUSD balance data
* @throws {ParabolSDKError} If there's an error fetching the balance
*/
fetchParabolUSDBalance(walletAddress: Address, chains: SupportedChainId[]): Promise<QueryExecutionResult<typeof GraphQueryType.FETCH_BALANCE>>;
/**
* Fetches ParabolUSD nonce for a given wallet address
* @param {Address} walletAddress - Wallet address to fetch nonce for
* @param {SupportedChainId[]} chains - Array of chain IDs
* @returns {Promise<QueryExecutionResult>} ParabolUSD nonce data
* @throws {ParabolSDKError} If there's an error fetching the nonce
*/
fetchParabolUSDNonce(walletAddress: Address, chains: SupportedChainId[]): Promise<QueryExecutionResult<typeof GraphQueryType.FETCH_PARABOL_USD_NONCE>>;
/**
* Fetches non-fungible note position nonce for a given wallet address
* @param {Address} walletAddress - Wallet address to fetch nonce for
* @param {SupportedChainId[]} chains - Array of chain IDs
* @returns {Promise<QueryExecutionResult>} Non-fungible note position nonce data
* @throws {ParabolSDKError} If there's an error fetching the nonce
*/
fetchNonFungibleNotePositionNonce(walletAddress: Address, chains: SupportedChainId[]): Promise<QueryExecutionResult<typeof GraphQueryType.FETCH_NONFUNGIBLE_NOTE_POSITION_NONCE>>;
/**
* Fetches ParabolUSD allowance for a given owner and spender
* @param {Address} owner - Owner address
* @param {Address} spender - Spender address
* @param {SupportedChainId[]} chains - Array of chain IDs
* @returns {Promise<QueryExecutionResult>} ParabolUSD allowance data
* @throws {ParabolSDKError} If there's an error fetching the allowance
*/
fetchParabolUSDAllowance(owner: Address, spender: Address, chains: SupportedChainId[]): Promise<QueryExecutionResult<typeof GraphQueryType.FETCH_PARABOL_USD_ALLOWANCE>>;
/**
* Fetches position allowance for a given owner and token ID
* @param {Address} owner - Owner address
* @param {number} tokenId - Token ID
* @param {SupportedChainId} chain - Chain ID
* @returns {Promise<QueryExecutionResult>} Position allowance data
* @throws {ParabolSDKError} If there's an error fetching the allowance
*/
fetchPositionAllowance(owner: Address, tokenId: number, chain: SupportedChainId): Promise<QueryExecutionResult<typeof GraphQueryType.FETCH_POSITION_ALLOWANCE>>;
/**
* Fetches floating incomes for specified chains
* @returns {Promise<QueryExecutionResult>} Floating income data
* @throws {ParabolSDKError} If there's an error fetching the floating incomes
*/
fetchFloatingIncomes(chain?: SupportedChainId): Promise<QueryExecutionResult<typeof GraphQueryType.FETCH_FLOATING_INCOMES>>;
/**
* Executes a Parabol Subgraph query
* @param {GraphQueryType} type - Type of the GraphQL query
* @param {GraphQueryVariables} variables - Variables for the GraphQL query
* @returns {Promise<QueryExecutionResult>} Query execution result
* @throws {ParabolSDKError} If there's an error executing the query
* @private
*/
private executeQuery;
/**
* Validates the variables for a GraphQL query
* @param {GraphQueryVariables} variables - Variables to validate
* @throws {ParabolSDKError} If the variables are invalid
* @private
*/
private validateVariables;
/**
* Returns the default chain based on the environment
* @returns {SupportedChainId} Default chain ID
* @private
*/
private getDefaultChain;
/**
* Gets the API endpoint based on the environment
* @param {PARABOL_ENV} env - The environment
* @returns {string} The API endpoint
* @private
*/
private getEndpoint;
}
//# sourceMappingURL=ParabolServer.d.ts.map