Conversation
| uint numMinutesLeft = S.getNumDowntimeMinutesLeft(); | ||
| if (numMinutesLeft < durationMinutes) { | ||
| uint numMinutesToPurchase = durationMinutes.sub(numMinutesLeft); | ||
| uint costLRC = getDowntimeCostLRC(S, numMinutesToPurchase); |
There was a problem hiding this comment.
can this be written as:
uint costLRC = S.getDowntimeCostLRC(numMinutesToPurchase);
There was a problem hiding this comment.
That doesn't seem possible because it's a function in the same library. If you do something like this:
library ExchangeAdmins
{
using ExchangeAdmins for ExchangeData.State;
...
}
then this strangely compiles, but cannot be deployed because it references itself.
| return S.numDowntimeMinutes; | ||
| } else { | ||
| // Calculate how long (in minutes) the exchange is in maintenance | ||
| uint numDowntimeMinutesUsed = now.sub(S.downtimeStart) / 60; |
There was a problem hiding this comment.
use block.timestamp instead of now
There was a problem hiding this comment.
Any reason for this? now is exactly the same as block.timestamp:
https://solidity.readthedocs.io/en/develop/units-and-global-variables.html?highlight=block.timestamp#block-and-transaction-properties
All other code uses now.
There was a problem hiding this comment.
Ok, there is a lint warning we should use block.timestamp instead of now. But if you don't see it, it means we disabled that rule. Then stick to now for consistence then.
|
@Brechtpd can we add a totalDowntime per exchange. Maybe also have a view method called
In future versions, we may want to give a different downtime price per minute, for example: function getDowntimePricePerMinute() {
uint multipler = getTotalDowntimeBips() / 100;
if (totalDowntimeMin < 30 days || multipler == 0) {
multipler = 1;
} else if (multipler > 5) {
multipler = 5;
}
return downtimePriceLRCPerMinute * multipler;
}** UPDATE ** After a second thought, maybe we should still use constant price for the downtime. We should not set up any barrier for a DEX to operate? @Brechtpd ? |
Good idea. I exposed |
|
LGTM. |
|
please merge once tests pass. |
Maintenance mode needs to be expensive because users cannot withdraw anything in maintenance. If it's cheap the exchange can hold user funds hostage for a long time. Making maintenance mode even more expensive if it's used a lot could make sense, other parameters like total user funds stored in the exchange, ... could also be used. |
Implements #206.
Tests still need to be updated.