@symmetry-hq/liquidity-sdk
Version:
Exchange functionality using symmetry funds liquidity
42 lines (41 loc) • 2.02 kB
TypeScript
/// <reference types="node" />
import { Wallet } from "@coral-xyz/anchor/dist/cjs/provider";
import { AccountInfo, Connection, GetProgramAccountsResponse, PublicKey, TransactionInstruction } from "@solana/web3.js";
import { RouteData } from "./types";
export * from "./types";
export declare class TokenSwap {
private connection;
private program;
private tokenListData;
private curveChainData;
private funds;
private oraclePrices;
private wallet?;
constructor(accountInfos: {
tokenListAccountInfo: AccountInfo<Buffer>;
curveDataAccountInfo: AccountInfo<Buffer>;
oracleDataAccountInfos: Array<AccountInfo<Buffer>>;
fundStateAccountInfos: GetProgramAccountsResponse;
}, connection: Connection, wallet?: Wallet);
static getAccountInfosForTokenSwap(connection: Connection): Promise<{
tokenListAccountInfo: AccountInfo<Buffer>;
curveDataAccountInfo: AccountInfo<Buffer>;
oracleDataAccountInfos: Array<AccountInfo<Buffer>>;
fundStateAccountInfos: GetProgramAccountsResponse;
}>;
static init(connection: Connection, wallet?: Wallet): Promise<TokenSwap>;
setWallet(wallet: Wallet): void;
getTokenList(): {
tokenId: number;
coingeckoId: string;
tokenMint: string;
}[];
getAccountsForUpdate(): PublicKey[];
update(accountInfos: AccountInfo<Buffer>[]): void;
updateLiquiditySources(): Promise<void>;
findTokenId(tokenMint: PublicKey): number | undefined;
getRouteData(tokenFrom: PublicKey, tokenTo: PublicKey, fromAmount: number): RouteData;
getAllRoutes(tokenFrom: PublicKey, tokenTo: PublicKey, fromAmount: number): RouteData[];
executeSwap(routeData: RouteData, fromTokenAccount?: PublicKey, toTokenAccount?: PublicKey, slippage?: number): Promise<TransactionInstruction>;
generateSwapInstruction(routeData: RouteData, fromTokenAccount: PublicKey, toTokenAccount: PublicKey, user?: PublicKey, slippage?: number): Promise<TransactionInstruction>;
}