More notes:
[PUBLIC] Gauntlet Compound Governance Notes
The purpose of this document is to discuss possible improvements to the 2-step cooldown mechanism for claiming COMP that was introduced in the Jan 13 Developer Community Call. It assumes basic familiarity with the existing cool down patch.
We received 2 strong points of feedback from the community about the proposed 2-step cool down patch:
cooldown()
function)cooldown()
function for another account due to griefing protectionWe have come up with a proposal that alleviates the above concerns while maintaining most of the cool down logic intact.
The idea is for the cool down process to happen automatically in claims. The first claim will trigger cool down while following claims will claim any available amount and trigger a new cooldown if applicable.
Proposed pseudo code implementation of grantCompCooldownInternal
(this is the function that will be used internally by claimComp
to apportion COMP for a given user).
/**
* @notice Transfer COMP to the user while respecting cooldown
* @dev Note: If there is not enough COMP, we do not perform the transfer all.
* @param user The address of the user to transfer COMP to
* @param amount The amount of COMP to (possibly) transfer
* @return The amount of COMP which was NOT transferred to the user
*/
function grantCompCooldownInternal(address user, uint amount) internal returns (uint) {
if (cooldownPeriod == 0) {
// revert to existing functionality if cooldown is not in effect
return grantCompInternal(user, amount);
} else if (lastCooldownBlock[user] + cooldownPeriod <= getBlockNumber()) {
// if previous cooldown has expired for this user
uint amountToTransfer = compLocked[user] < amount ? compLocked[user] : amount;
uint notTransferred = 0;
if (amountToTransfer > 0) {
// first, immediately transfer any amount that has expired cooldown
notTransferred = grantCompInternal(user, amountToTransfer);
uint lockedAmountLeft = add_(sub_(compLocked[user], amountToTransfer), notTransferred);
compLocked[user] = lockedAmountLeft;
if (lockedAmountLeft == 0) {
// release storage if no locked amount left
lastCooldownBlock[user] = 0;
}
notTransferred = add_(notTransferred, sub_(amount, amountToTransfer));
} else {
notTransferred = amount;
}
// now if there is any extra COMP accrued, begin a new cooldown period for that amount
if (notTransferred > 0) {
lastCooldownBlock[user] = getBlockNumber();
uint lockingAmount = notTransferred;
compLocked[user] = lockingAmount;
}
return notTransferred;
} else {
// cooldown still in progress, don't do anything
return amount;
}
}