Dutch auctions in the Lazy Summer Protocol facilitate efficient reward token sales. When ARKs harvest rewards, RAFT automatically auctions these tokens using a Dutch auction mechanism where prices decline over time until meeting a buyer or reaching the end price.
The auction process is fully automated:
Price declines according to chosen curve
Tokens are purchased or auction concludes
Proceeds are converted to vault tokens to enhance yields
Here's how a typical auction flow looks in code:
Copy // Example auction creation by RAFT
function _startAuction ( address ark , address rewardToken) internal {
uint256 totalTokens = obtainedTokens[ark][rewardToken] +
unsoldTokens[ark][rewardToken];
DutchAuctionLibrary.Auction memory newAuction = _createAuctionWithParams (
IERC20 (rewardToken) ,
IERC20 ( IArk (ark). asset ()) ,
totalTokens ,
address ( this ) ,
arkAuctionParameters[ark][rewardToken]
);
}
Core Auction Functions
Auction Creation :
Copy function createAuction (
IERC20 _auctionToken ,
IERC20 _paymentToken ,
uint256 _duration ,
uint256 _startPrice ,
uint256 _endPrice ,
uint256 _totalTokens ,
Percentage _kickerRewardPercentage ,
address _unsoldTokensRecipient ,
DecayFunctions . DecayType _decayType
) external returns ( uint256 auctionId)
Price Calculation :
Copy function getCurrentPrice ( uint256 _auctionId ) public view returns ( uint256 ) {
return DutchAuctionLibrary. getCurrentPrice (auctions[_auctionId]);
}
Token Purchase :
Copy function buyTokens (
address ark ,
address rewardToken ,
uint256 amount
) external returns ( uint256 paymentAmount) {
DutchAuctionLibrary.Auction storage auction = auctions[ark][rewardToken];
paymentAmount = auction. buyTokens (amount);
// Board payment tokens for yield generation
paymentTokensToBoard[ark][rewardToken] += paymentAmount;
}
Integration with RAFT
The RAFT contract handles auction automation:
Copy function harvestAndStartAuction (
address ark ,
bytes calldata rewardData
) external {
( address [] memory harvestedTokens , ) = _harvest (ark , rewardData);
for ( uint256 i = 0 ; i < harvestedTokens.length; i ++ ) {
_startAuction (ark , harvestedTokens[i]);
}
}
Price Decay Functions
Two decay functions are available:
Copy // Linear decay
function linearDecay (
uint256 initialValue ,
uint256 decayRatePerSecond ,
uint256 decayTimeInSeconds
) internal pure returns ( uint256 )
// Exponential decay
function exponentialDecay (
uint256 initialValue ,
uint256 decayRatePerSecond ,
uint256 decayTimeInSeconds
) internal pure returns ( uint256 )
The chosen decay function determines how price decreases over the auction duration.