mirror of
https://github.com/logos-storage/logos-storage-contracts-eth.git
synced 2026-01-03 13:53:10 +00:00
30 lines
724 B
JavaScript
30 lines
724 B
JavaScript
function pricePerSlotPerSecond(request) {
|
|
return request.ask.pricePerBytePerSecond * request.ask.slotSize
|
|
}
|
|
|
|
function maxPrice(request) {
|
|
return (
|
|
request.ask.slots * request.ask.duration * pricePerSlotPerSecond(request)
|
|
)
|
|
}
|
|
|
|
function payoutForDuration(request, start, end) {
|
|
return (Number(end) - Number(start)) * pricePerSlotPerSecond(request)
|
|
}
|
|
|
|
function calculatePartialPayout(request, expiresAt, filledAt) {
|
|
return (Number(expiresAt) - Number(filledAt)) * pricePerSlotPerSecond(request)
|
|
}
|
|
|
|
function calculateBalance(balance, reward) {
|
|
return BigInt(balance) + BigInt(reward)
|
|
}
|
|
|
|
module.exports = {
|
|
maxPrice,
|
|
pricePerSlotPerSecond,
|
|
payoutForDuration,
|
|
calculatePartialPayout,
|
|
calculateBalance,
|
|
}
|