SIP 145: Debt Cache Event Consistency Source

AuthorAnton Jurisevic
Discussions-Tohttps://research.synthetix.io/
StatusVote_Pending
Created2021-06-09

Simple Summary

Fixes an incorrect debt cache event value.

Abstract

SIP 136 updated the debt cache system to properly exclude non-SNX-backed debt from the system debt. However, it did not perform the same deduction from the value emitted in the DebtCacheUpdated event within DebtCache.takeDebtSnapshot.

Motivation

The true debt snapshot value and the emitted value are out of sync; although the true cached value is being computed correctly, the event emitted concurrently with this value being updated does not properly exclude non-SNX-backed debt. This makes it difficult to track the true historical debt value from the events. Additionally, as this affected only full snapshots and not partial ones, the emitted debt cache value time series was fluctuating wildly by a factor of 2 between adjacent DebtCacheUpdated events.

Specification

Overview

The event emitted inside DebtCache.takeDebtSnapshot will contain a corrected value, which properly excludes debt accounted for by the ether wrapper, loans contracts, et cetera.

Rationale

This is the most direct means of fixing the problem. A speedy resolution will limit the number of incorrect data points pushed onto the chain.

Technical Specification

Within DebtCache.takeDebtSnapshot, emit DebtCacheUpdated(snxCollateralDebt) will be replaced with emit DebtCacheUpdated(snxCollateralDebt.floorSub(excludedDebt)). The code is available on github.

Test Cases

See the accompanying pull request.

Configurable Values (Via SCCP)

None

Copyright and related rights waived via CC0.