Skip to content

Commit a8bf4b2

Browse files
committed
Use reserved funds payout calculation logic in Audino and simplify Fortune calculations
1 parent 0ddfd39 commit a8bf4b2

File tree

2 files changed

+4
-14
lines changed

2 files changed

+4
-14
lines changed

packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/audino-payouts-calculator.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { EscrowClient, EscrowUtils } from '@human-protocol/sdk';
1+
import { EscrowClient } from '@human-protocol/sdk';
22
import { Injectable } from '@nestjs/common';
33
import type { OverrideProperties } from 'type-fest';
44

@@ -43,10 +43,8 @@ export class AudinoPayoutsCalculator implements EscrowPayoutsCalculator {
4343
if (annotations.jobs.length === 0 || annotations.results.length === 0) {
4444
throw new Error('Invalid annotation meta');
4545
}
46-
47-
const escrowData = await EscrowUtils.getEscrow(chainId, escrowAddress);
48-
const jobBountyValue =
49-
BigInt(escrowData.totalFundedAmount) / BigInt(annotations.jobs.length);
46+
const reservedFunds = await escrowClient.getReservedFunds(escrowAddress);
47+
const jobBountyValue = reservedFunds / BigInt(annotations.jobs.length);
5048

5149
const workersBounties = new Map<string, bigint>();
5250
for (const job of annotations.jobs) {

packages/apps/reputation-oracle/server/src/modules/escrow-completion/payouts-calculation/fortune-payouts-calculator.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { EscrowClient } from '@human-protocol/sdk';
22
import { Injectable } from '@nestjs/common';
3-
import { ethers } from 'ethers';
43
import type { OverrideProperties } from 'type-fest';
54

65
import { FortuneFinalResult, FortuneManifest } from '@/common/types';
@@ -42,14 +41,7 @@ export class FortunePayoutsCalculator implements EscrowPayoutsCalculator {
4241
.map((item) => item.workerAddress);
4342

4443
const reservedFunds = await escrowClient.getReservedFunds(escrowAddress);
45-
const tokenAddress = await escrowClient.getTokenAddress(escrowAddress);
46-
const tokenDecimals = await this.web3Service.getTokenDecimals(
47-
chainId,
48-
tokenAddress,
49-
);
50-
const payoutAmount =
51-
ethers.parseUnits(reservedFunds, tokenDecimals) /
52-
BigInt(recipients.length);
44+
const payoutAmount = reservedFunds / BigInt(recipients.length);
5345

5446
return recipients.map((recipient) => ({
5547
address: recipient,

0 commit comments

Comments
 (0)