@dojima-wallet/connection
Version:
Initialise and connection for layer 1&2 blockchain
45 lines (44 loc) • 2.31 kB
TypeScript
import { ChainClientParams, Network } from "../client";
import { SwapAssetList } from "@dojima-wallet/utils";
import * as ethers from "ethers";
import Web3 from "web3";
import { EthTransferParams, EthTxData, EthTxHistoryParams, EthTxs, GasfeeResult } from "./eth-types";
import { PoolData, SwapFeeResult } from "../swap_utils";
export type EthRpcParams = {
privateKey: string;
rpcUrl: string;
etherscanKey?: string;
};
declare class EthereumClient {
protected network: Network;
protected web3: Web3;
protected rpcUrl: string;
protected account: ethers.ethers.Wallet;
protected provider: ethers.ethers.providers.JsonRpcProvider;
private phrase;
protected api: string;
private etherscanApiKey;
private privateKey;
constructor({ phrase, privateKey, network, rpcUrl, etherscanKey, }: ChainClientParams & EthRpcParams);
getAddress(): string;
getBalance(address: string): Promise<number>;
calculateDojFee(baseGasFee: number, multiplier: number): number;
estimateGasFee(amount: number, memo?: string): Promise<number>;
getFees(amount: number, memo?: string): Promise<GasfeeResult>;
estimateGasLimit(tx: ethers.providers.TransactionRequest): Promise<ethers.BigNumber>;
getCurrentGasPrice(): Promise<ethers.BigNumber>;
transfer(params: EthTransferParams): Promise<string>;
dummyTx(recipient: string, amount: number): Promise<string>;
getTransactionData(hash: string): Promise<EthTxData>;
getTransactionsHistory(params: EthTxHistoryParams): Promise<EthTxs>;
getSwapOutput(inputAmount: number, pool: PoolData, toDoj: boolean): number;
getDoubleSwapOutput(inputAmount: number, pool1: PoolData, pool2: PoolData): number;
getSwapSlip(inputAmount: number, pool: PoolData, toDoj: boolean): number;
getDoubleSwapSlip(inputAmount: number, pool1: PoolData, pool2: PoolData): number;
getSwapFeesData(): Promise<SwapFeeResult>;
getEthereumInboundAddress(hermesApiUrl: string): Promise<string>;
getDefaultLiquidityPoolGasFee(hermesApiUrl: string): Promise<number>;
addLiquidityPool(amount: number, inboundAddress: string, hermesAddress?: string): Promise<string>;
swap(amount: number, token: SwapAssetList, inboundAddress: string, recipient: string): Promise<string>;
}
export { EthereumClient };