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

feat/new-fee-column #163

Closed
2 changes: 1 addition & 1 deletion src/helpers/fee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Decimal from "decimal.js";

export function generateFeeString(reward: number | Decimal | undefined, feeRate: number | Decimal | undefined) {
if (!reward || !feeRate) return "-";
const feeRateDecimal = new Decimal(1).minus(new Decimal(feeRate));
const feeRateDecimal = new Decimal(100).minus(new Decimal(feeRate)).div(100);
const originalReward = new Decimal(reward).div(feeRateDecimal);
const fee = originalReward.minus(new Decimal(reward));
return fee.toFixed(2);
Expand Down
2 changes: 1 addition & 1 deletion src/parser/github-comment-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ export class GithubCommentModule implements Module {
</h6>
</b>
</summary>
${result.feeRate !== undefined ? `<h6>⚠️ ${new Decimal(result.feeRate).mul(100)}% fee rate has been applied. Consider using the&nbsp;<a href="https://dao.ubq.fi/dollar" target="_blank" rel="noopener">Ubiquity Dollar</a>&nbsp;for no fees.</h6>` : ""}
${result.feeRate !== undefined ? `<h6>⚠️ ${result.feeRate}% fee rate has been applied. Consider using the&nbsp;<a href="https://dao.ubq.fi/dollar" target="_blank" rel="noopener">Ubiquity Dollar</a>&nbsp;for no fees.</h6>` : ""}
gentlementlegen marked this conversation as resolved.
Show resolved Hide resolved
<h6>Contributions Overview</h6>
<table>
<thead>
Expand Down
2 changes: 1 addition & 1 deletion src/parser/permit-generation-module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ export class PermitGenerationModule implements Module {
permitFeeAmountDecimal = permitFeeAmountDecimal.add(new Decimal(rewardResult.total).minus(totalAfterFee));
// subtract fees
result[key].total = Number(totalAfterFee.toFixed(2));
result[key].feeRate = new Decimal(env.PERMIT_FEE_RATE).div(100).toNumber();
result[key].feeRate = new Decimal(env.PERMIT_FEE_RATE).toNumber();
if (result[key].task) {
result[key].task.reward = Number(new Decimal(result[key].task.reward).mul(feeRateDecimal).toFixed(2));
}
Expand Down
8 changes: 4 additions & 4 deletions tests/fees.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe("GithubCommentModule Fee Tests", () => {
reward: 50, // Example value
multiplier: 1.5, // Example value
},
feeRate: 0.2, // This implies a 5% fee
feeRate: 20, // This implies a 20% fee
permitUrl: "https://pay.ubq.fi", // Example URL
userId: 12345, // Example user ID
evaluationCommentHtml: "",
Expand All @@ -88,7 +88,7 @@ describe("GithubCommentModule Fee Tests", () => {
' "reward": 50,\n' +
' "multiplier": 1.5\n' +
" },\n" +
' "feeRate": 0.2,\n' +
' "feeRate": 20,\n' +
' "permitUrl": "https://pay.ubq.fi",\n' +
' "userId": 12345\n' +
" }\n" +
Expand All @@ -106,7 +106,7 @@ describe("GithubCommentModule Fee Tests", () => {
reward: 50, // Example value
multiplier: 1.5, // Example value
},
feeRate: 0.2, // This implies a 5% fee
feeRate: 20, // This implies a 20% fee
permitUrl: "https://pay.ubq.fi", // Example URL
userId: 12345, // Example user ID
evaluationCommentHtml: "",
Expand All @@ -131,7 +131,7 @@ describe("GithubCommentModule Fee Tests", () => {
' "reward": 50,\n' +
' "multiplier": 1.5\n' +
" },\n" +
' "feeRate": 0.2,\n' +
' "feeRate": 20,\n' +
' "permitUrl": "https://pay.ubq.fi",\n' +
' "userId": 12345\n' +
" }\n" +
Expand Down
Loading