Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

basic rate-limited hole #218

Draft
wants to merge 1 commit into
base: liq-2.0
Choose a base branch
from
Draft

basic rate-limited hole #218

wants to merge 1 commit into from

Conversation

kmbarry1
Copy link
Contributor

DO NOT MERGE, FOR DISCUSSION PURPOSES ONLY

Here's a basic implementation of a hole that decays in a stepwise linear fashion.

It's stepwise because a continuous decrease would likely lead to too many small auctions in a case where we bumped into a hole limit.

Every qntm seconds, dirt can decrease by up to clod. This is triggered in bark (adds a lot of SSTORE ops, so incentives will matter). But the decrease is only allowed if enough DAI has been collected from auctions or is no longer associated with an auction. This is tracked as trid (dirt that has been "reversed"), so that if auctions are failing to recapitalize, we don't continue to liquidate. I think there may be an argument for removing this and simplifying to a purely time-based mechanism, but wanted to start from this formulation.

@kmbarry1 kmbarry1 requested a review from a team March 16, 2021 22:27
// Risk of overflow should be extremely small, even if milk.last = 0;
// can anyway be made less likely to overflow with a little more work.
uint256 pile = mul(sub(block.timestamp, milk.last) / milk.qntm, milk.clod);
pile = min(milk.dirt, milk.trid, pile);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

given trid <= dirt, why is dirt needed here?

uint256 trid; // Amt of dirt dug by auctions. [rad]
// Packed in to a single slot to minimze gas costs.
uint224 clod; // Amount of dirt to remove per time quantum [rad]
uint32 qntm; // Time between removal of clods [seconds]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about removing this and setting clod in a per-second basis to save some gas?

@e18r
Copy link
Contributor

e18r commented Mar 17, 2021

So the assumption here is that during sharp price declines trid will be bigger than pile, so liquidations will be rate-limited; but in other circumstances, such as high network congestion, pile > trid, so we still want to use the current system and wait for liquidations to finish before allowing more. Am I understanding this correctly?

@e18r
Copy link
Contributor

e18r commented Mar 17, 2021

After thinking about this a lot, I think that making dirt completely dependent on time is the best option, as you suggest. This would save gas, make things much more predictable, and solve the main issue we're trying to solve.

digs would disappear and dirt would only be updated by bark, after subtracting the decay and adding the tab of every new liquidation if it fits in the room.

What I really like about this option, is that it would be a pretty small code change, possibly easier to audit and verify.

@gbalabasquer gbalabasquer changed the base branch from liq-2.0 to master June 9, 2021 15:00
@gbalabasquer gbalabasquer changed the base branch from master to liq-2.0 June 9, 2021 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants