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
This commit is contained in:
Mark Spanbroek 2025-03-12 10:52:11 +01:00
parent e4348de891
commit 6bd4144714
2 changed files with 2 additions and 18 deletions

View File

@ -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);

View File

@ -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)
})
})