mirror of
https://github.com/status-im/codex-contracts-eth.git
synced 2025-02-07 22:23:41 +00:00
e74d3397a1
* changes reward => pricePerByte * collateral => collateralPerByte * updates tests * introduces AskHelpers to compute price and collateral per slot * adds public view function returning currentCollateral for the slot * updates names for price and collateral * uses pricePerSlotPerSecond in maxPriceHelper * adds collateralPerSlot helper * makes sure that the intended use of the <<currentCollateral>> view function is demonstrated in tests * formatting * fix comment * mints more tokens so that it can be used with contracts tests in nim-codex * Renaming <<collateral>> and <<reward>> to <<collateralPerByte>> and <<pricePerBytePerSecond>> respectively (merged in the meantime to the master)
16 lines
417 B
JavaScript
16 lines
417 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 (end - start) * pricePerSlotPerSecond(request)
|
|
}
|
|
|
|
module.exports = { maxPrice, pricePerSlotPerSecond, payoutForDuration }
|