amm.useMint
Mints liquidity tokens by providing a token pair. Learn more about the Fee AMM
Usage
ts
import { } from 'wagmi/tempo'
import { } from 'viem'
const = ..()
// Call `mutate` in response to user action (e.g. button click, form submission)
.({
: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
: '0x20c0000000000000000000000000000000000000',
: '0x20c0000000000000000000000000000000000001',
: ('100', 6),
})
.('Liquidity minted:', .?.)
Liquidity minted: 100000000nts
import { createConfig, http } from 'wagmi'
import { tempoTestnet } from 'wagmi/chains'
import { KeyManager, webAuthn } from 'wagmi/tempo'
export const config = createConfig({
connectors: [
webAuthn({
keyManager: KeyManager.localStorage(),
}),
],
chains: [tempoTestnet],
multiInjectedProviderDiscovery: false,
transports: {
[tempoTestnet.id]: http(),
},
})Asynchronous Usage
The example above uses a *Sync variant of the action, that will wait for the transaction to be included before returning.
If you are optimizing for performance, you should use the non-sync amm.mint action and wait for inclusion manually:
ts
import { Hooks } from 'wagmi/tempo'
import { Actions } from 'viem/tempo'
import { parseUnits } from 'viem'
import { useWaitForTransactionReceipt } from 'wagmi'
const mint = Hooks.amm.useMint()
const { data: receipt } = useWaitForTransactionReceipt({ hash: mint.data })
// Call `mutate` in response to user action (e.g. button click, form submission)
mint.mutate({
to: '0x742d35Cc6634C0532925a3b844Bc9e7595f0bEbb',
userTokenAddress: '0x20c0000000000000000000000000000000000000',
validatorTokenAddress: '0x20c0000000000000000000000000000000000001',
validatorTokenAmount: parseUnits('100', 6),
})
if (receipt) {
const { args: { liquidity } }
= Actions.amm.mint.extractEvent(receipt.logs)Return Type
See TanStack Query mutation docs for more info hook return types.
data
See Wagmi Action amm.mint Return Type
mutate/mutateAsync
See Wagmi Action amm.mint Parameters
Parameters
config
Config | undefined
Config to use instead of retrieving from the nearest WagmiProvider.
mutation
See the TanStack Query mutation docs for more info hook parameters.