mirror of
https://github.com/logos-storage/logos-storage-contracts-eth.git
synced 2026-01-03 22:03:08 +00:00
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:
parent
e4348de891
commit
6bd4144714
@ -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);
|
||||
|
||||
@ -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)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user