SIP-343: Add extra fields to existing Market Events to track market debt changes

Author
StatusImplemented
TypeGovernance
NetworkEthereum & Optimism
ImplementorTBD
ReleaseTBD
ProposalLoading status...
Created2023-10-03

Simple Summary

In order to facilitate market's debt tracking over time, this proposal targets to extend existing market events in the Synthetix core system.

Motivation

The primary motivation behind this proposal is to provide a more comprehensive tracking system for changes in the market's debt. The added fields will enable analytics capabilities and in subgrapts to power UI, benefiting both developers and users.

Specification

Overview

Under this proposal, creditCapacity, netIssuance, depositedCollateralValue and reportedDebt fields would be added to MarketUsdDeposited, MarketUsdWithdrawn, MarketCollateralDeposited and MarketCollateralWithdrawn events, which will store the market's debt-relaeted data at the time of each event.

This will prevent the need to recalculate these values in the subgraph processor, thereby averting potential data discrepancies.

Technical Specification

The proposal suggests additions to existing events by introducing new fields. The enhanced event signatures would appear as follows:

    event MarketCollateralDeposited(
        uint128 indexed marketId
        address indexed collateralType
        uint256 tokenAmount
        address indexed sender
+       int128 creditCapacity
+       int128 netIssuance
+       uint256 depositedCollateralValue
+       uint256 reportedDebt
    );
    event MarketCollateralWithdrawn(
        uint128 indexed marketId
        address indexed collateralType
        uint256 tokenAmount
        address indexed sender
+       int128 creditCapacity
+       int128 netIssuance
+       uint256 depositedCollateralValue
+       uint256 reportedDebt
    );
    event MarketUsdDeposited(
        uint128 indexed marketId
        address indexed target
        uint256 amount
        address indexed market
+       int128 creditCapacity
+       int128 netIssuance
+       uint256 depositedCollateralValue
+       uint256 reportedDebt
    );
    event MarketUsdWithdrawn(
        uint128 indexed marketId
        address indexed target
        uint256 amount
        address indexed market
+       int128 creditCapacity
+       int128 netIssuance
+       uint256 depositedCollateralValue
+       uint256 reportedDebt
    );

Test Case

While this SIP doesn't necessitate additional test cases as it is non-breaking and just expands existing events with new fields, it's important that existing test cases receive updates to incorporate these extra properties.

Moreover, it's crucial to note that the UI and subgraphs consuming these events must be modified to accommodate these changes.

Configurable Values (Via SCCP)

N/A

Copyright and related rights waived via CC0.