UNPKG

@broxus/js-core

Version:

MobX-based JavaScript Core library

157 lines (156 loc) 8.44 kB
import { type Address, type DecodeEventParams, type DecodeTransactionParams, type DelayedMessageExecution, type FullContractState, type ProviderRpcClient, type SendInternalParams, type Transaction } from 'everscale-inpage-provider'; import { type DexAccountAbi } from '../../models/dex-account/abi'; import { type DexAccountDecodedEvent, type DexAccountDecodedTransaction } from '../../models/dex-account/types'; import { type CallId } from '../../types'; export interface DexAccountAddPairAbiParams { leftRootAddress: Address | string; rightRootAddress: Address | string; } export interface DexAccountAddPoolAbiParams { roots: (Address | string)[]; } export interface DexAccountDepositLiquidityAbiParams extends Partial<CallId> { autoChange: boolean; expectedLpAddress: Address | string; leftAmount: string | number; leftRootAddress: Address | string; rightAmount: string | number; rightRootAddress: Address | string; sendGasTo: Address | string; } export interface DexAccountDepositLiquidityV2AbiParams extends Partial<CallId> { expected: { amount: string | number; root: Address | string; }; operations: { amount: string | number; root: Address | string; }[]; referrer: Address | string; remainingGasTo: Address | string; } export interface DexAccountWithdrawAbiParams extends Partial<CallId> { amount: string | number; deployWalletGrams?: string | number; recipientAddress: Address | string; sendGasTo: Address | string; tokenAddress: Address | string; } export interface DexAccountWithdrawLiquidityAbiParams extends Partial<CallId> { amount: string | number; leftRootAddress: Address | string; lpRootAddress: Address | string; rightRootAddress: Address | string; sendGasTo: Address | string; } export declare abstract class DexAccountUtils { /** * Sends a delayed message to add a pair to the Account * @param {ProviderRpcClient} provider * @param {Address | string} dexAccountAddress * @param {DexAccountAddPairAbiParams} params * @param {Pick<SendInternalParams, 'from'> & Omit<Partial<SendInternalParams>, 'from'>} args * @returns {Promise<DelayedMessageExecution>} */ static addPair(provider: ProviderRpcClient, dexAccountAddress: Address | string, params: DexAccountAddPairAbiParams, args: Pick<SendInternalParams, 'from'> & Omit<Partial<SendInternalParams>, 'from'>): Promise<DelayedMessageExecution>; /** * Sends a delayed message to add a pool to the Account * @param {ProviderRpcClient} provider * @param {Address | string} dexAccountAddress * @param {DexAccountAddPoolAbiParams} params * @param {Pick<SendInternalParams, 'from'> & Omit<Partial<SendInternalParams>, 'from'>} args * @returns {Promise<DelayedMessageExecution>} */ static addPool(provider: ProviderRpcClient, dexAccountAddress: Address | string, params: DexAccountAddPoolAbiParams, args: Pick<SendInternalParams, 'from'> & Omit<Partial<SendInternalParams>, 'from'>): Promise<DelayedMessageExecution>; /** * Sends a delayed message to deposit liquidity into a pair via the Account * @param {ProviderRpcClient} provider * @param {Address | string} dexAccountAddress * @param {DexAccountDepositLiquidityAbiParams} params * @param {Partial<SendInternalParams>} [args] * @returns {Promise<DelayedMessageExecution>} */ static depositLiquidity(provider: ProviderRpcClient, dexAccountAddress: Address | string, params: DexAccountDepositLiquidityAbiParams, args?: Partial<SendInternalParams>): Promise<DelayedMessageExecution>; /** * Sends a delayed message to deposit liquidity into a stable pool via the Account * @param {ProviderRpcClient} provider * @param {Address | string} dexAccountAddress * @param {DexAccountDepositLiquidityAbiParams} params * @param {Partial<SendInternalParams>} [args] * @returns {Promise<DelayedMessageExecution>} */ static depositLiquidityV2(provider: ProviderRpcClient, dexAccountAddress: Address | string, params: DexAccountDepositLiquidityV2AbiParams, args?: Partial<SendInternalParams>): Promise<DelayedMessageExecution>; /** * Sends a delayed message to withdraw token from the Account * @param {ProviderRpcClient} provider * @param {Address | string} dexAccountAddress * @param {DexAccountWithdrawAbiParams} params * @param {Partial<SendInternalParams>} [args] * @returns {Promise<DelayedMessageExecution>} */ static withdraw(provider: ProviderRpcClient, dexAccountAddress: Address | string, params: DexAccountWithdrawAbiParams, args?: Partial<SendInternalParams>): Promise<DelayedMessageExecution>; /** * Sends a delayed message to withdraw liquidity (LP tokens) from the Account * @param {ProviderRpcClient} provider * @param {Address | string} dexAccountAddress * @param {DexAccountWithdrawLiquidityAbiParams} params * @param {Partial<SendInternalParams>} [args] * @returns {Promise<DelayedMessageExecution>} * @deprecated */ static withdrawLiquidity(provider: ProviderRpcClient, dexAccountAddress: Address | string, params: DexAccountWithdrawLiquidityAbiParams, args?: Partial<SendInternalParams>): Promise<DelayedMessageExecution>; /** * Returns DEX Account owner address * @param {ProviderRpcClient} connection * @param {Address | string} dexAccountAddress * @param {FullContractState} cachedState * @returns {Promise<Address>} */ static getOwner(connection: ProviderRpcClient, dexAccountAddress: Address | string, cachedState?: FullContractState): Promise<Address>; /** * Returns token balance by the given DEX Account and token address addresses * @param {ProviderRpcClient} connection * @param {Address | string} dexAccountAddress * @param {Address | string} tokenAddress * @param {FullContractState | undefined} [cachedState] * @returns {Promise<string | undefined>} */ static getBalance(connection: ProviderRpcClient, dexAccountAddress: Address | string, tokenAddress: Address | string, cachedState?: FullContractState): Promise<string | undefined>; /** * Returns map of a user tokens balances in a DEX account * @param {ProviderRpcClient} connection * @param {Address | string} dexAccountAddress * @param {FullContractState} [cachedState] * @returns {Promise<Map<string, string>>} */ static getBalances(connection: ProviderRpcClient, dexAccountAddress: Address | string, cachedState?: FullContractState): Promise<Map<string, string>>; /** * * @param {ProviderRpcClient} connection * @param {Address | string} dexAccountAddress * @param {FullContractState} [cachedState] * @returns Promise<string> */ static getVersion(connection: ProviderRpcClient, dexAccountAddress: Address | string, cachedState?: FullContractState): Promise<string>; /** * Returns token wallet by the given DEX Account and token address addresses * @param {ProviderRpcClient} connection * @param {Address | string} dexAccountAddress * @param {Address | string} tokenAddress * @param {FullContractState | undefined} [cachedState] * @returns Promise<Address> */ static getWallet(connection: ProviderRpcClient, dexAccountAddress: Address | string, tokenAddress: Address | string, cachedState?: FullContractState): Promise<Address>; /** * * @param {ProviderRpcClient} connection * @param {Address | string} dexAccountAddress * @param {FullContractState} [cachedState] * @returns {Promise<Map<string, Address>>} */ static getWallets(connection: ProviderRpcClient, dexAccountAddress: Address | string, cachedState?: FullContractState): Promise<Map<string, Address>>; static decodeEvent(connection: ProviderRpcClient, dexAccountAddress: Address | string, args: DecodeEventParams<typeof DexAccountAbi>): Promise<DexAccountDecodedEvent | undefined>; static decodeTransaction(connection: ProviderRpcClient, dexAccountAddress: Address | string, args: DecodeTransactionParams<typeof DexAccountAbi>): Promise<DexAccountDecodedTransaction | undefined>; static decodeTransactionEvents(connection: ProviderRpcClient, dexAccountAddress: Address | string, transaction: Transaction): Promise<DexAccountDecodedEvent[]>; }