@broxus/js-core
Version:
MobX-based JavaScript Core library
112 lines (111 loc) • 6.13 kB
TypeScript
import { type Address, type DecodeEventParams, type DecodeTransactionParams, type ProviderRpcClient, type SendInternalParams, type Subscriber, type Transaction } from 'everscale-inpage-provider';
import { type SmartContractWatchCallback, SmartContractModel } from '../../core';
import { type Dex } from '../../models/dex';
import { type DexAccountAbi } from '../../models/dex-account/abi';
import { DexAccountUtils } from '../../models/dex-account/DexAccountUtils';
import { type DexAccountAddPairParams, type DexAccountAddPoolParams, type DexAccountDecodedEvent, type DexAccountDecodedTransaction, type DexAccountDepositLiquidityParams, type DexAccountDepositLiquidityV2Params, type DexAccountDepositTokenParams, type DexAccountWithdrawTokenParams } from '../../models/dex-account/types';
import { type Forceable, type Silentable, type Syncable, type Watchable } from '../../types';
export interface DexAccountCtorOptions {
watchDebounceDelay?: number;
}
export interface DexAccountCreateOptions extends DexAccountCtorOptions, Syncable, Watchable {
watchCallback?: VoidFunction;
}
export type DexAccountCreateConfig = {
address: Address | string;
dex: Dex;
} | {
dex: Dex;
ownerAddress: Address | string;
};
export interface DexAccountData {
balances?: Map<string, string>;
ownerAddress: Address;
wallets?: Map<string, Address>;
}
export declare class DexAccount extends SmartContractModel<DexAccountData> {
protected readonly _connection: ProviderRpcClient;
protected readonly dex: Dex;
protected readonly options?: Readonly<DexAccountCtorOptions> | undefined;
protected readonly _provider?: ProviderRpcClient | undefined;
static Utils: typeof DexAccountUtils;
/**
* @param {ProviderRpcClient} _connection
* Standalone RPC client that doesn't require connection to the TVM wallet provider
* @param {Address | string} address
* DexAccount root address
* @param {Dex} dex Dex Smart Contract Model instance
* @param {Readonly<DexAccountCtorOptions>} [options]
* (optional) DexAccount 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<DexAccountCtorOptions> | undefined, _provider?: ProviderRpcClient | undefined);
/**
* @param {ProviderRpcClient} connection
* Standalone RPC client that doesn't require connection to the TVM wallet provider
* @param {Readonly<DexAccountCreateConfig>} config
* DexAccount Smart Contract Model config
* @param {Readonly<DexAccountCtorOptions>} [options]
* (optional) DexAccount Smart Contract Model options
* @param {ProviderRpcClient} [provider]
* (optional) RPC provider that require connection to the TVM wallet
*/
static create(connection: ProviderRpcClient, config: Readonly<DexAccountCreateConfig>, options?: Readonly<DexAccountCreateOptions>, provider?: ProviderRpcClient): Promise<DexAccount>;
sync(options?: Forceable & Silentable): Promise<void>;
watch(callback?: SmartContractWatchCallback<DexAccountData>): Promise<Subscriber>;
unwatch(): Promise<void>;
check(options?: Forceable): Promise<boolean>;
/**
* Stream-based method to add pair (constant or stable) to the DexAccount
* @param {DexAccountDepositTokenParams} params
* @param {Partial<SendInternalParams>} [args]
* @deprecated Use `DexAccount.addPool` instead
*/
addPair(params: DexAccountAddPairParams, args: Pick<SendInternalParams, 'from'> & Omit<Partial<SendInternalParams>, 'from'>): Promise<Transaction | undefined>;
/**
* Stream-based method to add pool (stable) to the DexAccount
* @param {DexAccountDepositTokenParams} params
* @param {Partial<SendInternalParams>} [args]
*/
addPool(params: DexAccountAddPoolParams, args: Pick<SendInternalParams, 'from'> & Omit<Partial<SendInternalParams>, 'from'>): Promise<Transaction | undefined>;
/**
* Stream-based method to deposit a given token to the DexAccount
* @param {DexAccountDepositTokenParams} params
* @param {Partial<SendInternalParams>} [args]
*/
depositToken(params: DexAccountDepositTokenParams, args?: Partial<SendInternalParams>): Promise<Transaction | undefined>;
/**
* Stream-based method to deposit a liquidity from the DexAccount assets
* @param {DexAccountDepositLiquidityParams} params
* @param {Partial<SendInternalParams>} [args]
*/
depositLiquidity(params: DexAccountDepositLiquidityParams, args?: Partial<SendInternalParams>): Promise<Transaction | undefined>;
depositLiquidityV2(params: DexAccountDepositLiquidityV2Params, args?: Partial<SendInternalParams>): Promise<Transaction | undefined>;
/**
Stream-based method to withdraw a given token from the DexAccount
* @param {DexAccountWithdrawTokenParams} params
* @param {Partial<SendInternalParams>} [args]
*/
withdrawToken(params: DexAccountWithdrawTokenParams, args?: Partial<SendInternalParams>): Promise<Transaction | undefined>;
/**
* Returns user lp wallets balances as map where
* key is lp wallet address and value is balance.
* @returns {DexAccountData["balances"]}
*/
get balances(): DexAccountData['balances'];
/**
* Returns account owner address
* @returns {DexAccountData["ownerAddress"]}
*/
get ownerAddress(): DexAccountData['ownerAddress'];
/**
* Returns user token wallets addresses as map where
* key is lp token address and value is token wallet address.
* @returns {DexAccountData["wallets"]}
*/
get wallets(): DexAccountData['wallets'];
decodeEvent(args: DecodeEventParams<typeof DexAccountAbi>): Promise<DexAccountDecodedEvent | undefined>;
decodeTransaction(args: DecodeTransactionParams<typeof DexAccountAbi>): Promise<DexAccountDecodedTransaction | undefined>;
decodeTransactionEvents(transaction: Transaction): Promise<DexAccountDecodedEvent[]>;
}