Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add skip participants with too low balance. Closes #42 #46

Merged
merged 3 commits into from
Dec 6, 2024

Conversation

juliangruber
Copy link
Member

Closes #42

if (amount === 0) return
const totalScheduledRewards =
(await ie.rewardsScheduledFor(address)) + amount
if (totalScheduledRewards >= 0.1e18) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the following would be easier to read:

Suggested change
if (totalScheduledRewards >= 0.1e18) {
if (totalScheduledRewards >= 0.1 * 1e18) {

Do you have any concerns about comparing a BigInt value against a float value and potentially losing precision?

A possible solution that avoids the problem:

Suggested change
if (totalScheduledRewards >= 0.1e18) {
if (totalScheduledRewards >= /* 0.1 FIL */ 10n ** 18n / 10n) {

But maybe this is not an issue.

❯ node                                
Welcome to Node.js v20.11.1.
Type ".help" for more information.
> 10n ** 18n / 10n
100000000000000000n
> 0.1e18
100000000000000000
> 

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't have an opinion on this, as the results are the same and for me the current version is easiest to read. What do you prefer?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find 0.1 * 1e18 easier to read than 0.1e18 - I have to think a bit to decipher what 0.1e18 means.

Adding a code comment explaining the threshold is 0.1 FIL is probably the best solution, as it does not require any knowledge about attoFIL being 1 18 .

Anyhow, this is a detail not worth bikeshedding. Choose the option you prefer yourself!

@juliangruber juliangruber force-pushed the add/skip-amount-too-low branch from c6dbd44 to 7e6dfb4 Compare December 6, 2024 13:42
@juliangruber juliangruber requested a review from bajtos December 6, 2024 13:45
if (amount === 0) return
const totalScheduledRewards =
(await ie.rewardsScheduledFor(address)) + amount
if (totalScheduledRewards >= 0.1e18) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find 0.1 * 1e18 easier to read than 0.1e18 - I have to think a bit to decipher what 0.1e18 means.

Adding a code comment explaining the threshold is 0.1 FIL is probably the best solution, as it does not require any knowledge about attoFIL being 1 18 .

Anyhow, this is a detail not worth bikeshedding. Choose the option you prefer yourself!

@juliangruber
Copy link
Member Author

Cool, I've changed it to 0.1 * 1e18. I decided not to add the comment saying that it's 0.1 FIL, because in ethereum style development the constant 1e18 is common knowledge.

@juliangruber juliangruber merged commit f02066c into main Dec 6, 2024
6 checks passed
@juliangruber juliangruber deleted the add/skip-amount-too-low branch December 6, 2024 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve financial efficiency
2 participants