import type { Address } from 'abitype'; import { type ReadContractReturnType } from '../../actions/public/readContract.js'; import { type WatchContractEventParameters } from '../../actions/public/watchContractEvent.js'; import { type WriteContractReturnType, writeContract } from '../../actions/wallet/writeContract.js'; import { writeContractSync } from '../../actions/wallet/writeContractSync.js'; import type { Client } from '../../clients/createClient.js'; import type { Transport } from '../../clients/transports/createTransport.js'; import type { BaseErrorType } from '../../errors/base.js'; import type { Account } from '../../types/account.js'; import type { Chain } from '../../types/chain.js'; import type { ExtractAbiItem, GetEventArgs } from '../../types/contract.js'; import type { Log as viem_Log } from '../../types/log.js'; import type { Compute, UnionOmit } from '../../types/utils.js'; import * as Abis from '../Abis.js'; import type { GetAccountParameter, ReadParameters, WriteParameters } from '../internal/types.js'; import type { TransactionReceipt } from '../Transaction.js'; /** * Order type for limit orders. */ type OrderType = 'buy' | 'sell'; /** * Buys a specific amount of tokens. * * @example * ```ts * import { createClient, http, parseUnits } from 'viem' * import { privateKeyToAccount } from 'viem/accounts' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * account: privateKeyToAccount('0x...'), * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const hash = await Actions.dex.buy(client, { * tokenIn: '0x20c...11', * tokenOut: '0x20c...20', * amountOut: parseUnits('100', 6), * maxAmountIn: parseUnits('105', 6), * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction hash. */ export declare function buy(client: Client, parameters: buy.Parameters): Promise; export declare namespace buy { type Parameters = WriteParameters & Args; type Args = { /** Amount of tokenOut to buy. */ amountOut: bigint; /** Maximum amount of tokenIn to spend. */ maxAmountIn: bigint; /** Address of the token to spend. */ tokenIn: Address; /** Address of the token to buy. */ tokenOut: Address; }; type ReturnValue = WriteContractReturnType; type ErrorType = BaseErrorType; /** @internal */ function inner(action: action, client: Client, parameters: buy.Parameters): Promise>; /** * Defines a call to the `swapExactAmountOut` function. * * Can be passed as a parameter to: * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls * * @example * ```ts * import { createClient, http, parseUnits, walletActions } from 'viem' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }).extend(walletActions) * * const { result } = await client.sendCalls({ * calls: [ * Actions.dex.buy.call({ * tokenIn: '0x20c0...beef', * tokenOut: '0x20c0...babe', * amountOut: parseUnits('100', 6), * maxAmountIn: parseUnits('105', 6), * }), * ] * }) * ``` * * @param args - Arguments. * @returns The call. */ function call(args: Args): { abi: [{ readonly name: "swapExactAmountOut"; readonly type: "function"; readonly stateMutability: "nonpayable"; readonly inputs: readonly [{ readonly type: "address"; readonly name: "tokenIn"; }, { readonly type: "address"; readonly name: "tokenOut"; }, { readonly type: "uint128"; readonly name: "amountOut"; }, { readonly type: "uint128"; readonly name: "maxAmountIn"; }]; readonly outputs: readonly [{ readonly type: "uint128"; readonly name: "amountIn"; }]; }]; functionName: "swapExactAmountOut"; } & { args: readonly [tokenIn: `0x${string}`, tokenOut: `0x${string}`, amountOut: bigint, maxAmountIn: bigint]; } & { address: Address; } & { data: import("../../index.js").Hex; to: Address; }; } /** * Buys a specific amount of tokens. * * @example * ```ts * import { createClient, http, parseUnits } from 'viem' * import { privateKeyToAccount } from 'viem/accounts' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * account: privateKeyToAccount('0x...'), * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const result = await Actions.dex.buySync(client, { * tokenIn: '0x20c...11', * tokenOut: '0x20c...20', * amountOut: parseUnits('100', 6), * maxAmountIn: parseUnits('105', 6), * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction receipt. */ export declare function buySync(client: Client, parameters: buySync.Parameters): Promise; export declare namespace buySync { type Parameters = buy.Parameters; type Args = buy.Args; type ReturnValue = Compute<{ /** Transaction receipt. */ receipt: TransactionReceipt; }>; type ErrorType = BaseErrorType; } /** * Cancels an order from the orderbook. * * @example * ```ts * import { createClient, http } from 'viem' * import { privateKeyToAccount } from 'viem/accounts' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * account: privateKeyToAccount('0x...'), * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const hash = await Actions.dex.cancel(client, { * orderId: 123n, * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction hash. */ export declare function cancel(client: Client, parameters: cancel.Parameters): Promise; export declare namespace cancel { type Parameters = WriteParameters & Args; type Args = { /** Order ID to cancel. */ orderId: bigint; }; type ReturnValue = WriteContractReturnType; type ErrorType = BaseErrorType; /** @internal */ function inner(action: action, client: Client, parameters: cancel.Parameters): Promise>; /** * Defines a call to the `cancel` function. * * Can be passed as a parameter to: * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls * * @example * ```ts * import { createClient, http, walletActions } from 'viem' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }).extend(walletActions) * * const { result } = await client.sendCalls({ * calls: [ * Actions.dex.cancel.call({ * orderId: 123n, * }), * ] * }) * ``` * * @param args - Arguments. * @returns The call. */ function call(args: Args): { abi: [{ readonly name: "cancel"; readonly type: "function"; readonly stateMutability: "nonpayable"; readonly inputs: readonly [{ readonly type: "uint128"; readonly name: "orderId"; }]; readonly outputs: readonly []; }]; functionName: "cancel"; } & { args: readonly [orderId: bigint]; } & { address: Address; } & { data: import("../../index.js").Hex; to: Address; }; /** * Extracts the `OrderCancelled` event from logs. * * @param logs - The logs. * @returns The `OrderCancelled` event. */ function extractEvent(logs: viem_Log[]): viem_Log; } /** * Cancels an order from the orderbook. * * @example * ```ts * import { createClient, http } from 'viem' * import { privateKeyToAccount } from 'viem/accounts' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * account: privateKeyToAccount('0x...'), * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const result = await Actions.dex.cancelSync(client, { * orderId: 123n, * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction receipt and event data. */ export declare function cancelSync(client: Client, parameters: cancelSync.Parameters): Promise; export declare namespace cancelSync { type Parameters = cancel.Parameters; type Args = cancel.Args; type ReturnValue = Compute & { /** Transaction receipt. */ receipt: TransactionReceipt; }>; type ErrorType = BaseErrorType; } /** * Cancels a stale order from the orderbook. * * A stale order is one where the owner's balance or allowance has dropped * below the order amount. * * @example * ```ts * import { createClient, http } from 'viem' * import { privateKeyToAccount } from 'viem/accounts' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * account: privateKeyToAccount('0x...'), * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const hash = await Actions.dex.cancelStale(client, { * orderId: 123n, * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction hash. */ export declare function cancelStale(client: Client, parameters: cancelStale.Parameters): Promise; export declare namespace cancelStale { type Parameters = WriteParameters & Args; type Args = { /** Order ID to cancel. */ orderId: bigint; }; type ReturnValue = WriteContractReturnType; type ErrorType = BaseErrorType; /** @internal */ function inner(action: action, client: Client, parameters: cancelStale.Parameters): Promise>; /** * Defines a call to the `cancelStaleOrder` function. * * Can be passed as a parameter to: * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls * * @example * ```ts * import { createClient, http, walletActions } from 'viem' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }).extend(walletActions) * * const { result } = await client.sendCalls({ * calls: [ * Actions.dex.cancelStale.call({ * orderId: 123n, * }), * ] * }) * ``` * * @param args - Arguments. * @returns The call. */ function call(args: Args): { abi: [{ readonly name: "cancelStaleOrder"; readonly type: "function"; readonly stateMutability: "nonpayable"; readonly inputs: readonly [{ readonly type: "uint128"; readonly name: "orderId"; }]; readonly outputs: readonly []; }]; functionName: "cancelStaleOrder"; } & { args: readonly [orderId: bigint]; } & { address: Address; } & { data: import("../../index.js").Hex; to: Address; }; /** * Extracts the `OrderCancelled` event from logs. * * @param logs - The logs. * @returns The `OrderCancelled` event. */ function extractEvent(logs: viem_Log[]): viem_Log; } /** * Cancels a stale order from the orderbook and waits for confirmation. * * A stale order is one where the owner's balance or allowance has dropped * below the order amount. * * @example * ```ts * import { createClient, http } from 'viem' * import { privateKeyToAccount } from 'viem/accounts' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * account: privateKeyToAccount('0x...'), * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const result = await Actions.dex.cancelStaleSync(client, { * orderId: 123n, * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction receipt and event data. */ export declare function cancelStaleSync(client: Client, parameters: cancelStaleSync.Parameters): Promise; export declare namespace cancelStaleSync { type Parameters = cancelStale.Parameters; type Args = cancelStale.Args; type ReturnValue = Compute & { /** Transaction receipt. */ receipt: TransactionReceipt; }>; type ErrorType = BaseErrorType; } /** * Creates a new trading pair on the DEX. * * @example * ```ts * import { createClient, http } from 'viem' * import { privateKeyToAccount } from 'viem/accounts' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * account: privateKeyToAccount('0x...'), * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const hash = await Actions.dex.createPair(client, { * base: '0x20c...11', * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction hash. */ export declare function createPair(client: Client, parameters: createPair.Parameters): Promise; export declare namespace createPair { type Parameters = WriteParameters & Args; type Args = { /** Address of the base token for the pair. */ base: Address; }; type ReturnValue = WriteContractReturnType; type ErrorType = BaseErrorType; /** @internal */ function inner(action: action, client: Client, parameters: createPair.Parameters): Promise>; /** * Defines a call to the `createPair` function. * * Can be passed as a parameter to: * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls * * @example * ```ts * import { createClient, http, walletActions } from 'viem' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }).extend(walletActions) * * const { result } = await client.sendCalls({ * calls: [ * Actions.dex.createPair.call({ * base: '0x20c0...beef', * }), * ] * }) * ``` * * @param args - Arguments. * @returns The call. */ function call(args: Args): { abi: [{ readonly name: "createPair"; readonly type: "function"; readonly stateMutability: "nonpayable"; readonly inputs: readonly [{ readonly type: "address"; readonly name: "base"; }]; readonly outputs: readonly [{ readonly type: "bytes32"; readonly name: "key"; }]; }]; functionName: "createPair"; } & { args: readonly [base: `0x${string}`]; } & { address: Address; } & { data: import("../../index.js").Hex; to: Address; }; /** * Extracts the `PairCreated` event from logs. * * @param logs - The logs. * @returns The `PairCreated` event. */ function extractEvent(logs: viem_Log[]): viem_Log; } /** * Creates a new trading pair on the DEX. * * @example * ```ts * import { createClient, http } from 'viem' * import { privateKeyToAccount } from 'viem/accounts' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * account: privateKeyToAccount('0x...'), * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const result = await Actions.dex.createPairSync(client, { * base: '0x20c...11', * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction receipt and event data. */ export declare function createPairSync(client: Client, parameters: createPairSync.Parameters): Promise; export declare namespace createPairSync { type Parameters = createPair.Parameters; type Args = createPair.Args; type ReturnValue = Compute & { /** Transaction receipt. */ receipt: TransactionReceipt; }>; type ErrorType = BaseErrorType; } /** * Gets a user's token balance on the DEX. * * @example * ```ts * import { createClient, http } from 'viem' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const balance = await Actions.dex.getBalance(client, { * account: '0x...', * token: '0x20c...11', * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The user's token balance on the DEX. */ export declare function getBalance(client: Client, parameters: getBalance.Parameters): Promise; export declare namespace getBalance { type Parameters = ReadParameters & GetAccountParameter & Args; type Args = { /** Address of the account. */ account: Address; /** Address of the token. */ token: Address; }; type ReturnValue = ReadContractReturnType; /** * Defines a call to the `balanceOf` function. * * @param args - Arguments. * @returns The call. */ function call(args: Args): { abi: [{ readonly name: "balanceOf"; readonly type: "function"; readonly stateMutability: "view"; readonly inputs: readonly [{ readonly type: "address"; readonly name: "user"; }, { readonly type: "address"; readonly name: "token"; }]; readonly outputs: readonly [{ readonly type: "uint128"; }]; }]; functionName: "balanceOf"; } & { args: readonly [user: `0x${string}`, token: `0x${string}`]; } & { address: Address; } & { data: import("../../index.js").Hex; to: Address; }; } /** * Gets the quote for buying a specific amount of tokens. * * @example * ```ts * import { createClient, http, parseUnits } from 'viem' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const amountIn = await Actions.dex.getBuyQuote(client, { * amountOut: parseUnits('100', 6), * tokenIn: '0x20c...11', * tokenOut: '0x20c...20', * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The amount of tokenIn needed to buy the specified amountOut. */ export declare function getBuyQuote(client: Client, parameters: getBuyQuote.Parameters): Promise; export declare namespace getBuyQuote { type Parameters = ReadParameters & Args; type Args = { /** Amount of tokenOut to buy. */ amountOut: bigint; /** Address of the token to spend. */ tokenIn: Address; /** Address of the token to buy. */ tokenOut: Address; }; type ReturnValue = ReadContractReturnType; /** * Defines a call to the `quoteSwapExactAmountOut` function. * * @param args - Arguments. * @returns The call. */ function call(args: Args): { abi: [{ readonly name: "quoteSwapExactAmountOut"; readonly type: "function"; readonly stateMutability: "view"; readonly inputs: readonly [{ readonly type: "address"; readonly name: "tokenIn"; }, { readonly type: "address"; readonly name: "tokenOut"; }, { readonly type: "uint128"; readonly name: "amountOut"; }]; readonly outputs: readonly [{ readonly type: "uint128"; readonly name: "amountIn"; }]; }]; functionName: "quoteSwapExactAmountOut"; } & { args: readonly [tokenIn: `0x${string}`, tokenOut: `0x${string}`, amountOut: bigint]; } & { address: Address; } & { data: import("../../index.js").Hex; to: Address; }; } /** * Gets an order's details from the orderbook. * * @example * ```ts * import { createClient, http } from 'viem' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const order = await Actions.dex.getOrder(client, { * orderId: 123n, * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The order details. */ export declare function getOrder(client: Client, parameters: getOrder.Parameters): Promise; export declare namespace getOrder { type Parameters = ReadParameters & Args; type Args = { /** Order ID to query. */ orderId: bigint; }; type ReturnValue = ReadContractReturnType; /** * Defines a call to the `getOrder` function. * * @param args - Arguments. * @returns The call. */ function call(args: Args): { abi: [{ readonly name: "getOrder"; readonly type: "function"; readonly stateMutability: "view"; readonly inputs: readonly [{ readonly type: "uint128"; readonly name: "orderId"; }]; readonly outputs: readonly [{ readonly type: "tuple"; readonly components: readonly [{ readonly type: "uint128"; readonly name: "orderId"; }, { readonly type: "address"; readonly name: "maker"; }, { readonly type: "bytes32"; readonly name: "bookKey"; }, { readonly type: "bool"; readonly name: "isBid"; }, { readonly type: "int16"; readonly name: "tick"; }, { readonly type: "uint128"; readonly name: "amount"; }, { readonly type: "uint128"; readonly name: "remaining"; }, { readonly type: "uint128"; readonly name: "prev"; }, { readonly type: "uint128"; readonly name: "next"; }, { readonly type: "bool"; readonly name: "isFlip"; }, { readonly type: "int16"; readonly name: "flipTick"; }]; }]; }]; functionName: "getOrder"; } & { args: readonly [orderId: bigint]; } & { address: Address; } & { data: import("../../index.js").Hex; to: Address; }; } /** * Gets orderbook information for a trading pair. * * @example * ```ts * import { createClient, http } from 'viem' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const book = await Actions.dex.getOrderbook(client, { * base: '0x20c...11', * quote: '0x20c...20', * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The orderbook information. */ export declare function getOrderbook(client: Client, parameters: getOrderbook.Parameters): Promise; export declare namespace getOrderbook { type Parameters = ReadParameters & Args; type Args = { /** Address of the base token. */ base: Address; /** Address of the quote token. */ quote: Address; }; type ReturnValue = ReadContractReturnType; /** * Defines a call to the `books` function. * * @param args - Arguments. * @returns The call. */ function call(args: Args): { abi: [{ readonly name: "books"; readonly type: "function"; readonly stateMutability: "view"; readonly inputs: readonly [{ readonly type: "bytes32"; readonly name: "pairKey"; }]; readonly outputs: readonly [{ readonly type: "tuple"; readonly components: readonly [{ readonly type: "address"; readonly name: "base"; }, { readonly type: "address"; readonly name: "quote"; }, { readonly type: "int16"; readonly name: "bestBidTick"; }, { readonly type: "int16"; readonly name: "bestAskTick"; }]; }]; }]; functionName: "books"; } & { args: readonly [`0x${string}`]; } & { address: Address; } & { data: import("../../index.js").Hex; to: Address; }; } /** * Gets the price level information at a specific tick. * * @example * ```ts * import { createClient, http } from 'viem' * import { tempo } from 'viem/chains' * import { Actions, Tick } from 'viem/tempo' * * const client = createClient({ * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const level = await Actions.dex.getTickLevel(client, { * base: '0x20c...11', * tick: Tick.fromPrice('1.001'), * isBid: true, * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The price level information. */ export declare function getTickLevel(client: Client, parameters: getTickLevel.Parameters): Promise; export declare namespace getTickLevel { type Parameters = ReadParameters & Args; type Args = { /** Address of the base token. */ base: Address; /** Whether to query the bid side (true) or ask side (false). */ isBid: boolean; /** Price tick to query. */ tick: number; }; type ReturnValue = { /** Order ID of the first order at this tick (0 if empty) */ head: bigint; /** Order ID of the last order at this tick (0 if empty) */ tail: bigint; /** Total liquidity available at this tick level */ totalLiquidity: bigint; }; /** * Defines a call to the `getTickLevel` function. * * @param args - Arguments. * @returns The call. */ function call(args: Args): { abi: [{ readonly name: "getTickLevel"; readonly type: "function"; readonly stateMutability: "view"; readonly inputs: readonly [{ readonly type: "address"; readonly name: "base"; }, { readonly type: "int16"; readonly name: "tick"; }, { readonly type: "bool"; readonly name: "isBid"; }]; readonly outputs: readonly [{ readonly type: "uint128"; readonly name: "head"; }, { readonly type: "uint128"; readonly name: "tail"; }, { readonly type: "uint128"; readonly name: "totalLiquidity"; }]; }]; functionName: "getTickLevel"; } & { args: readonly [base: `0x${string}`, tick: number, boolean]; } & { address: Address; } & { data: import("../../index.js").Hex; to: Address; }; } /** * Gets the quote for selling a specific amount of tokens. * * @example * ```ts * import { createClient, http, parseUnits } from 'viem' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const amountOut = await Actions.dex.getSellQuote(client, { * amountIn: parseUnits('100', 6), * tokenIn: '0x20c...11', * tokenOut: '0x20c...20', * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The amount of tokenOut received for selling the specified amountIn. */ export declare function getSellQuote(client: Client, parameters: getSellQuote.Parameters): Promise; export declare namespace getSellQuote { type Parameters = ReadParameters & Args; type Args = { /** Amount of tokenIn to sell. */ amountIn: bigint; /** Address of the token to sell. */ tokenIn: Address; /** Address of the token to receive. */ tokenOut: Address; }; type ReturnValue = ReadContractReturnType; /** * Defines a call to the `quoteSwapExactAmountIn` function. * * @param args - Arguments. * @returns The call. */ function call(args: Args): { abi: [{ readonly name: "quoteSwapExactAmountIn"; readonly type: "function"; readonly stateMutability: "view"; readonly inputs: readonly [{ readonly type: "address"; readonly name: "tokenIn"; }, { readonly type: "address"; readonly name: "tokenOut"; }, { readonly type: "uint128"; readonly name: "amountIn"; }]; readonly outputs: readonly [{ readonly type: "uint128"; readonly name: "amountOut"; }]; }]; functionName: "quoteSwapExactAmountIn"; } & { args: readonly [tokenIn: `0x${string}`, tokenOut: `0x${string}`, amountIn: bigint]; } & { address: Address; } & { data: import("../../index.js").Hex; to: Address; }; } /** * Places a limit order on the orderbook. * * @example * ```ts * import { createClient, http, parseUnits } from 'viem' * import { privateKeyToAccount } from 'viem/accounts' * import { tempo } from 'viem/chains' * import { Actions, Tick } from 'viem/tempo' * * const client = createClient({ * account: privateKeyToAccount('0x...'), * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const hash = await Actions.dex.place(client, { * amount: parseUnits('100', 6), * tick: Tick.fromPrice('0.99'), * token: '0x20c...11', * type: 'buy', * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction hash. */ export declare function place(client: Client, parameters: place.Parameters): Promise; export declare namespace place { type Parameters = WriteParameters & Args; type Args = { /** Amount of tokens to place in the order. */ amount: bigint; /** Price tick for the order. */ tick: number; /** Address of the base token. */ token: Address; /** Order type - 'buy' to buy the token, 'sell' to sell it. */ type: OrderType; }; type ReturnValue = WriteContractReturnType; type ErrorType = BaseErrorType; /** @internal */ function inner(action: action, client: Client, parameters: place.Parameters): Promise>; /** * Defines a call to the `place` function. * * Can be passed as a parameter to: * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls * * @example * ```ts * import { createClient, http, parseUnits, walletActions } from 'viem' * import { tempo } from 'viem/chains' * import { Actions, Tick } from 'viem/tempo' * * const client = createClient({ * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }).extend(walletActions) * * const { result } = await client.sendCalls({ * calls: [ * Actions.dex.place.call({ * amount: parseUnits('100', 6), * tick: Tick.fromPrice('0.99'), * token: '0x20c0...beef', * type: 'buy', * }), * ] * }) * ``` * * @param args - Arguments. * @returns The call. */ function call(args: Args): { abi: [{ readonly name: "place"; readonly type: "function"; readonly stateMutability: "nonpayable"; readonly inputs: readonly [{ readonly type: "address"; readonly name: "token"; }, { readonly type: "uint128"; readonly name: "amount"; }, { readonly type: "bool"; readonly name: "isBid"; }, { readonly type: "int16"; readonly name: "tick"; }]; readonly outputs: readonly [{ readonly type: "uint128"; readonly name: "orderId"; }]; }]; functionName: "place"; } & { args: readonly [token: `0x${string}`, amount: bigint, boolean, tick: number]; } & { address: Address; } & { data: import("../../index.js").Hex; to: Address; }; /** * Extracts the `OrderPlaced` event from logs. * * @param logs - The logs. * @returns The `OrderPlaced` event. */ function extractEvent(logs: viem_Log[]): viem_Log; } /** * Places a flip order that automatically flips when filled. * * @example * ```ts * import { createClient, http, parseUnits } from 'viem' * import { privateKeyToAccount } from 'viem/accounts' * import { tempo } from 'viem/chains' * import { Actions, Tick } from 'viem/tempo' * * const client = createClient({ * account: privateKeyToAccount('0x...'), * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const hash = await Actions.dex.placeFlip(client, { * amount: parseUnits('100', 6), * flipTick: Tick.fromPrice('1.01'), * tick: Tick.fromPrice('0.99'), * token: '0x20c...11', * type: 'buy', * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction hash. */ export declare function placeFlip(client: Client, parameters: placeFlip.Parameters): Promise; export declare namespace placeFlip { type Parameters = WriteParameters & Args; type Args = { /** Amount of tokens to place in the order. */ amount: bigint; /** Target tick to flip to when order is filled. */ flipTick: number; /** Price tick for the order. */ tick: number; /** Address of the base token. */ token: Address; /** Order type - 'buy' to buy the token, 'sell' to sell it. */ type: OrderType; }; type ReturnValue = WriteContractReturnType; type ErrorType = BaseErrorType; /** @internal */ function inner(action: action, client: Client, parameters: placeFlip.Parameters): Promise>; /** * Defines a call to the `placeFlip` function. * * Can be passed as a parameter to: * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls * * @example * ```ts * import { createClient, http, parseUnits, walletActions } from 'viem' * import { tempo } from 'viem/chains' * import { Actions, Tick } from 'viem/tempo' * * const client = createClient({ * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }).extend(walletActions) * * const { result } = await client.sendCalls({ * calls: [ * Actions.dex.placeFlip.call({ * amount: parseUnits('100', 6), * flipTick: Tick.fromPrice('1.01'), * tick: Tick.fromPrice('0.99'), * token: '0x20c0...beef', * type: 'buy', * }), * ] * }) * ``` * * @param args - Arguments. * @returns The call. */ function call(args: Args): { abi: [{ readonly name: "placeFlip"; readonly type: "function"; readonly stateMutability: "nonpayable"; readonly inputs: readonly [{ readonly type: "address"; readonly name: "token"; }, { readonly type: "uint128"; readonly name: "amount"; }, { readonly type: "bool"; readonly name: "isBid"; }, { readonly type: "int16"; readonly name: "tick"; }, { readonly type: "int16"; readonly name: "flipTick"; }]; readonly outputs: readonly [{ readonly type: "uint128"; readonly name: "orderId"; }]; }]; functionName: "placeFlip"; } & { args: readonly [token: `0x${string}`, amount: bigint, boolean, tick: number, number]; } & { address: Address; } & { data: import("../../index.js").Hex; to: Address; }; /** * Extracts the `OrderPlaced` event (with `isFlipOrder: true`) from logs. * * @param logs - The logs. * @returns The `OrderPlaced` event for a flip order. */ function extractEvent(logs: viem_Log[]): viem_Log; } /** * Places a flip order that automatically flips when filled. * * @example * ```ts * import { createClient, http, parseUnits } from 'viem' * import { privateKeyToAccount } from 'viem/accounts' * import { tempo } from 'viem/chains' * import { Actions, Tick } from 'viem/tempo' * * const client = createClient({ * account: privateKeyToAccount('0x...'), * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const result = await Actions.dex.placeFlipSync(client, { * amount: parseUnits('100', 6), * flipTick: Tick.fromPrice('1.01'), * tick: Tick.fromPrice('0.99'), * token: '0x20c...11', * type: 'buy', * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction receipt and event data. */ export declare function placeFlipSync(client: Client, parameters: placeFlipSync.Parameters): Promise; export declare namespace placeFlipSync { type Parameters = placeFlip.Parameters; type Args = placeFlip.Args; type ReturnValue = Compute & { /** Transaction receipt. */ receipt: TransactionReceipt; }>; type ErrorType = BaseErrorType; } /** * Places a limit order on the orderbook. * * @example * ```ts * import { createClient, http, parseUnits } from 'viem' * import { privateKeyToAccount } from 'viem/accounts' * import { tempo } from 'viem/chains' * import { Actions, Tick } from 'viem/tempo' * * const client = createClient({ * account: privateKeyToAccount('0x...'), * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const result = await Actions.dex.placeSync(client, { * amount: parseUnits('100', 6), * tick: Tick.fromPrice('0.99'), * token: '0x20c...11', * type: 'buy', * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction receipt and event data. */ export declare function placeSync(client: Client, parameters: placeSync.Parameters): Promise; export declare namespace placeSync { type Parameters = place.Parameters; type Args = place.Args; type ReturnValue = Compute & { /** Transaction receipt. */ receipt: TransactionReceipt; }>; type ErrorType = BaseErrorType; } /** * Sells a specific amount of tokens. * * @example * ```ts * import { createClient, http, parseUnits } from 'viem' * import { privateKeyToAccount } from 'viem/accounts' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * account: privateKeyToAccount('0x...'), * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const hash = await Actions.dex.sell(client, { * amountIn: parseUnits('100', 6), * minAmountOut: parseUnits('95', 6), * tokenIn: '0x20c...11', * tokenOut: '0x20c...20', * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction hash. */ export declare function sell(client: Client, parameters: sell.Parameters): Promise; export declare namespace sell { type Parameters = WriteParameters & Args; type Args = { /** Amount of tokenIn to sell. */ amountIn: bigint; /** Minimum amount of tokenOut to receive. */ minAmountOut: bigint; /** Address of the token to sell. */ tokenIn: Address; /** Address of the token to receive. */ tokenOut: Address; }; type ReturnValue = WriteContractReturnType; type ErrorType = BaseErrorType; /** @internal */ function inner(action: action, client: Client, parameters: sell.Parameters): Promise>; /** * Defines a call to the `swapExactAmountIn` function. * * Can be passed as a parameter to: * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls * * @example * ```ts * import { createClient, http, parseUnits, walletActions } from 'viem' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }).extend(walletActions) * * const { result } = await client.sendCalls({ * calls: [ * Actions.dex.sell.call({ * amountIn: parseUnits('100', 6), * minAmountOut: parseUnits('95', 6), * tokenIn: '0x20c0...beef', * tokenOut: '0x20c0...babe', * }), * ] * }) * ``` * * @param args - Arguments. * @returns The call. */ function call(args: Args): { abi: [{ readonly name: "swapExactAmountIn"; readonly type: "function"; readonly stateMutability: "nonpayable"; readonly inputs: readonly [{ readonly type: "address"; readonly name: "tokenIn"; }, { readonly type: "address"; readonly name: "tokenOut"; }, { readonly type: "uint128"; readonly name: "amountIn"; }, { readonly type: "uint128"; readonly name: "minAmountOut"; }]; readonly outputs: readonly [{ readonly type: "uint128"; readonly name: "amountOut"; }]; }]; functionName: "swapExactAmountIn"; } & { args: readonly [tokenIn: `0x${string}`, tokenOut: `0x${string}`, amountIn: bigint, minAmountOut: bigint]; } & { address: Address; } & { data: import("../../index.js").Hex; to: Address; }; } /** * Sells a specific amount of tokens. * * @example * ```ts * import { createClient, http, parseUnits } from 'viem' * import { privateKeyToAccount } from 'viem/accounts' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * account: privateKeyToAccount('0x...'), * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const result = await Actions.dex.sellSync(client, { * amountIn: parseUnits('100', 6), * minAmountOut: parseUnits('95', 6), * tokenIn: '0x20c...11', * tokenOut: '0x20c...20', * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction receipt. */ export declare function sellSync(client: Client, parameters: sellSync.Parameters): Promise; export declare namespace sellSync { type Parameters = sell.Parameters; type Args = sell.Args; type ReturnValue = Compute<{ /** Transaction receipt. */ receipt: TransactionReceipt; }>; type ErrorType = BaseErrorType; } /** * Watches for flip order placed events. * * @example * ```ts * import { createClient, http } from 'viem' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const unwatch = Actions.dex.watchFlipOrderPlaced(client, { * onFlipOrderPlaced: (args, log) => { * console.log('Flip order placed:', args) * }, * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns A function to unsubscribe from the event. */ export declare function watchFlipOrderPlaced(client: Client, parameters: watchFlipOrderPlaced.Parameters): import("../../actions/public/watchContractEvent.js").WatchContractEventReturnType; export declare namespace watchFlipOrderPlaced { type Args = GetEventArgs; type Log = viem_Log, true>; type Parameters = UnionOmit, 'abi' | 'address' | 'batch' | 'eventName' | 'onLogs' | 'strict'> & { /** Address of the maker to filter events. */ maker?: Address | undefined; /** Callback to invoke when a flip order is placed. */ onFlipOrderPlaced: (args: Args, log: Log) => void; /** Address of the token to filter events. */ token?: Address | undefined; }; } /** * Watches for order cancelled events. * * @example * ```ts * import { createClient, http } from 'viem' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const unwatch = Actions.dex.watchOrderCancelled(client, { * onOrderCancelled: (args, log) => { * console.log('Order cancelled:', args) * }, * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns A function to unsubscribe from the event. */ export declare function watchOrderCancelled(client: Client, parameters: watchOrderCancelled.Parameters): import("../../actions/public/watchContractEvent.js").WatchContractEventReturnType; export declare namespace watchOrderCancelled { type Args = GetEventArgs; type Log = viem_Log, true>; type Parameters = UnionOmit, 'abi' | 'address' | 'batch' | 'eventName' | 'onLogs' | 'strict'> & { /** Callback to invoke when an order is cancelled. */ onOrderCancelled: (args: Args, log: Log) => void; /** Order ID to filter events. */ orderId?: bigint | undefined; }; } /** * Watches for order filled events. * * @example * ```ts * import { createClient, http } from 'viem' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const unwatch = Actions.dex.watchOrderFilled(client, { * onOrderFilled: (args, log) => { * console.log('Order filled:', args) * }, * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns A function to unsubscribe from the event. */ export declare function watchOrderFilled(client: Client, parameters: watchOrderFilled.Parameters): import("../../actions/public/watchContractEvent.js").WatchContractEventReturnType; export declare namespace watchOrderFilled { type Args = GetEventArgs; type Log = viem_Log, true>; type Parameters = UnionOmit, 'abi' | 'address' | 'batch' | 'eventName' | 'onLogs' | 'strict'> & { /** Address of the maker to filter events. */ maker?: Address | undefined; /** Callback to invoke when an order is filled. */ onOrderFilled: (args: Args, log: Log) => void; /** Order ID to filter events. */ orderId?: bigint | undefined; /** Address of the taker to filter events. */ taker?: Address | undefined; }; } /** * Watches for order placed events. * * @example * ```ts * import { createClient, http } from 'viem' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const unwatch = Actions.dex.watchOrderPlaced(client, { * onOrderPlaced: (args, log) => { * console.log('Order placed:', args) * }, * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns A function to unsubscribe from the event. */ export declare function watchOrderPlaced(client: Client, parameters: watchOrderPlaced.Parameters): import("../../actions/public/watchContractEvent.js").WatchContractEventReturnType; export declare namespace watchOrderPlaced { type Args = GetEventArgs; type Log = viem_Log, true>; type Parameters = UnionOmit, 'abi' | 'address' | 'batch' | 'eventName' | 'onLogs' | 'strict'> & { /** Address of the maker to filter events. */ maker?: Address | undefined; /** Callback to invoke when an order is placed. */ onOrderPlaced: (args: Args, log: Log) => void; /** Address of the token to filter events. */ token?: Address | undefined; }; } /** * Withdraws tokens from the DEX to the caller's wallet. * * @example * ```ts * import { createClient, http } from 'viem' * import { privateKeyToAccount } from 'viem/accounts' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * account: privateKeyToAccount('0x...'), * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const hash = await Actions.dex.withdraw(client, { * amount: 100n, * token: '0x20c...11', * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction hash. */ export declare function withdraw(client: Client, parameters: withdraw.Parameters): Promise; export declare namespace withdraw { type Parameters = WriteParameters & Args; type Args = { /** Amount to withdraw. */ amount: bigint; /** Address of the token to withdraw. */ token: Address; }; type ReturnValue = WriteContractReturnType; type ErrorType = BaseErrorType; /** @internal */ function inner(action: action, client: Client, parameters: withdraw.Parameters): Promise>; /** * Defines a call to the `withdraw` function. * * Can be passed as a parameter to: * - [`estimateContractGas`](https://viem.sh/docs/contract/estimateContractGas): estimate the gas cost of the call * - [`simulateContract`](https://viem.sh/docs/contract/simulateContract): simulate the call * - [`sendCalls`](https://viem.sh/docs/actions/wallet/sendCalls): send multiple calls * * @example * ```ts * import { createClient, http, parseUnits, walletActions } from 'viem' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }).extend(walletActions) * * const { result } = await client.sendCalls({ * calls: [ * Actions.dex.withdraw.call({ * amount: parseUnits('100', 6), * token: '0x20c0...beef', * }), * ] * }) * ``` * * @param args - Arguments. * @returns The call. */ function call(args: Args): { abi: [{ readonly name: "withdraw"; readonly type: "function"; readonly stateMutability: "nonpayable"; readonly inputs: readonly [{ readonly type: "address"; readonly name: "token"; }, { readonly type: "uint128"; readonly name: "amount"; }]; readonly outputs: readonly []; }]; functionName: "withdraw"; } & { args: readonly [token: `0x${string}`, amount: bigint]; } & { address: Address; } & { data: import("../../index.js").Hex; to: Address; }; } /** * Withdraws tokens from the DEX to the caller's wallet. * * @example * ```ts * import { createClient, http } from 'viem' * import { privateKeyToAccount } from 'viem/accounts' * import { tempo } from 'viem/chains' * import { Actions } from 'viem/tempo' * * const client = createClient({ * account: privateKeyToAccount('0x...'), * chain: tempo.extend({ feeToken: '0x20c0000000000000000000000000000000000001' }) * transport: http(), * }) * * const result = await Actions.dex.withdrawSync(client, { * amount: 100n, * token: '0x20c...11', * }) * ``` * * @param client - Client. * @param parameters - Parameters. * @returns The transaction receipt. */ export declare function withdrawSync(client: Client, parameters: withdrawSync.Parameters): Promise; export declare namespace withdrawSync { type Parameters = withdraw.Parameters; type Args = withdraw.Args; type ReturnValue = Compute<{ /** Transaction receipt. */ receipt: TransactionReceipt; }>; type ErrorType = BaseErrorType; } export {}; //# sourceMappingURL=dex.d.ts.map