Skip to content

Commit

Permalink
SIP-342 Add extra fields to existing Market Events to track market de…
Browse files Browse the repository at this point in the history
…bt changes (#1710)
  • Loading branch information
noisekit authored Oct 4, 2023
1 parent 31562da commit fa38ee7
Showing 1 changed file with 97 additions and 0 deletions.
97 changes: 97 additions & 0 deletions content/sips/sip-343.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
---
sip: 343
network: Ethereum & Optimism
title: Add extra fields to existing Market Events to track market debt changes
author: Noisekit (@noisekit)
status: Draft
created: 2023-10-03
type: Governance
---

## 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:

```diff
event MarketCollateralDeposited(
uint128 indexed marketId
address indexed collateralType
uint256 tokenAmount
address indexed sender
+ int128 creditCapacity
+ int128 netIssuance
+ uint256 depositedCollateralValue
+ uint256 reportedDebt
);
```


```diff
event MarketCollateralWithdrawn(
uint128 indexed marketId
address indexed collateralType
uint256 tokenAmount
address indexed sender
+ int128 creditCapacity
+ int128 netIssuance
+ uint256 depositedCollateralValue
+ uint256 reportedDebt
);
```

```diff
event MarketUsdDeposited(
uint128 indexed marketId
address indexed target
uint256 amount
address indexed market
+ int128 creditCapacity
+ int128 netIssuance
+ uint256 depositedCollateralValue
+ uint256 reportedDebt
);
```


```diff
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

Copyright and related rights waived via [CC0](https://creativecommons.org/publicdomain/zero/1.0/).

1 comment on commit fa38ee7

@vercel
Copy link

@vercel vercel bot commented on fa38ee7 Oct 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.