Liquidation Event Handling And Collateral Reserves

When a user is liquidated in Compound III, all of their collateral is absorbed into the protocol, and they are typically left with a positive balance of the base asset (USDC) and no debt (or collateral dust).

Shortly after the first market launched, a community developer noticed that the absorb function was missing an event log in the case when an account is left with a positive balance.

While this doesn’t have any economic impact, adding this event log will improve the user experience on Etherscan and blockchain explorers, and make analytics easier.

We have crafted a patch and created a migration script to create a proposal in this pull request.

The first step is to deploy a new CometFactory, using the patched version of the contract, which adds the Transfer event to absorb. This is done as a ‘prepare’ step of the migration script. The ‘enact’ step is then used to actually make the proposal.

The first action of the proposal is to set the factory for cUSDCv3 to the newly deployed factory.

The second action is to deploy and upgrade to a new implementation of Comet, using the newly configured factory.

The third action is to transfer 10 COMP to ilemi.eth (0x2Ae8c972fB2E6c00ddED8986E2dc672ED190DA06), as a reward for identifying the issue and suggesting the improvement.

6 Likes

happy to have helped out! :slight_smile:

1 Like

While implementing the above patch, we uncovered an opportunity for another small improvement to the protocol.

Currently, based on the ‘internal accounting’ methodology of the protocol, collateral balances held by a deployment (but not created through the standard supply function) belong to nobody, and are inaccessible without a code change, nor included as reserves for sale. This could occur if a user sends a token to the wrong address, or if (hypothetically) a Compound III market is collateral in another deployment (for example, if cUSDCv3 were collateral in cWETHv3) and generates interest.

In addition to the liquidation event log, this patch will also include an accounting change, in which the protocol’s reserves of a collateral asset are calculated as the balance held, minus all user owned balances. In effect, if the protocol receives collateral, for any reason, that does not belong to a user address–it will become reserves. This patch will not impact any existing users, but unlocks future tools for governance, including the use of a Compound III market as collateral in another deployment.

This also requires a change to the example liquidation bot contract we provided, and which is updated accordingly in the code.

We are proposing to bundle these changes together, as they are relatively small changes that will give us parity for the markets being launched soon after. By bundling them together, we aim to minimize the governance burden. We’ve added test coverage for the new changes to the pull request, and are working on a few other testing enhancements before creating the proposal. OpenZeppelin is currently auditing these changes, and we will update this thread with any additional findings they have.

2 Likes

This proposal is now live.

The feedback we received from OpenZeppelin on this patch can be found here and will be updated to reflect our responses.

3 Likes

132th proposal summary in korean: Compound 거버넌스 #132 — dakeshi

I voted YES because it will helpful for onchain anlaytics and preparing upcoming changes(collateral reserves code improvement)

1 Like