generated from GenerationSoftware/foundry-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
reduce solidity memory usage and run the script in chunks
- Loading branch information
Showing
5 changed files
with
125 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.21; | ||
|
||
import { Vm } from "forge-std/Vm.sol"; | ||
import { TierCalculationLib, SD59x18 } from "pt-v5-prize-pool/PrizePool.sol"; | ||
|
||
struct Params { | ||
uint256 winningRandomNumber; | ||
uint24 lastAwardedDrawId; | ||
address vault; | ||
uint8 tier; | ||
uint32 tierPrizeCount; | ||
SD59x18 tierOdds; | ||
SD59x18 vaultPortion; | ||
uint256 vaultTotalSupplyTwab; | ||
address[] user; | ||
uint256[] userTwab; | ||
} | ||
|
||
struct Winner { | ||
address user; | ||
uint32 prizeIndex; | ||
} | ||
|
||
contract WinnerCalc { | ||
|
||
Winner[] public winners; | ||
|
||
/// @dev pushes winners to the `winners` array based off the prize param info | ||
function checkWin( | ||
uint256 winningRandomNumber, | ||
uint24 lastAwardedDrawId, | ||
address vault, | ||
uint256 vaultTotalSupplyTwab, | ||
SD59x18 vaultPortion, | ||
address user, | ||
uint256 userTwab, | ||
uint8 tier, | ||
SD59x18 tierOdds, | ||
uint32 prizeIndex | ||
) external { | ||
uint256 _userSpecificRandomNumber = TierCalculationLib.calculatePseudoRandomNumber( | ||
lastAwardedDrawId, | ||
vault, | ||
user, | ||
tier, | ||
prizeIndex, | ||
winningRandomNumber | ||
); | ||
if ( | ||
TierCalculationLib.isWinner( | ||
_userSpecificRandomNumber, | ||
userTwab, | ||
vaultTotalSupplyTwab, | ||
vaultPortion, | ||
tierOdds | ||
) | ||
) { | ||
winners.push(Winner({ | ||
user: user, | ||
prizeIndex: prizeIndex | ||
})); | ||
} | ||
} | ||
|
||
function writeResults(Vm vm, string memory outputFilename) external { | ||
vm.writeFile(outputFilename, vm.toString(abi.encode(winners))); | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters