diff --git a/src/handlers/comment/handlers/assign.ts b/src/handlers/comment/handlers/assign.ts index e50831a64..02c01a177 100644 --- a/src/handlers/comment/handlers/assign.ts +++ b/src/handlers/comment/handlers/assign.ts @@ -128,13 +128,18 @@ export const assign = async (body: string) => { const comments = issueComments.sort((a: Comment, b: Comment) => new Date(b.created_at).getTime() - new Date(a.created_at).getTime()); const latestComment = comments.length > 0 ? comments[0].body : undefined; if (latestComment && comment.commit != latestComment) { - const { multiplier, reason, bounty } = await getMultiplierInfoToDisplay(payload.sender.login, id?.toString(), issue); + const { multiplier, reason, bounty } = await getMultiplierInfoToDisplay( + payload.sender.login, + id?.toString(), + issue, + config.bountyRewardsCap.issue_assignee + ); return tableComment({ ...comment, multiplier, reason, bounty, isBountyStale, days }) + comment.tips; } return; }; -const getMultiplierInfoToDisplay = async (senderLogin: string, org_id: string, issue: Issue) => { +const getMultiplierInfoToDisplay = async (senderLogin: string, org_id: string, issue: Issue, cap: boolean) => { const { reason, value } = await getWalletMultiplier(senderLogin, org_id); const multiplier = value?.toFixed(2) || "1.00"; @@ -156,6 +161,9 @@ const getMultiplierInfoToDisplay = async (senderLogin: string, org_id: string, i const issueDetailed = bountyInfo(issue); if (issueDetailed.priceLabel) { _bountyToDisplay = (+issueDetailed.priceLabel.substring(7, issueDetailed.priceLabel.length - 4) * value).toString() + " USD"; + if (cap) { + _bountyToDisplay = (+issueDetailed.priceLabel.substring(7, issueDetailed.priceLabel.length - 4)).toString() + " USD" + " [Capped]"; + } } } return { multiplier: _multiplierToDisplay, reason: _reasonToDisplay, bounty: _bountyToDisplay }; diff --git a/src/handlers/payout/action.ts b/src/handlers/payout/action.ts index bd84daf13..4def573ee 100644 --- a/src/handlers/payout/action.ts +++ b/src/handlers/payout/action.ts @@ -26,6 +26,7 @@ export const handleIssueClosed = async () => { payout: { paymentToken, rpc, permitBaseUrl, networkId, privateKey }, mode: { paymentPermitMaxPrice }, accessControl, + bountyRewardsCap: { issue_assignee }, } = getBotConfig(); const logger = getLogger(); const payload = context.payload as Payload; @@ -183,6 +184,12 @@ export const handleIssueClosed = async () => { priceInEth = new Decimal(ethers.utils.formatUnits(bountyAmountAfterPenalty, 18)); } + let labelAmount: Decimal | undefined = undefined; + if (issueDetailed.priceLabel) { + labelAmount = new Decimal(issueDetailed.priceLabel.substring(7, issueDetailed.priceLabel.length - 4)); + } + + priceInEth = issue_assignee && labelAmount !== undefined && priceInEth > labelAmount ? labelAmount : priceInEth; const { txData, payoutUrl } = await generatePermit2Signature(recipient, priceInEth, issue.node_id, assignee.node_id, "ISSUE_ASSIGNEE"); const tokenSymbol = await getTokenSymbol(paymentToken, rpc); const shortenRecipient = shortenEthAddress(recipient, `[ CLAIM ${priceInEth} ${tokenSymbol.toUpperCase()} ]`.length); diff --git a/src/types/config.ts b/src/types/config.ts index 12475bd75..a15c4aca2 100644 --- a/src/types/config.ts +++ b/src/types/config.ts @@ -122,6 +122,7 @@ export type AccessControl = Static; export const BountyRewardsCapSchema = Type.Object({ issue_issuer: Type.Boolean(), issue_collaborator: Type.Boolean(), + issue_assignee: Type.Boolean(), issue_default: Type.Boolean(), review_issuer: Type.Boolean(), review_collaborator: Type.Boolean(), diff --git a/ubiquibot-config-default.json b/ubiquibot-config-default.json index 9a486789b..248c69527 100644 --- a/ubiquibot-config-default.json +++ b/ubiquibot-config-default.json @@ -94,6 +94,7 @@ "bounty-rewards-cap": { "issue_issuer": true, "issue_collaborator": true, + "issue_assignee": true, "issue_default": true, "review_issuer": true, "review_collaborator": true,