This repository has been archived by the owner on Sep 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 61
September 2023 Update Adjustments #818
Open
whilefoo
wants to merge
9
commits into
ubiquity:development
Choose a base branch
from
ubiquity-whilefoo:september-update-adjustment
base: development
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
3056bc9
feat: adjustments
whilefoo e344906
feat: rename priceInEth and retrieve decimals for payment token
whilefoo 2df5613
feat: use permitBaseUrl instead of hardcoded
whilefoo 660e205
feat: improve regex
whilefoo 8542538
feat: remove restriction where issue creator will not get reward if t…
whilefoo 31f8e80
fix: wording
whilefoo 87b7273
Merge branch 'development' into september-update-adjustment
whilefoo 5003f80
feat: rename
whilefoo 326b471
Merge remote-tracking branch 'upstream/development' into september-up…
whilefoo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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 |
---|---|---|
|
@@ -12,7 +12,7 @@ import { BigNumber } from "ethers"; | |
export interface CreatorCommentResult { | ||
title: string; | ||
account?: string | undefined; | ||
amountInETH?: Decimal | undefined; | ||
rewardInTokens?: Decimal | undefined; | ||
userId?: string | undefined; | ||
tokenSymbol?: string | undefined; | ||
node_id?: string | undefined; | ||
|
@@ -120,14 +120,14 @@ export const calculateIssueCreatorReward = async (incentivesCalculation: Incenti | |
|
||
const description = await getIssueDescription(incentivesCalculation.issue.number, "html"); | ||
if (!description) { | ||
logger.info(`Skipping to generate a permit url because issue description is empty. description: ${description}`); | ||
return { error: `Skipping to generate a permit url because issue description is empty. description: ${description}` }; | ||
logger.info(`Skipping issue creator reward because issue description is empty. description: ${description}`); | ||
return { error: `Skipping issue creator reward because issue description is empty. description: ${description}` }; | ||
} | ||
logger.info(`Getting the issue description done. description: ${description}`); | ||
const creator = incentivesCalculation.issue.user; | ||
if (creator.type === UserType.Bot || creator.login === incentivesCalculation.issue.assignee) { | ||
logger.info("Issue creator assigneed himself or Bot created this issue."); | ||
return { error: "Issue creator assigneed himself or Bot created this issue." }; | ||
if (creator.type === UserType.Bot) { | ||
logger.info("Skipping issue creator reward because Bot created this issue."); | ||
return { error: "Skipping issue creator reward because Bot created this issue." }; | ||
} | ||
|
||
const result = await generatePermitForComments( | ||
|
@@ -138,8 +138,8 @@ export const calculateIssueCreatorReward = async (incentivesCalculation: Incenti | |
incentivesCalculation.paymentPermitMaxPrice | ||
); | ||
|
||
if (!result || !result.account || !result.amountInETH) { | ||
throw new Error("Failed to generate permit for issue creator because of missing account or amountInETH"); | ||
if (!result || !result.account || !result.rewardInTokens) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think that's as expressive as inBigNumber etc it implies 1e18 format There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's not in 1e18 format, but with decimals like |
||
throw new Error("Failed to generate permit for issue creator because of missing account or rewardInTokens"); | ||
} | ||
|
||
return { | ||
|
@@ -149,7 +149,7 @@ export const calculateIssueCreatorReward = async (incentivesCalculation: Incenti | |
username: creator.login, | ||
reward: [ | ||
{ | ||
priceInEth: result?.amountInETH ?? new Decimal(0), | ||
priceInEth: result?.rewardInTokens ?? new Decimal(0), | ||
account: result?.account, | ||
userId: creator.id, | ||
user: "", | ||
|
@@ -269,7 +269,7 @@ const generatePermitForComments = async ( | |
multiplier: number, | ||
incentives: Incentives, | ||
paymentPermitMaxPrice: number | ||
): Promise<undefined | { account: string; amountInETH: Decimal }> => { | ||
): Promise<undefined | { account: string; rewardInTokens: Decimal }> => { | ||
const logger = getLogger(); | ||
const commentsByNode = await parseComments(comments, ItemsToExclude); | ||
const rewardValue = calculateRewardValue(commentsByNode, incentives); | ||
|
@@ -279,15 +279,15 @@ const generatePermitForComments = async ( | |
} | ||
logger.debug(`Comment parsed for the user: ${user}. comments: ${JSON.stringify(commentsByNode)}, sum: ${rewardValue.sum}`); | ||
const account = await getWalletAddress(user); | ||
const amountInETH = rewardValue.sum.mul(multiplier); | ||
if (amountInETH.gt(paymentPermitMaxPrice)) { | ||
const rewardInTokens = rewardValue.sum.mul(multiplier); | ||
if (rewardInTokens.gt(paymentPermitMaxPrice)) { | ||
logger.info(`Skipping issue creator reward for user ${user} because reward is higher than payment permit max price`); | ||
return; | ||
} | ||
if (account) { | ||
return { account, amountInETH }; | ||
return { account, rewardInTokens }; | ||
} else { | ||
return { account: "0x", amountInETH: new Decimal(0) }; | ||
return { account: "0x", rewardInTokens: new Decimal(0) }; | ||
} | ||
}; | ||
/** | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it makes sense to call this Assignee Reward because task is implicit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We shouldn't change it because it will break backwards compatibility. We need to implement comment metadata first and then we can change format