@azuro-org/sdk
Version:
One-stop solution for building betting dApps on the Azuro Protocol.
67 lines (66 loc) • 2.15 kB
TypeScript
import { type Address, type Hex } from 'viem';
import { type ChainId } from '@azuro-org/toolkit';
import { type Bet } from '../../global';
type SubmitProps = {
bets: Array<Pick<Bet, 'tokenId' | 'coreAddress' | 'lpAddress' | 'freebetId' | 'paymaster'> & {
freebetContractAddress?: Address;
}>;
};
type Props = {
chainId?: ChainId;
};
/**
* Redeem winnings from winning or canceled bets.
* Supports both single and batch redemption of bets from the same LP contract.
*
* Handles legacy V2 contracts, freebets, and regular bets.
* Supports both regular wallets and Account Abstraction (AA) wallets.
*
* - Docs: https://gem.azuro.org/hub/apps/sdk/write/useRedeemBet
*
* @example
* import { useBets, useRedeemBet } from '@azuro-org/sdk'
*
* // Bet list component
* const { data, isFetching } = useBets({ filter: { ... } })
* const allBets = data?.pages.flatMap(page => page.bets) || []
*
* // ... Single bet component
* const { submit, isPending, isProcessing } = useRedeemBet()
*
* const handleRedeem = async () => {
* if (isPending || isProcessing || bet.isRedeemed || !bet.isRedeemable) {
* return
* }
*
* await submit({ bets: [ bet ] })
* }
* */
export declare const useRedeemBet: ({ chainId }?: Props) => {
isPending: boolean;
isProcessing: boolean;
data: `0x${string}` | undefined;
error: any;
submit: (props: SubmitProps) => Promise<{
blobGasPrice?: bigint | undefined;
blobGasUsed?: bigint | undefined;
blockHash: import("viem").Hash;
blockNumber: bigint;
blockTimestamp?: bigint | undefined;
contractAddress: Address | null | undefined;
cumulativeGasUsed: bigint;
effectiveGasPrice: bigint;
from: Address;
gasUsed: bigint;
logs: import("viem").Log<bigint, number, false>[];
logsBloom: Hex;
root?: `0x${string}` | undefined;
status: "success" | "reverted";
to: Address | null;
transactionHash: import("viem").Hash;
transactionIndex: number;
type: import("viem").TransactionType;
chainId: number;
}>;
};
export {};