UNPKG

@broxus/js-core

Version:

MobX-based JavaScript Core library

82 lines (81 loc) 4.72 kB
import { type Address, type ProviderRpcClient, type SendInternalParams, type Subscriber, type Transaction } from 'everscale-inpage-provider'; import { SmartContractModel } from '../../core'; import { type Dex, type DexDeployPairCallbacks } from '../../models/dex'; import { type DexPairFeeParams, type DexPairFullDetails, DexPairUtils } from '../../models/dex-pair/DexPairUtils'; import { type DexPairOperationCancelled, type DexPairWithdrawSuccess } from '../../models/dex-pair/types'; import { type CallId, type Forceable, type SendMessageCallback, type Silentable, type Syncable, type TransactionCallbacks, type TransactionFailureReason, type TransactionSentDetails, type TransactionSuccessResult, type Watchable } from '../../types'; export interface DexPairWithdrawLiquidityCallbacks extends SendMessageCallback, TransactionCallbacks<TransactionSuccessResult<DexPairWithdrawSuccess>, TransactionFailureReason<DexPairOperationCancelled>, TransactionSentDetails> { } export interface DexPairWithdrawParams extends Partial<CallId>, DexPairWithdrawLiquidityCallbacks { amount: string | number; deployWalletGrams?: string | number; notify?: boolean; ownerAddress: Address | string; ownerLpWalletAddress?: Address | string; payload?: string; remainingGasTo?: Address | string; } export interface DexPairDeployParams extends Partial<CallId>, DexDeployPairCallbacks { sendGasTo: Address | string; } export interface DexPairCtorOptions { watchDebounceDelay?: number; } export type DexPairCreateConfig = { address: Address | string; dex: Dex; } | { dex: Dex; leftRootAddress: Address | string; rightRootAddress: Address | string; }; export interface DexPairCreateOptions extends DexPairCtorOptions, Syncable, Watchable { watchCallback?: VoidFunction; } export interface DexPairData extends DexPairFullDetails { dexRootAddress: Address; dexVaultAddress: Address; feeParams: DexPairFeeParams; } export declare class DexPair extends SmartContractModel<DexPairData> { protected readonly _connection: ProviderRpcClient; protected readonly dex: Dex; protected readonly options?: Readonly<DexPairCtorOptions> | undefined; protected readonly _provider?: ProviderRpcClient | undefined; static Utils: typeof DexPairUtils; /** * @param {ProviderRpcClient} _connection Standalone RPC client that doesn't require connection to the TVM wallet provider * @param {Address | string} address DexPair root address * @param {Dex} dex Dex Smart Contract Model instance * @param {Readonly<DexPairCtorOptions>} [options] (optional) DexPair Smart Contract Model options * @param {ProviderRpcClient} [_provider] (optional) RPC provider that require connection to the TVM wallet */ constructor(_connection: ProviderRpcClient, address: Address | string, dex: Dex, options?: Readonly<DexPairCtorOptions> | undefined, _provider?: ProviderRpcClient | undefined); /** * @param {ProviderRpcClient} connection Standalone RPC client that doesn't require connection to the TVM wallet provider * @param {Readonly<DexPairCreateConfig>} config DexPair Smart Contract Model config * @param {Readonly<DexPairCtorOptions>} [options] (optional) DexPair Smart Contract Model options * @param {ProviderRpcClient} [provider] (optional) RPC provider that require connection to the TVM wallet */ static create(connection: ProviderRpcClient, config: DexPairCreateConfig, options?: Readonly<DexPairCreateOptions>, provider?: ProviderRpcClient): Promise<DexPair>; sync(options?: Forceable & Silentable): Promise<void>; watch(callback?: VoidFunction): Promise<Subscriber>; unwatch(): Promise<void>; check(options?: Forceable): Promise<boolean>; syncBalances(options?: Forceable): Promise<Map<string, string>>; deployPair(params: DexPairDeployParams, args?: Partial<SendInternalParams>): Promise<Transaction | undefined>; withdrawLiquidity(params: DexPairWithdrawParams, args?: Partial<SendInternalParams>): Promise<Transaction | undefined>; get balances(): DexPairData['balances']; get dexRootAddress(): DexPairData['dexRootAddress']; get dexVaultAddress(): DexPairData['dexVaultAddress']; get feeParams(): DexPairData['feeParams']; get isActive(): DexPairData['isActive']; get leftToken(): DexPairData['tokens'][number]; get leftTokenWallet(): DexPairData['wallets'][number]; get lpToken(): DexPairData['lpToken']; get lpWallet(): DexPairData['lpWallet']; get rightToken(): DexPairData['tokens'][number]; get rightTokenWallet(): DexPairData['wallets'][number]; get tokens(): DexPairData['tokens']; get type(): DexPairData['type']; }