Skip to content

Commit 7efdb6f

Browse files
committed
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
1 parent 775c174 commit 7efdb6f

File tree

2 files changed

+2
-18
lines changed

2 files changed

+2
-18
lines changed

contracts/Marketplace.sol

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,10 +208,8 @@ contract Marketplace is SlotReservations, Proofs, StateRetrieval, Endian {
208208
uint128 designated = _config.collateral.designatedCollateral(collateral);
209209

210210
if (slotState(slotId) == SlotState.Repair) {
211-
// host gets a discount on its collateral, paid for by the repair reward
212211
uint128 repairReward = _config.collateral.repairReward(collateral);
213212
_vault.transfer(fund, clientAccount, hostAccount, repairReward);
214-
collateral -= repairReward;
215213
}
216214

217215
_transferToVault(slot.host, fund, hostAccount, collateral);

test/Marketplace.test.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -304,31 +304,17 @@ describe("Marketplace", function () {
304304
await marketplace.freeSlot(slotId(slot))
305305
})
306306

307-
it("gives the host a discount on the collateral", async function () {
308-
const collateral = collateralPerSlot(request)
309-
const reward = repairReward(config, collateral)
310-
const discountedCollateral = collateral - reward
311-
await token.approve(marketplace.address, discountedCollateral)
312-
await marketplace.reserveSlot(slot.request, slot.index)
313-
const startBalance = await token.balanceOf(host.address)
314-
await marketplace.fillSlot(slot.request, slot.index, proof)
315-
const endBalance = await token.balanceOf(host.address)
316-
317-
expect(startBalance - endBalance).to.equal(discountedCollateral)
318-
})
319-
320307
it("tops up the host collateral with the repair reward", async function () {
321308
const collateral = collateralPerSlot(request)
322309
const reward = repairReward(config, collateral)
323-
const discountedCollateral = collateral - reward
324-
await token.approve(marketplace.address, discountedCollateral)
310+
await token.approve(marketplace.address, collateral)
325311
await marketplace.reserveSlot(slot.request, slot.index)
326312

327313
const startBalance = await marketplace.getSlotBalance(slotId(slot))
328314
await marketplace.fillSlot(slot.request, slot.index, proof)
329315
const endBalance = await marketplace.getSlotBalance(slotId(slot))
330316

331-
expect(endBalance - startBalance).to.equal(collateral)
317+
expect(endBalance - startBalance).to.equal(collateral + reward)
332318
})
333319
})
334320

0 commit comments

Comments
 (0)