Skip to content

fix: only refund budget for trx job #76

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

Open
wants to merge 5 commits into
base: feat/society
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 16 additions & 15 deletions contracts/acp/ACPSimple.sol
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ contract ACPSimple is
address(this),
job.budget
);
} else if (oldPhase == PHASE_EVALUATION && phase >= PHASE_COMPLETED) {
} else if ((oldPhase >= PHASE_TRANSACTION && oldPhase <= PHASE_EVALUATION) && phase >= PHASE_COMPLETED) {
_claimBudget(jobId);
}
}
Expand All @@ -210,12 +210,12 @@ contract ACPSimple is
Job storage job = jobs[id];
require(job.budget > job.amountClaimed, "No budget to claim");

job.amountClaimed = job.budget;
uint256 claimableAmount = job.budget - job.amountClaimed;
uint256 evaluatorFee = (claimableAmount * evaluatorFeeBP) / 10000;
uint256 platformFee = (claimableAmount * platformFeeBP) / 10000;
job.amountClaimed = job.budget;

if (job.phase == PHASE_COMPLETED) {
uint256 evaluatorFee = (claimableAmount * evaluatorFeeBP) / 10000;
uint256 platformFee = (claimableAmount * platformFeeBP) / 10000;
if (platformFee > 0) {
paymentToken.safeTransferFrom(
address(this),
Expand Down Expand Up @@ -251,14 +251,16 @@ contract ACPSimple is
"Unable to refund budget"
);

paymentToken.safeTransferFrom(
address(this),
job.client,
claimableAmount
);
emit RefundedBudget(id, job.client, claimableAmount);
if (job.phase >= PHASE_TRANSACTION && claimableAmount > 0) {
paymentToken.safeTransferFrom(
address(this),
job.client,
claimableAmount
);
emit RefundedBudget(id, job.client, claimableAmount);
}

if (job.phase != PHASE_REJECTED) {
if (job.phase != PHASE_REJECTED && job.phase != PHASE_EXPIRED) {
_updateJobPhase(id, PHASE_EXPIRED);
}
}
Expand Down Expand Up @@ -316,10 +318,9 @@ contract ACPSimple is
address account,
Job memory job
) public pure returns (bool) {
return
((job.client == account || job.provider == account) ||
((job.evaluator == account || job.evaluator == address(0)) &&
job.phase == PHASE_EVALUATION));
return ((job.client == account || job.provider == account) ||
((job.evaluator == account || job.evaluator == address(0)) &&
job.phase == PHASE_EVALUATION));
}

function getAllMemos(
Expand Down