UNPKG

client-aftermath-ts-sdk

Version:
342 lines 14.2 kB
import { TransactionObjectArgument, Transaction } from "@mysten/sui/transactions"; import { AftermathApi } from "../../../general/providers/aftermathApi"; import { CoinDecimal, CoinType, CoinsToBalance } from "../../coin/coinTypes"; import { Balance, Slippage, PoolCreationLpCoinMetadata, PoolName, PoolTradeFee, AnyObjectType, ReferralVaultAddresses, PoolsAddresses, PoolFlatness, PoolWeight, PoolWithdrawFee, PoolDepositFee, Url, ObjectId, SuiAddress, ApiPublishLpCoinBody, DaoFeePoolsAddresses, ApiPoolsOwnedDaoFeePoolOwnerCapsBody, DaoFeePoolOwnerCapObject } from "../../../types"; import { Pool } from "../pool"; import { MoveErrors, MoveErrorsInterface } from "../../../general/types/moveErrorsInterface"; /** * This file contains the implementation of the PoolsApi class, which provides methods for interacting with the Aftermath protocol's pools. * @packageDocumentation */ /** * Provides methods to interact with the Pools API. */ export declare class PoolsApi implements MoveErrorsInterface { private readonly Provider; /** * Constants used in the pools API. */ private static readonly constants; /** * Object containing the addresses of various contracts. */ readonly addresses: { pools: PoolsAddresses; referralVault: ReferralVaultAddresses; daoFeePools?: DaoFeePoolsAddresses; }; readonly objectTypes: { pool: AnyObjectType; daoFeePool?: AnyObjectType; daoFeePoolOwnerCap?: AnyObjectType; }; readonly eventTypes: { trade: AnyObjectType; deposit: AnyObjectType; withdraw: AnyObjectType; tradeV2: AnyObjectType; depositV2: AnyObjectType; withdrawV2: AnyObjectType; }; readonly moveErrors: MoveErrors; /** * Creates an instance of PoolsApi. * @param {AftermathApi} Provider - An instance of AftermathApi. * @throws {Error} Throws an error if not all required addresses have been set in AfSdk */ constructor(Provider: AftermathApi); fetchOwnedDaoFeePoolOwnerCaps: (inputs: ApiPoolsOwnedDaoFeePoolOwnerCapsBody) => Promise<DaoFeePoolOwnerCapObject[]>; /** * Executes a trade transaction on the specified pool. * @param inputs An object containing the necessary inputs for the trade transaction. * @returns A `TransactionObjectArgument` representing the trade transaction. */ tradeTx: (inputs: { tx: Transaction; poolId: ObjectId; coinInId: ObjectId | TransactionObjectArgument; coinInType: CoinType; expectedCoinOutAmount: Balance; coinOutType: CoinType; lpCoinType: CoinType; slippage: Slippage; withTransfer?: boolean; }) => TransactionObjectArgument; /** * Creates a transaction object argument for depositing multiple coins into a pool. * * @param inputs - An object containing the necessary parameters for the deposit transaction. * @returns A transaction object argument representing the deposit transaction. */ multiCoinDepositTx: (inputs: { tx: Transaction; poolId: ObjectId; coinIds: ObjectId[] | TransactionObjectArgument[]; coinTypes: CoinType[]; expectedLpRatio: bigint; lpCoinType: CoinType; slippage: Slippage; withTransfer?: boolean; }) => TransactionObjectArgument; /** * Withdraws multiple coins from a pool. * @param inputs An object containing the necessary parameters for the transaction. * @returns A TransactionObjectArgument representing the transaction. */ multiCoinWithdrawTx: (inputs: { tx: Transaction; poolId: ObjectId; lpCoinId: ObjectId | TransactionObjectArgument; lpCoinType: CoinType; expectedAmountsOut: Balance[]; coinTypes: CoinType[]; slippage: Slippage; withTransfer?: boolean; }) => TransactionObjectArgument; /** * Withdraws all coins from a liquidity pool. * @param inputs - The inputs required for the transaction. * @param inputs.tx - The transaction block. * @param inputs.poolId - The ID of the liquidity pool. * @param inputs.lpCoinId - The ID of the LP coin. * @param inputs.lpCoinType - The type of the LP coin. * @param inputs.coinTypes - An array of coin types. * @param inputs.withTransfer - Whether or not to include a transfer. * @returns An array of transaction objects. */ allCoinWithdrawTx: (inputs: { tx: Transaction; poolId: ObjectId; lpCoinId: ObjectId | TransactionObjectArgument; lpCoinType: CoinType; coinTypes: CoinType[]; withTransfer?: boolean; }) => TransactionObjectArgument[]; /** * Publishes a transaction block for creating a liquidity pool coin. * @param inputs An object containing the transaction block and the decimal value of the liquidity pool coin. * @returns A promise that resolves to the result of the transaction publishing. */ publishLpCoinTx: (inputs: { tx: Transaction; lpCoinDecimals: CoinDecimal; }) => import("@mysten/sui/transactions").TransactionResult; /** * Creates a transaction to create a new pool. * @param inputs - An object containing the necessary inputs to create the pool. * @returns A transaction block to create the pool. */ createPoolTx: (inputs: { tx: Transaction; lpCoinType: CoinType; coinsInfo: { coinId: ObjectId | TransactionObjectArgument; coinType: CoinType; weight: PoolWeight; decimals?: CoinDecimal; tradeFeeIn: PoolTradeFee; tradeFeeOut: PoolTradeFee; depositFee: PoolDepositFee; withdrawFee: PoolWithdrawFee; }[]; lpCoinMetadata: PoolCreationLpCoinMetadata; lpCoinIconUrl: Url; createPoolCapId: ObjectId | TransactionObjectArgument; poolName: PoolName; poolFlatness: PoolFlatness; lpCoinDescription: string; respectDecimals: boolean; forceLpDecimals?: CoinDecimal; withTransfer?: boolean; }) => TransactionObjectArgument[]; /** * Returns the pool object ID for a given LP coin type transaction. * @param inputs - An object containing the transaction block and LP coin type. * @returns The pool object ID. */ poolObjectIdForLpCoinTypeTx: (inputs: { tx: Transaction; lpCoinType: CoinType; }) => import("@mysten/sui/transactions").TransactionResult; daoFeePoolNewTx: (inputs: { tx: Transaction; poolId: ObjectId | TransactionObjectArgument; feeBps: bigint; feeRecipient: SuiAddress; lpCoinType: CoinType; }) => import("@mysten/sui/transactions").TransactionResult; daoFeePoolUpdateFeeBpsTx: (inputs: { tx: Transaction; daoFeePoolOwnerCapId: ObjectId; daoFeePoolId: ObjectId; newFeeBps: bigint; lpCoinType: CoinType; }) => import("@mysten/sui/transactions").TransactionResult; daoFeePoolUpdateFeeRecipientTx: (inputs: { tx: Transaction; daoFeePoolOwnerCapId: ObjectId; daoFeePoolId: ObjectId; newFeeRecipient: SuiAddress; lpCoinType: CoinType; }) => import("@mysten/sui/transactions").TransactionResult; /** * Executes a trade transaction on the specified pool. * @param inputs An object containing the necessary inputs for the trade transaction. * @returns A `TransactionObjectArgument` representing the trade transaction. */ daoFeePoolTradeTx: (inputs: { tx: Transaction; daoFeePoolId: ObjectId; coinInId: ObjectId | TransactionObjectArgument; coinInType: CoinType; expectedCoinOutAmount: Balance; coinOutType: CoinType; lpCoinType: CoinType; slippage: Slippage; }) => TransactionObjectArgument; /** * Creates a transaction object argument for depositing multiple coins into a pool. * * @param inputs - An object containing the necessary parameters for the deposit transaction. * @returns A transaction object argument representing the deposit transaction. */ daoFeePoolMultiCoinDepositTx: (inputs: { tx: Transaction; daoFeePoolId: ObjectId; coinIds: ObjectId[] | TransactionObjectArgument[]; coinTypes: CoinType[]; expectedLpRatio: bigint; lpCoinType: CoinType; slippage: Slippage; }) => TransactionObjectArgument; /** * Withdraws all coins from a liquidity pool. * @param inputs - The inputs required for the transaction. * @param inputs.tx - The transaction block. * @param inputs.poolId - The ID of the liquidity pool. * @param inputs.lpCoinId - The ID of the LP coin. * @param inputs.lpCoinType - The type of the LP coin. * @param inputs.coinTypes - An array of coin types. * @returns An array of transaction objects. */ daoFeePoolAllCoinWithdrawTx: (inputs: { tx: Transaction; daoFeePoolId: ObjectId; lpCoinId: ObjectId | TransactionObjectArgument; lpCoinType: CoinType; coinTypes: CoinType[]; }) => TransactionObjectArgument[]; /** * Fetches a transaction block for trading in a pool. * @async * @param {SuiAddress} inputs.walletAddress - The wallet address of the user trading in the pool. * @param {Pool} inputs.pool - The pool to trade in. * @param {CoinType} inputs.coinInType - The coin type of the coin being traded in. * @param {Balance} inputs.coinInAmount - The amount of the coin being traded in. * @param {CoinType} inputs.coinOutType - The coin type of the coin being traded out. * @param {Slippage} inputs.slippage - The slippage of the trade. * @param {SuiAddress} [inputs.referrer] - The referrer of the trade. * @param {boolean} [inputs.isSponsoredTx] - Whether the transaction is sponsored. * @returns {Promise<Transaction>} A promise that resolves to the fetched transaction block. */ fetchBuildTradeTx: (inputs: { walletAddress: SuiAddress; pool: Pool; coinInType: CoinType; coinInAmount: Balance; coinOutType: CoinType; slippage: Slippage; referrer?: SuiAddress; isSponsoredTx?: boolean; }) => Promise<Transaction>; fetchAddTradeTx: (inputs: { tx: Transaction; coinInId: ObjectId | TransactionObjectArgument; coinInType: CoinType; coinInAmount: Balance; coinOutType: CoinType; slippage: Slippage; pool: Pool; referrer?: SuiAddress; }) => Promise<TransactionObjectArgument>; /** * Fetches a transaction block for depositing in a pool. * @async * @param {SuiAddress} inputs.walletAddress - The wallet address of the user depositing in the pool. * @param {Pool} inputs.pool - The pool to deposit in. * @param {CoinsToBalance} inputs.amountsIn - The amounts of coins being deposited. * @param {Slippage} inputs.slippage - The slippage of the deposit. * @param {SuiAddress} [inputs.referrer] - The referrer of the deposit. * @param {boolean} [inputs.isSponsoredTx] - Whether the transaction is sponsored. * @returns {Promise<Transaction>} A promise that resolves to the fetched transaction block. */ fetchBuildDepositTx: (inputs: { walletAddress: SuiAddress; pool: Pool; amountsIn: CoinsToBalance; slippage: Slippage; referrer?: SuiAddress; isSponsoredTx?: boolean; }) => Promise<Transaction>; /** * Fetches a transaction block for withdrawing from a pool. * @async * @param {SuiAddress} inputs.walletAddress - The wallet address of the user withdrawing from the pool. * @param {Pool} inputs.pool - The pool to withdraw from. * @param {CoinsToBalance} inputs.amountsOutDirection - The amounts of coins being withdrawn. * @param {Balance} inputs.lpCoinAmount - The amount of LP tokens being withdrawn. * @param {Slippage} inputs.slippage - The slippage of the withdrawal. * @param {SuiAddress} [inputs.referrer] - The referrer of the withdrawal. * @returns {Promise<Transaction>} A promise that resolves to the fetched transaction block. */ fetchBuildWithdrawTx: (inputs: { walletAddress: SuiAddress; pool: Pool; amountsOutDirection: CoinsToBalance; lpCoinAmount: Balance; slippage: Slippage; referrer?: SuiAddress; }) => Promise<Transaction>; /** * Fetches a transaction block that withdraws all coins from a pool in exchange for the corresponding LP tokens. * @param inputs An object containing the wallet address, pool, LP coin amount, and optional referrer. * @returns A promise that resolves to a Transaction object. */ fetchBuildAllCoinWithdrawTx: (inputs: { walletAddress: SuiAddress; pool: Pool; lpCoinAmount: Balance; referrer?: SuiAddress; }) => Promise<Transaction>; /** * Builds a transaction block for publishing an LP coin. * @param inputs - The input parameters for the transaction. * @returns The built transaction block. */ buildPublishLpCoinTx: (inputs: ApiPublishLpCoinBody) => Transaction; buildDaoFeePoolUpdateFeeBpsTx: (inputs: { walletAddress: string; } & Omit<{ tx: Transaction; daoFeePoolOwnerCapId: ObjectId; daoFeePoolId: ObjectId; newFeeBps: bigint; lpCoinType: CoinType; }, "tx">) => Transaction; buildDaoFeePoolUpdateFeeRecipientTx: (inputs: { walletAddress: string; } & Omit<{ tx: Transaction; daoFeePoolOwnerCapId: ObjectId; daoFeePoolId: ObjectId; newFeeRecipient: SuiAddress; lpCoinType: CoinType; }, "tx">) => Transaction; private tradeEventType; private depositEventType; private withdrawEventType; private tradeV2EventType; private depositV2EventType; private withdrawV2EventType; } //# sourceMappingURL=poolsApi.d.ts.map