Skip to main content

RewardLib

Git Source

Author: G9 Software Inc.

Library for calculating auction rewards.

This library uses a parabolic fractional dutch auction (PFDA) to calculate rewards. For more details see https://dev.pooltogether.com/protocol/next/design/draw-auction#parabolic-fractional-dutch-auction-pfda

Functions​

fractionalReward​

Calculates the fractional reward using a Parabolic Fractional Dutch Auction (PFDA) given the elapsed time, auction time, and target sale parameters.

function fractionalReward(
uint48 _elapsedTime,
uint48 _auctionDuration,
UD2x18 _targetTimeFraction,
UD2x18 _targetRewardFraction
) internal pure returns (UD2x18);

Parameters

NameTypeDescription
_elapsedTimeuint48The elapsed time since the start of the auction in seconds
_auctionDurationuint48The auction duration in seconds
_targetTimeFractionUD2x18The target sale time as a fraction of the total auction duration (0.0,1.0]
_targetRewardFractionUD2x18The target fractional sale price

Returns

NameTypeDescription
<none>UD2x18The reward fraction as a UD2x18 fraction

rewards​

Calculates rewards to distribute given the available reserve and completed auction results.

Each auction takes a fraction of the remaining reserve. This means that if the reserve is equal to 100 and the first auction takes 50% and the second takes 50%, then the first reward will be equal to 50 while the second will be 25.

function rewards(Allocation[] memory _allocations, uint256 _reserve) internal pure returns (uint256[] memory);

Parameters

NameTypeDescription
_allocationsAllocation[]Auction results to get rewards for
_reserveuint256Reserve available for the rewards

Returns

NameTypeDescription
<none>uint256[]Rewards in the same order as the auction results they correspond to

reward​

Calculates the reward for the given auction result and available reserve.

If the auction reward recipient is the zero address, no reward will be given.

function reward(UD2x18 _rewardFraction, uint256 _reserve) internal pure returns (uint256);

Parameters

NameTypeDescription
_rewardFractionUD2x18Reward fraction to get reward for
_reserveuint256Reserve available for the reward

Returns

NameTypeDescription
<none>uint256Reward amount

Structs​

Allocation​

Stores the results of an auction.

struct Allocation {
address recipient;
UD2x18 rewardFraction;
}

Properties

NameTypeDescription
recipientaddressThe recipient of the auction awards
rewardFractionUD2x18The fraction of the available rewards to be sent to the recipient