KVORUM
compoundSource: Compound governor bravo · #132

Liquidation Event Handling And Collateral Reserves

executedOct 29, 2022, 09:44 AM UTCbyC60xc66e…68a9

01Summary

AISummary by Kvorumclaude-haiku-4-5

Upgrade Compound III (cUSDCv3) to improve liquidation event logging and collateral reserve handling. The patch adds a Transfer event when users are liquidated, treats all excess collateral in the protocol as implicit reserves automatically, and formalizes collateral reserve accounting with a new getCollateralReserves function. Additionally, 10 COMP will be awarded to ilemi.eth for identifying the missing event log issue.

Type
contract upgrade
Funding
$10

Key changes

  • Emit Transfer event from absorb function when users are liquidated and left with positive base asset balance, improving Etherscan and blockchain explorer visibility(medium)
  • Implicit collateral reserves: all excess collateral available via ERC20 balanceOf is automatically considered part of collateral reserves, including accidentally transferred collateral and accrued interest(high)
  • Formalize collateral reserves concept by adding getCollateralReserves(asset) function for protocol transparency(medium)
  • Deploy new CometFactory with patched version and upgrade cUSDCv3 implementation to use the new factory(high)
Contracts0x316f9708bb98af7da9c68c1c3b5e79039cd336e30x1ec63b5883c3481134fd50d5daebc83ecd2e87790x3d9819210a31b4961b30ef54be2aed79b9c9cd3b
Generated by Kvorum
model: claude-haiku-4-5
provider: anthropic
profile: anthropic-fast-v1
prompt: v1.0
generated: 2mo ago
Read the description ↗

02Description

368 words

Liquidation Event Handling And Collateral Reserves

Explanation

Emit Transfer event from absorb

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.

Implicit collateral reserves

Without this patch, the collateral which is bought using buyCollateral must be part of the protocol's balance explicitly, which can happen during absorb. Excess collateral simply transferred to the protocol will not be available as collateral reserves to be sold by the protocol automatically.

With this patch, all of the excess collateral asset available using the ERC20 balanceOf function is implicitly considered part of collateral reserves. This means that accidentally transferring the ERC20 to the protocol will automatically become reserves. It also means that interest accrued implicitly, e.g. when the collateral is the token of another Compound III market, will automatically become part of reserves, which can be sold by the protocol and bought using buyCollateral.

This patch also formalizes the idea of collateral reserves in general, adding a getCollateralReserves(asset) function.

The associated forum post for this proposal can be found here.

Proposal

The proposal itself is to be made from 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 and modifies the total collateral accounting. This is done as a ‘prepare’ step of the migration script.

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 Transfer event improvement.

03Mismatch analysis

AIMismatch analysis by Kvorum

A calldata-vs-description analysis is not generated yet. Review the decoded actions →

04Actions

3 total
#0setFactory(address,address)chain 0x1
Target
0x316f…36e3
Value
0 wei
Function
setFactory(address,address)
Arguments
{
  "0": "0xc3d688B66703497DAA19211EEdff47f25384cdc3",
  "1": "0xa7F7De6cCad4D83d81676717053883337aC2c1b4"
}
Calldata
#1deployAndUpgradeTo(address,address)chain 0x1
Target
0x1ec6…8779
Value
0 wei
Function
deployAndUpgradeTo(address,address)
Arguments
{
  "0": "0x316f9708bB98af7dA9c68C1C3b5e79039cD336E3",
  "1": "0xc3d688B66703497DAA19211EEdff47f25384cdc3"
}
Calldata
#2_grantComp(address,uint256)chain 0x1
Target
0x3d98…cd3b
Value
0 wei
Function
_grantComp(address,uint256)
Arguments
{
  "0": "0x2Ae8c972fB2E6c00ddED8986E2dc672ED190DA06",
  "1": "10000000000000000000"
}
Calldata

05Tally

Summed from votes

Voters0
VP participating0
Outcome (current)—
Current support—

06Voters

0 total

No votes recorded yet.

07Forum

AIForum synthesis by Kvorumclaude-haiku-4-5
sentiment · favorablethread · constructive

Arguments for

  • Adding a Transfer event log to the absorb function improves user experience on Etherscan and blockchain explorers and makes analytics easier.— jared, dakeshi
  • The accounting change to calculate protocol reserves as total balance minus user-owned balances enables future governance tools including using Compound III markets as collateral in other deployments.— jared
  • Bundling the event log and reserve accounting changes together minimizes governance burden by combining relatively small improvements needed for parity across upcoming market launches.— jared

Arguments against

None surfaced.

Notable participants

  • jaredProposer who drafted the patch, led implementation, and oversaw OpenZeppelin audit and proposal creation.
  • andrewhong5297Community developer who identified the missing event log in the absorb function and suggested the improvement.
  • dakeshiDelegate who reviewed the proposal and voted in favor, highlighting its utility for on-chain analytics.
Generated by Kvorum
model: claude-haiku-4-5
provider: anthropic
profile: anthropic-fast-v1
prompt: v1.0
generated: 2mo ago
Open the thread ↗