viem
Version:
1,573 lines (1,572 loc) • 105 kB
text/typescript
import type { Account } from '../accounts/types.js'
import type { Client } from '../clients/createClient.js'
import type { Transport } from '../clients/transports/createTransport.js'
import type { Chain } from '../types/chain.js'
import * as ammActions from './actions/amm.js'
import * as dexActions from './actions/dex.js'
import * as faucetActions from './actions/faucet.js'
import * as feeActions from './actions/fee.js'
import * as policyActions from './actions/policy.js'
import * as rewardActions from './actions/reward.js'
import * as tokenActions from './actions/token.js'
export type Decorator<
chain extends Chain | undefined = Chain | undefined,
account extends Account | undefined = Account | undefined,
> = {
amm: {
/**
* Gets the reserves for a liquidity pool.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* chain: tempo({ feeToken: '0x20c...001' }),
* transport: http(),
* }).extend(tempoActions())
*
* const pool = await client.amm.getPool({
* userToken: '0x...',
* validatorToken: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The pool reserves.
*/
getPool: (
parameters: ammActions.getPool.Parameters,
) => Promise<ammActions.getPool.ReturnValue>
/**
* Gets the LP token balance for an account in a specific pool.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const poolId = await client.amm.getPoolId({
* userToken: '0x...',
* validatorToken: '0x...',
* })
*
* const balance = await client.amm.getLiquidityBalance({
* poolId,
* address: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The LP token balance.
*/
getLiquidityBalance: (
parameters: ammActions.getLiquidityBalance.Parameters,
) => Promise<ammActions.getLiquidityBalance.ReturnValue>
/**
* Removes liquidity from a pool.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.amm.burn({
* userToken: '0x...',
* validatorToken: '0x...',
* liquidity: 50n,
* to: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
burn: (
parameters: ammActions.burn.Parameters<chain, account>,
) => Promise<ammActions.burn.ReturnValue>
/**
* Removes liquidity from a pool and waits for confirmation.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const { receipt, ...result } = await client.amm.burnSync({
* userToken: '0x...',
* validatorToken: '0x...',
* liquidity: 50n,
* to: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
burnSync: (
parameters: ammActions.burnSync.Parameters<chain, account>,
) => Promise<ammActions.burnSync.ReturnValue>
/**
* Adds liquidity to a pool.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.amm.mint({
* userTokenAddress: '0x...',
* validatorTokenAddress: '0x...',
* validatorTokenAmount: 100n,
* to: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
mint: (
parameters: ammActions.mint.Parameters<chain, account>,
) => Promise<ammActions.mint.ReturnValue>
/**
* Adds liquidity to a pool.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.amm.mintSync({
* userTokenAddress: '0x...',
* validatorTokenAddress: '0x...',
* validatorTokenAmount: 100n,
* to: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
mintSync: (
parameters: ammActions.mintSync.Parameters<chain, account>,
) => Promise<ammActions.mintSync.ReturnValue>
/**
* Swaps tokens during a rebalance operation.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.amm.rebalanceSwap({
* userToken: '0x...',
* validatorToken: '0x...',
* amountOut: 100n,
* to: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
rebalanceSwap: (
parameters: ammActions.rebalanceSwap.Parameters<chain, account>,
) => Promise<ammActions.rebalanceSwap.ReturnValue>
/**
* Swaps tokens during a rebalance operation and waits for confirmation.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const { receipt, ...result } = await client.amm.rebalanceSwapSync({
* userToken: '0x...',
* validatorToken: '0x...',
* amountOut: 100n,
* to: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
rebalanceSwapSync: (
parameters: ammActions.rebalanceSwapSync.Parameters<chain, account>,
) => Promise<ammActions.rebalanceSwapSync.ReturnValue>
/**
* Watches for burn (liquidity removal) events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.amm.watchBurn({
* onBurn: (args, log) => {
* console.log('Liquidity removed:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchBurn: (parameters: ammActions.watchBurn.Parameters) => () => void
/**
* Watches for liquidity mint events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.amm.watchMint({
* onMint: (args, log) => {
* console.log('Liquidity added:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchMint: (parameters: ammActions.watchMint.Parameters) => () => void
/**
* Watches for rebalance swap events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.amm.watchRebalanceSwap({
* onRebalanceSwap: (args, log) => {
* console.log('Rebalance swap:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchRebalanceSwap: (
parameters: ammActions.watchRebalanceSwap.Parameters,
) => () => void
}
dex: {
/**
* Buys a specific amount of tokens.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.dex.buy({
* tokenIn: '0x20c...11',
* tokenOut: '0x20c...20',
* amountOut: 100n,
* maxAmountIn: 105n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
buy: (
parameters: dexActions.buy.Parameters<chain, account>,
) => Promise<dexActions.buy.ReturnValue>
/**
* Buys a specific amount of tokens.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.dex.buySync({
* tokenIn: '0x20c...11',
* tokenOut: '0x20c...20',
* amountOut: 100n,
* maxAmountIn: 105n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt.
*/
buySync: (
parameters: dexActions.buySync.Parameters<chain, account>,
) => Promise<dexActions.buySync.ReturnValue>
/**
* Cancels an order from the orderbook.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.dex.cancel({
* orderId: 123n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
cancel: (
parameters: dexActions.cancel.Parameters<chain, account>,
) => Promise<dexActions.cancel.ReturnValue>
/**
* Cancels an order from the orderbook.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.dex.cancelSync({
* orderId: 123n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
cancelSync: (
parameters: dexActions.cancelSync.Parameters<chain, account>,
) => Promise<dexActions.cancelSync.ReturnValue>
/**
* Cancels a stale order from the orderbook.
*
* A stale order is one where the maker has been blacklisted by a TIP-403 policy.
* Anyone can cancel stale orders.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.dex.cancelStale({
* orderId: 123n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
cancelStale: (
parameters: dexActions.cancelStale.Parameters<chain, account>,
) => Promise<dexActions.cancelStale.ReturnValue>
/**
* Cancels a stale order from the orderbook and waits for confirmation.
*
* A stale order is one where the maker has been blacklisted by a TIP-403 policy.
* Anyone can cancel stale orders.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.dex.cancelStaleSync({
* orderId: 123n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
cancelStaleSync: (
parameters: dexActions.cancelStaleSync.Parameters<chain, account>,
) => Promise<dexActions.cancelStaleSync.ReturnValue>
/**
* Creates a new trading pair on the DEX.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.dex.createPair({
* base: '0x20c...11',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
createPair: (
parameters: dexActions.createPair.Parameters<chain, account>,
) => Promise<dexActions.createPair.ReturnValue>
/**
* Creates a new trading pair on the DEX.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.dex.createPairSync({
* base: '0x20c...11',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
createPairSync: (
parameters: dexActions.createPairSync.Parameters<chain, account>,
) => Promise<dexActions.createPairSync.ReturnValue>
/**
* Gets a user's token balance on the DEX.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const balance = await client.dex.getBalance({
* account: '0x...',
* token: '0x20c...11',
* })
* ```
*
* @param parameters - Parameters.
* @returns The user's token balance on the DEX.
*/
getBalance: (
parameters: dexActions.getBalance.Parameters<account>,
) => Promise<dexActions.getBalance.ReturnValue>
/**
* Gets the quote for buying a specific amount of tokens.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const amountIn = await client.dex.getBuyQuote({
* tokenIn: '0x20c...11',
* tokenOut: '0x20c...20',
* amountOut: 100n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The amount of tokenIn needed to buy the specified amountOut.
*/
getBuyQuote: (
parameters: dexActions.getBuyQuote.Parameters,
) => Promise<dexActions.getBuyQuote.ReturnValue>
/**
* Gets an order's details from the orderbook.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const order = await client.dex.getOrder({
* orderId: 123n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The order details.
*/
getOrder: (
parameters: dexActions.getOrder.Parameters,
) => Promise<dexActions.getOrder.ReturnValue>
/**
* Gets the price level information at a specific tick.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions, Tick } from 'tempo.ts/viem'
*
* const client = createClient({
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const level = await client.dex.getTickLevel({
* base: '0x20c...11',
* tick: Tick.fromPrice('1.001'),
* isBid: true,
* })
* ```
*
* @param parameters - Parameters.
* @returns The price level information.
*/
getTickLevel: (
parameters: dexActions.getTickLevel.Parameters,
) => Promise<dexActions.getTickLevel.ReturnValue>
/**
* Gets the quote for selling a specific amount of tokens.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const amountOut = await client.dex.getSellQuote({
* tokenIn: '0x20c...11',
* tokenOut: '0x20c...20',
* amountIn: 100n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The amount of tokenOut received for selling the specified amountIn.
*/
getSellQuote: (
parameters: dexActions.getSellQuote.Parameters,
) => Promise<dexActions.getSellQuote.ReturnValue>
/**
* Places a limit order on the orderbook.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions, Tick } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.dex.place({
* token: '0x20c...11',
* amount: 100n,
* type: 'buy',
* tick: Tick.fromPrice('0.99'),
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
place: (
parameters: dexActions.place.Parameters<chain, account>,
) => Promise<dexActions.place.ReturnValue>
/**
* Places a limit order on the orderbook.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions, Tick } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.dex.placeSync({
* token: '0x20c...11',
* amount: 100n,
* type: 'buy',
* tick: Tick.fromPrice('0.99'),
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
placeSync: (
parameters: dexActions.placeSync.Parameters<chain, account>,
) => Promise<dexActions.placeSync.ReturnValue>
/**
* Places a flip order that automatically flips when filled.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions, Tick } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.dex.placeFlip({
* token: '0x20c...11',
* amount: 100n,
* type: 'buy',
* tick: Tick.fromPrice('0.99'),
* flipTick: Tick.fromPrice('1.01'),
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
placeFlip: (
parameters: dexActions.placeFlip.Parameters<chain, account>,
) => Promise<dexActions.placeFlip.ReturnValue>
/**
* Places a flip order that automatically flips when filled.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions, Tick } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.dex.placeFlipSync({
* token: '0x20c...11',
* amount: 100n,
* type: 'buy',
* tick: Tick.fromPrice('0.99'),
* flipTick: Tick.fromPrice('1.01'),
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
placeFlipSync: (
parameters: dexActions.placeFlipSync.Parameters<chain, account>,
) => Promise<dexActions.placeFlipSync.ReturnValue>
/**
* Sells a specific amount of tokens.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.dex.sell({
* tokenIn: '0x20c...11',
* tokenOut: '0x20c...20',
* amountIn: 100n,
* minAmountOut: 95n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
sell: (
parameters: dexActions.sell.Parameters<chain, account>,
) => Promise<dexActions.sell.ReturnValue>
/**
* Sells a specific amount of tokens.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.dex.sellSync({
* tokenIn: '0x20c...11',
* tokenOut: '0x20c...20',
* amountIn: 100n,
* minAmountOut: 95n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt.
*/
sellSync: (
parameters: dexActions.sellSync.Parameters<chain, account>,
) => Promise<dexActions.sellSync.ReturnValue>
/**
* 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 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.dex.withdraw({
* token: '0x20c...11',
* amount: 100n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
withdraw: (
parameters: dexActions.withdraw.Parameters<chain, account>,
) => Promise<dexActions.withdraw.ReturnValue>
/**
* 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 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.dex.withdrawSync({
* token: '0x20c...11',
* amount: 100n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt.
*/
withdrawSync: (
parameters: dexActions.withdrawSync.Parameters<chain, account>,
) => Promise<dexActions.withdrawSync.ReturnValue>
/**
* Watches for flip order placed events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.dex.watchFlipOrderPlaced({
* onFlipOrderPlaced: (args, log) => {
* console.log('Flip order placed:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchFlipOrderPlaced: (
parameters: dexActions.watchFlipOrderPlaced.Parameters,
) => () => void
/**
* Watches for order cancelled events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.dex.watchOrderCancelled({
* onOrderCancelled: (args, log) => {
* console.log('Order cancelled:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchOrderCancelled: (
parameters: dexActions.watchOrderCancelled.Parameters,
) => () => void
/**
* Watches for order filled events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.dex.watchOrderFilled({
* onOrderFilled: (args, log) => {
* console.log('Order filled:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchOrderFilled: (
parameters: dexActions.watchOrderFilled.Parameters,
) => () => void
/**
* Watches for order placed events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.dex.watchOrderPlaced({
* onOrderPlaced: (args, log) => {
* console.log('Order placed:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchOrderPlaced: (
parameters: dexActions.watchOrderPlaced.Parameters,
) => () => void
}
faucet: {
/**
* Funds an account with an initial amount of set token(s)
* on Tempo's testnet.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const hashes = await client.faucet.fund({
* account: '0xdeadbeefdeadbeefdeadbeefdeadbeefdeadbeef',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hashes.
*/
fund: (
parameters: faucetActions.fund.Parameters,
) => Promise<faucetActions.fund.ReturnValue>
}
fee: {
/**
* Gets the user's default fee token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const { address, id } = await client.token.getUserToken()
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
getUserToken: (
...parameters: account extends Account
? [feeActions.getUserToken.Parameters<account>] | []
: [feeActions.getUserToken.Parameters<account>]
) => Promise<feeActions.getUserToken.ReturnValue>
/**
* Sets the user's default fee token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.token.setUserToken({
* token: '0x...',
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns The transaction hash.
*/
setUserToken: (
parameters: feeActions.setUserToken.Parameters<chain, account>,
) => Promise<feeActions.setUserToken.ReturnValue>
/**
* Sets the user's default fee token.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.fee.setUserTokenSync({
* token: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
setUserTokenSync: (
parameters: feeActions.setUserTokenSync.Parameters<chain, account>,
) => Promise<feeActions.setUserTokenSync.ReturnValue>
/**
* Watches for user token set events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.token.watchSetUserToken({
* onUserTokenSet: (args, log) => {
* console.log('User token set:', args)
* },
* })
* ```
*
* @param client - Client.
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchSetUserToken: (
parameters: feeActions.watchSetUserToken.Parameters,
) => () => void
}
policy: {
/**
* Creates a new policy.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.policy.create({
* admin: '0x...',
* type: 'whitelist',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
create: (
parameters: policyActions.create.Parameters<chain, account>,
) => Promise<policyActions.create.ReturnValue>
/**
* Creates a new policy.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.policy.createSync({
* admin: '0x...',
* type: 'whitelist',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
createSync: (
parameters: policyActions.createSync.Parameters<chain, account>,
) => Promise<policyActions.createSync.ReturnValue>
/**
* Sets the admin for a policy.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.policy.setAdmin({
* policyId: 2n,
* admin: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
setAdmin: (
parameters: policyActions.setAdmin.Parameters<chain, account>,
) => Promise<policyActions.setAdmin.ReturnValue>
/**
* Sets the admin for a policy.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.policy.setAdminSync({
* policyId: 2n,
* admin: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
setAdminSync: (
parameters: policyActions.setAdminSync.Parameters<chain, account>,
) => Promise<policyActions.setAdminSync.ReturnValue>
/**
* Modifies a policy whitelist.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.policy.modifyWhitelist({
* policyId: 2n,
* address: '0x...',
* allowed: true,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
modifyWhitelist: (
parameters: policyActions.modifyWhitelist.Parameters<chain, account>,
) => Promise<policyActions.modifyWhitelist.ReturnValue>
/**
* Modifies a policy whitelist.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.policy.modifyWhitelistSync({
* policyId: 2n,
* address: '0x...',
* allowed: true,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
modifyWhitelistSync: (
parameters: policyActions.modifyWhitelistSync.Parameters<chain, account>,
) => Promise<policyActions.modifyWhitelistSync.ReturnValue>
/**
* Modifies a policy blacklist.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const hash = await client.policy.modifyBlacklist({
* policyId: 2n,
* address: '0x...',
* restricted: true,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction hash.
*/
modifyBlacklist: (
parameters: policyActions.modifyBlacklist.Parameters<chain, account>,
) => Promise<policyActions.modifyBlacklist.ReturnValue>
/**
* Modifies a policy blacklist.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { privateKeyToAccount } from 'viem/accounts'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* account: privateKeyToAccount('0x...'),
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const result = await client.policy.modifyBlacklistSync({
* policyId: 2n,
* address: '0x...',
* restricted: true,
* })
* ```
*
* @param parameters - Parameters.
* @returns The transaction receipt and event data.
*/
modifyBlacklistSync: (
parameters: policyActions.modifyBlacklistSync.Parameters<chain, account>,
) => Promise<policyActions.modifyBlacklistSync.ReturnValue>
/**
* Gets policy data.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const data = await client.policy.getData({
* policyId: 2n,
* })
* ```
*
* @param parameters - Parameters.
* @returns The policy data.
*/
getData: (
parameters: policyActions.getData.Parameters,
) => Promise<policyActions.getData.ReturnValue>
/**
* Checks if a user is authorized by a policy.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const authorized = await client.policy.isAuthorized({
* policyId: 2n,
* user: '0x...',
* })
* ```
*
* @param parameters - Parameters.
* @returns Whether the user is authorized.
*/
isAuthorized: (
parameters: policyActions.isAuthorized.Parameters,
) => Promise<policyActions.isAuthorized.ReturnValue>
/**
* Watches for policy creation events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.policy.watchCreate({
* onPolicyCreated: (args, log) => {
* console.log('Policy created:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchCreate: (
parameters: policyActions.watchCreate.Parameters,
) => () => void
/**
* Watches for policy admin update events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.policy.watchAdminUpdated({
* onAdminUpdated: (args, log) => {
* console.log('Policy admin updated:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchAdminUpdated: (
parameters: policyActions.watchAdminUpdated.Parameters,
) => () => void
/**
* Watches for whitelist update events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.policy.watchWhitelistUpdated({
* onWhitelistUpdated: (args, log) => {
* console.log('Whitelist updated:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchWhitelistUpdated: (
parameters: policyActions.watchWhitelistUpdated.Parameters,
) => () => void
/**
* Watches for blacklist update events.
*
* @example
* ```ts
* import { createClient, http } from 'viem'
* import { tempo } from 'tempo.ts/chains'
* import { tempoActions } from 'tempo.ts/viem'
*
* const client = createClient({
* chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' })
* transport: http(),
* }).extend(tempoActions())
*
* const unwatch = client.policy.watchBlacklistUpdated({
* onBlacklistUpdated: (args, log) => {
* console.log('Blacklist updated:', args)
* },
* })
* ```
*
* @param parameters - Parameters.
* @returns A function to unsubscribe from the event.
*/
watchBlacklistUpdated: (
parameters: policyActions.watchBlacklistUpdated.Parameters,
) => () => void
}
reward: {
/**
* Claims