Submits a cashout order.
ℹ️
You can find more information Here.
Usage
import { getCalculatedCashout, getCashoutTypedData, createCashout } from '@azuro-org/toolkit'
const { id, tokenId } = bet // user's bet
const { calculationId, multiplier, expiredAt } = await getCalculatedCashout({
chainId: 137,
betCoreAddress: '0x...',
account: '0x...',
graphBetId: id,
isLive: false,
})
const typedData = getCashoutTypedData({
chainId: 137,
account: '0x...',
attention: '...',
tokenId,
betCoreAddress: '0x...',
multiplier,
expiredAt,
})
const signature = await walletClient.data.signTypedData(typedData)
const createdOrder = await createCashout({
chainId: 137,
calculationId,
betCoreAddress: '0x...',
attention: '...',
signature,
})
Props
{
chainId: ChainId
calculationId: string // precalculated cashout id from getCalculatedCashout
betCoreAddress: Address | string
attention: string
signature: Hex // signed typed data
}
type ChainId = 100 | 137 | 80002 | 88888 | 88882
import { type Hex, type Address } from 'viem'
Return Value
type CreateCashoutResponse = {
id: string
state: CashoutState
errorMessage?: string
}
enum CashoutState {
Processing = 'PROCESSING',
Accepted = 'ACCEPTED',
Rejected = 'REJECTED',
Open = 'OPEN'
}