UNPKG

@mean-dao/ddca

Version:

Typescript library to interact with the Decentralized DCA program

45 lines (44 loc) 2.07 kB
import { PublicKey, Connection, Transaction } from '@solana/web3.js'; import * as anchor from "@project-serum/anchor"; import { DdcaAccount, DdcaActivity, DdcaDetails, HlaInfo } from '.'; import { ProgramError } from '@project-serum/anchor'; /** * Anchor based client for the DDCA program */ export declare class DdcaClient { private rpcUrl; connection: Connection; provider: anchor.Provider; program: anchor.Program; private ownerAccountAddress; private verbose; private rpcVersion; private tempoApiUrl; /** * Create a DDCA client */ constructor(rpcUrl: string, anchorWallet: any, confirmOptions?: anchor.web3.ConfirmOptions, verbose?: boolean, tempoApiUrl?: string); private getAnchorProvider; private createWrapSolInstructions; createDdcaTx(fromMint: PublicKey, toMint: PublicKey, amountPerSwap: number, swapsCount: number, intervalInSeconds: number, wrapSolIfNeeded?: boolean): Promise<[PublicKey, Transaction]>; createWakeAndSwapTx(ddcaAccountAddress: PublicKey, hlaInfo: HlaInfo): Promise<Transaction>; createAddFundsTx(ddcaAccountAddress: PublicKey, swapsCount: number, wrapSolIfNeeded?: boolean): Promise<Transaction>; createWithdrawTx(ddcaAccountAddress: PublicKey, withdrawAmount: number): Promise<Transaction>; createCloseTx(ddcaAccountAddress: PublicKey): Promise<Transaction>; updateCloseTx(ddcaAccountAddress: PublicKey, closeTxSignedByOwner: Transaction): Promise<Transaction>; listDdcas(stortByStartTs?: boolean, desc?: boolean): Promise<Array<DdcaAccount>>; getDdca(ddcaAccountAddress: PublicKey): Promise<DdcaDetails | null>; /** * ToString */ toString(): string; /** * Attempts to parse an rpc error. Experimental */ tryParseRpcError(rawError: any): ProgramError | null; private getRpcVersion; getActivity(ddcaAccountAddress: PublicKey | string, limit?: number, includeFailed?: boolean): Promise<DdcaActivity[]>; private parseTransaction; private CreateCrankAddress; private sendCloseTxUpdateRequest; }