@orca-so/whirlpool-sdk
Version:
Whirlpool SDK for the Orca protocol.
62 lines (61 loc) • 2.58 kB
TypeScript
import { Address } from "@project-serum/anchor";
import { Connection } from "@solana/web3.js";
import Decimal from "decimal.js";
import { OrcaNetwork } from "../constants/public/network";
import { PoolData } from "../types";
import { OrcaDAL } from "../dal/orca-dal";
import { OrcaPool } from "../pool/orca-pool";
import { OrcaPosition } from "../position/orca-position";
import { TokenUSDPrices } from "../utils/token-price";
import { UserPositionData } from "../types";
import { OrcaZooplankton } from "../offchain/orca-zp";
import { OrcaAdmin } from "../admin/public";
export declare type OrcaWhirlpoolClientConfig = {
network?: OrcaNetwork;
connection?: Connection;
whirlpoolConfig?: Address;
programId?: Address;
offchainDataURI?: string;
};
export declare class OrcaWhirlpoolClient {
readonly data: OrcaDAL;
readonly admin: OrcaAdmin;
readonly pool: OrcaPool;
readonly position: OrcaPosition;
readonly offchain: OrcaZooplankton;
constructor(config?: OrcaWhirlpoolClientConfig);
/**
* Use on-chain dex data to derive usd prices for tokens.
*
* @param poolAddresses pools to be used for price discovery
* @param baseTokenMint a token mint with known stable usd price (e.g. USDC)
* @param baseTokenUSDPrice baseTokenMint's usd price. defaults to 1, assuming `baseTokenMint` is a USD stable coin
* @param otherBaseTokenMints optional list of token mints to prioritize as base
* @param refresh defaults to refreshing the cache
*/
getTokenPrices(poolAddresses: Address[], baseTokenMint: Address, baseTokenUSDPrice?: Decimal, otherBaseTokenMints?: Address[], refresh?: boolean): Promise<TokenUSDPrices>;
/**
* Fetch position data owned by the wallet address.
*
* @param walletAddress wallet address
* @param refresh defaults to refreshing the cache
* @returns positions owned by the wallet address
*/
getUserPositions(walletAddress: Address, refresh?: boolean): Promise<Record<string, UserPositionData>>;
/**
* Fetch list of pool data.
*
* @param poolAddresses list of pools to retrieve
* @param refresh defaults to refreshing the cache
* @returns list of pool data
*/
getPools(poolAddresses: Address[], refresh?: boolean): Promise<Record<string, PoolData>>;
/**
* Fetch pool data.
*
* @param poolAddress pool address
* @param refresh defaults to refreshing the cache
* @returns pool data
*/
getPool(poolAddress: Address, refresh?: boolean): Promise<PoolData | null>;
}