mirror of
https://github.com/logos-storage/logos-storage-contracts-eth.git
synced 2026-01-03 13:53:10 +00:00
marketplace: collateral is uint128
Vault stores balances as uint128
This commit is contained in:
parent
4f45856a5e
commit
761fbd4f84
@ -243,8 +243,8 @@ contract Marketplace is SlotReservations, Proofs, StateRetrieval, Endian {
|
||||
context.fundsToReturnToClient -= _slotPayout(requestId, slot.filledAt);
|
||||
|
||||
// Collect collateral
|
||||
uint256 collateralAmount;
|
||||
uint256 collateralPerSlot = request.ask.collateralPerSlot();
|
||||
uint128 collateralAmount;
|
||||
uint128 collateralPerSlot = request.ask.collateralPerSlot();
|
||||
if (slotState(slotId) == SlotState.Repair) {
|
||||
// Host is repairing a slot and is entitled for repair reward, so he gets "discounted collateral"
|
||||
// in this way he gets "physically" the reward at the end of the request when the full amount of collateral
|
||||
@ -261,7 +261,7 @@ contract Marketplace is SlotReservations, Proofs, StateRetrieval, Endian {
|
||||
AccountId hostAccount = _vault.hostAccount(slot.host, slotIndex);
|
||||
TokensPerSecond rate = request.ask.pricePerSlotPerSecond();
|
||||
|
||||
_transferToVault(slot.host, fund, hostAccount, uint128(collateralAmount));
|
||||
_transferToVault(slot.host, fund, hostAccount, collateralAmount);
|
||||
_vault.flow(fund, clientAccount, hostAccount, rate);
|
||||
|
||||
_marketplaceTotals.received += collateralAmount;
|
||||
@ -374,10 +374,10 @@ contract Marketplace is SlotReservations, Proofs, StateRetrieval, Endian {
|
||||
Slot storage slot = _slots[slotId];
|
||||
Request storage request = _requests[slot.requestId];
|
||||
|
||||
uint256 slashedAmount = (request.ask.collateralPerSlot() *
|
||||
uint128 slashedAmount = (request.ask.collateralPerSlot() *
|
||||
_config.collateral.slashPercentage) / 100;
|
||||
|
||||
uint256 validatorRewardAmount = (slashedAmount *
|
||||
uint128 validatorRewardAmount = (slashedAmount *
|
||||
_config.collateral.validatorRewardPercentage) / 100;
|
||||
_marketplaceTotals.sent += validatorRewardAmount;
|
||||
|
||||
@ -388,7 +388,7 @@ contract Marketplace is SlotReservations, Proofs, StateRetrieval, Endian {
|
||||
fund,
|
||||
hostAccount,
|
||||
validatorAccount,
|
||||
uint128(validatorRewardAmount)
|
||||
validatorRewardAmount
|
||||
);
|
||||
|
||||
slot.currentCollateral -= slashedAmount;
|
||||
|
||||
@ -18,7 +18,7 @@ struct Request {
|
||||
struct Ask {
|
||||
uint256 proofProbability; // how often storage proofs are required
|
||||
TokensPerSecond pricePerBytePerSecond; // amount of tokens paid per second per byte to hosts
|
||||
uint256 collateralPerByte; // amount of tokens per byte required to be deposited by the hosts in order to fill the slot
|
||||
uint128 collateralPerByte; // amount of tokens per byte required to be deposited by the hosts in order to fill the slot
|
||||
uint64 slots; // the number of requested slots
|
||||
uint64 slotSize; // amount of storage per slot (in number of bytes)
|
||||
Duration duration; // how long content should be stored (in seconds)
|
||||
@ -49,7 +49,7 @@ enum SlotState {
|
||||
}
|
||||
|
||||
library AskHelpers {
|
||||
function collateralPerSlot(Ask memory ask) internal pure returns (uint256) {
|
||||
function collateralPerSlot(Ask memory ask) internal pure returns (uint128) {
|
||||
return ask.collateralPerByte * ask.slotSize;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user