emergencyUnstake
Emergency unstake all staked tokens from a pool without claiming any rewards. Use this when you need to quickly withdraw your stake.
Usage
example.tsx
import { mintclub } from 'mint.club-v2-sdk'
import { useWalletClient } from 'wagmi'
import { base } from 'viem/chains'
function EmergencyUnstakeExample() {
const { data: walletClient } = useWalletClient()
const handleEmergencyUnstake = async () => {
await mintclub
.withWalletClient({
...walletClient,
chain: base,
} as any)
.network('base')
.stake
.emergencyUnstake({
poolId: 0,
onSuccess: (receipt) => {
console.log('Emergency unstake successful!', receipt)
},
onError: (error) => {
console.error('Failed to emergency unstake:', error)
},
})
}
return <button onClick={handleEmergencyUnstake}>Emergency Unstake</button>
}Return Value
Promise<TransactionReceipt>
Returns a promise that resolves to a TransactionReceipt object when the transaction is successful.
Parameters
poolId
- Type:
number
The ID of the staking pool to emergency unstake from.
await mintclub.network('base').stake.emergencyUnstake({
poolId: 0,
})onSignatureRequest (optional)
- Type:
onSignatureRequest?: () => void; - Default:
undefined
Callback function for when the user is requested to sign the transaction.
await mintclub.network('base').stake.emergencyUnstake({
poolId: 0,
onSignatureRequest: () => {
console.log('Please sign the transaction')
},
})onSigned (optional)
- Type:
onSigned?: (txHash: '0x${string}') => void; - Default:
undefined
Callback function for when the user signs the transaction.
await mintclub.network('base').stake.emergencyUnstake({
poolId: 0,
onSigned: (txHash) => {
console.log('Transaction signed:', txHash)
},
})onSuccess (optional)
- Type:
onSuccess?: (receipt: TransactionReceipt) => void; - Default:
undefined
Callback function for when the transaction is successful.
await mintclub.network('base').stake.emergencyUnstake({
poolId: 0,
onSuccess: (receipt) => {
console.log('Emergency unstake successful!', receipt)
},
})onError (optional)
- Type:
onError?: (error: unknown) => void; - Default:
undefined
Callback function for when the transaction fails. This also includes when the user rejects the transaction.
await mintclub.network('base').stake.emergencyUnstake({
poolId: 0,
onError: (error) => {
console.error('Failed to emergency unstake:', error)
},
})