Skip to content

Commit

Permalink
Pass taskPrice instead of dealPrice to refund function
Browse files Browse the repository at this point in the history
  • Loading branch information
zguesmi committed May 29, 2024
1 parent 2d62dec commit 1fdd243
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions contracts/beacon/Voucher.sol
Original file line number Diff line number Diff line change
Expand Up @@ -200,9 +200,9 @@ contract Voucher is OwnableUpgradeable, IVoucher {
voucherHub,
iexecPoco,
taskId,
deal.app.price + deal.dataset.price + deal.workerpool.price, // taskPrice
task.dealid,
deal.botSize,
(deal.app.price + deal.dataset.price + deal.workerpool.price) * deal.botSize,
deal.requester
);
}
Expand Down Expand Up @@ -233,9 +233,9 @@ contract Voucher is OwnableUpgradeable, IVoucher {
voucherHub,
iexecPoco,
taskId,
deal.appPrice + deal.datasetPrice + deal.workerpoolPrice, // taskPrice
dealId,
deal.botSize,
(deal.appPrice + deal.datasetPrice + deal.workerpoolPrice) * deal.botSize,
deal.requester
);
}
Expand Down Expand Up @@ -312,27 +312,25 @@ contract Voucher is OwnableUpgradeable, IVoucher {
* @param voucherHub hub
* @param iexecPoco address of PoCo contract
* @param taskId id of the task
* @param taskPrice price paid per task at match orders
* @param dealId task's deal id
* @param dealVolume number of tasks in the deal
* @param dealPrice price paid at match orders
* @param requester of the task
*/
function _refundVoucherAndRequester(
IVoucherHub voucherHub,
address iexecPoco,
bytes32 taskId,
uint256 taskPrice,
bytes32 dealId,
uint256 dealVolume,
uint256 dealPrice,
address requester
) private {
VoucherStorage storage $ = _getVoucherStorage();
require(!$._refundedTasks[taskId], "Voucher: task already claimed");
require(!$._refundedTasks[taskId], "Voucher: task already refunded");
$._refundedTasks[taskId] = true;
if (dealPrice != 0) {
if (taskPrice != 0) {
uint256 dealSponsoredAmount = $._sponsoredAmounts[dealId];
// The division yields no remainder since dealPrice = taskPrice * volume.
uint256 taskPrice = dealPrice / dealVolume;
// A positive remainder is possible when the voucher balance is less than
// the sponsorable amount. Min(balance, dealSponsoredAmount) is computed
// at match orders.
Expand Down

0 comments on commit 1fdd243

Please sign in to comment.