Skip to main content

IPrizeHooks

Git Source

Author: PoolTogether Inc. & G9 Software Inc.

Allows winners to attach smart contract hooks to their prize winnings

Functions

beforeClaimPrize

Triggered before the prize pool claim prize function is called.

function beforeClaimPrize(address winner, uint8 tier, uint32 prizeIndex, uint96 reward, address rewardRecipient)
external
returns (address prizeRecipient, bytes memory data);

Parameters

NameTypeDescription
winneraddressThe user who won the prize and for whom this hook is attached
tieruint8The tier of the prize
prizeIndexuint32The index of the prize in the tier
rewarduint96The reward portion of the prize that will be allocated to the claimer
rewardRecipientaddressThe recipient of the claim reward

Returns

NameTypeDescription
prizeRecipientaddressThe address of the recipient of the prize
databytesArbitrary data that will be passed to the afterClaimPrize hook

afterClaimPrize

Triggered after the prize pool claim prize function is called.

function afterClaimPrize(
address winner,
uint8 tier,
uint32 prizeIndex,
uint256 prize,
address prizeRecipient,
bytes memory data
) external;

Parameters

NameTypeDescription
winneraddressThe user who won the prize and for whom this hook is attached
tieruint8The tier of the prize
prizeIndexuint32The index of the prize
prizeuint256The total size of the prize (not including the claim reward)
prizeRecipientaddressThe recipient of the prize
databytesArbitrary data received from the beforeClaimPrize hook

Structs

PrizeHooks

Defines a hook implementation and instructions on which hooks to call.

struct PrizeHooks {
bool useBeforeClaimPrize;
bool useAfterClaimPrize;
IPrizeHooks implementation;
}

Properties

NameTypeDescription
useBeforeClaimPrizeboolIf true, the vault will call the beforeClaimPrize hook on the implementation
useAfterClaimPrizeboolIf true, the vault will call the afterClaimPrize hook on the implementation
implementationIPrizeHooksThe address of the smart contract implementing the hooks