diff --git a/content/sips/sip-343.md b/content/sips/sip-343.md new file mode 100644 index 000000000..bfaca4623 --- /dev/null +++ b/content/sips/sip-343.md @@ -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/).