From 6bd414471431daad5f1fe0039458ad018295cd63 Mon Sep 17 00:00:00 2001 From: Mark Spanbroek Date: Wed, 12 Mar 2025 10:52:11 +0100 Subject: [PATCH] marketplace: repair reward is paid out at the end It is no longer a discount on the collateral, to simplify reasoning about collateral in the sales module of the codex node --- contracts/Marketplace.sol | 2 -- test/Marketplace.test.js | 18 ++---------------- 2 files changed, 2 insertions(+), 18 deletions(-) diff --git a/contracts/Marketplace.sol b/contracts/Marketplace.sol index cee8247..ceaf09d 100644 --- a/contracts/Marketplace.sol +++ b/contracts/Marketplace.sol @@ -208,10 +208,8 @@ contract Marketplace is SlotReservations, Proofs, StateRetrieval, Endian { uint128 designated = _config.collateral.designatedCollateral(collateral); if (slotState(slotId) == SlotState.Repair) { - // host gets a discount on its collateral, paid for by the repair reward uint128 repairReward = _config.collateral.repairReward(collateral); _vault.transfer(fund, clientAccount, hostAccount, repairReward); - collateral -= repairReward; } _transferToVault(slot.host, fund, hostAccount, collateral); diff --git a/test/Marketplace.test.js b/test/Marketplace.test.js index 21fc08d..4f394bf 100644 --- a/test/Marketplace.test.js +++ b/test/Marketplace.test.js @@ -304,31 +304,17 @@ describe("Marketplace", function () { await marketplace.freeSlot(slotId(slot)) }) - it("gives the host a discount on the collateral", async function () { - const collateral = collateralPerSlot(request) - const reward = repairReward(config, collateral) - const discountedCollateral = collateral - reward - await token.approve(marketplace.address, discountedCollateral) - await marketplace.reserveSlot(slot.request, slot.index) - const startBalance = await token.balanceOf(host.address) - await marketplace.fillSlot(slot.request, slot.index, proof) - const endBalance = await token.balanceOf(host.address) - - expect(startBalance - endBalance).to.equal(discountedCollateral) - }) - it("tops up the host collateral with the repair reward", async function () { const collateral = collateralPerSlot(request) const reward = repairReward(config, collateral) - const discountedCollateral = collateral - reward - await token.approve(marketplace.address, discountedCollateral) + await token.approve(marketplace.address, collateral) await marketplace.reserveSlot(slot.request, slot.index) const startBalance = await marketplace.getSlotBalance(slotId(slot)) await marketplace.fillSlot(slot.request, slot.index, proof) const endBalance = await marketplace.getSlotBalance(slotId(slot)) - expect(endBalance - startBalance).to.equal(collateral) + expect(endBalance - startBalance).to.equal(collateral + reward) }) })