Skip to content

Commit

Permalink
SIP-330: Minimum collateral capacity view function and event
Browse files Browse the repository at this point in the history
  • Loading branch information
noisekit committed Jun 29, 2023
1 parent 9ae0f1f commit b7cddb8
Showing 1 changed file with 75 additions and 0 deletions.
75 changes: 75 additions & 0 deletions content/sips/sip-330.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
sip: 330
title: Minimum credit capacity view function and event
network: Ethereum & Optimism
status: Draft
type: Governance
author: Noisekit
implementor: TBD
created: 2023-06-28
---

## Simple Summary

This proposal suggests the addition of a view function that provides the minimum credit capacity of a market, required to maintain market liquidity, and an event that is emitted when capacity changes.

## Abstract

A `getMinimumCreditCapacity(uint128 marketId)` function would return the minimum collateral needed for a given market to avoid getting locked due to insufficient collateral. In addition, a `MinimumCreditCapacityChanged(uint128 marketId, uint128 oldCreditCapacity, uint128 newCreditCapacity)` event would be emitted whenever the minimum collateral capacity changes.

## Motivation

The proposed additions will improve the user experience on the frontend by allowing users to understand how much collateral they can withdraw without causing a transaction revert due to a market getting into a locked collateral state.

For example, if a user wanted to decrease delegated collateral amount, the application could call `getMinimumCreditCapacity` to calculate the maximum amount the user could withdraw without causing a revert (losing user's money for gas fees)

In addition, the event would enable the creation of a historical data chart or dashboard to track changes in market liquidity requirements over time.

## Specification

### Overview

These additions would use existing data structures in the Synthetix V3 core system and should not introduce substantial risk to the system.

### Rationale

Providing visibility into minimum collateral requirements and changes to them helps users make informed decisions about their participation in the Synthetix Protocol.

### Technical Specification

The `getMinimumCreditCapacity` function could be implemented as follows:

```solidity
function getMinimumCreditCapacity(
uint128 marketId
)
external
view
returns (uint128 minCreditCapacity)
{
// Implementation to calculate and return the minimum collateral requirement
}
```

The `MinimumCreditCapacityChanged` event could be emitted as follows:

```solidity
event MinimumCreditCapacityChanged(
uint128 indexed marketId,
uint128 oldCreditCapacity,
uint128 newCreditCapacity
);
// This could be emitted wherever the minimum collateral requirement for a market changes in the system
```

## Test Case
Applications could call the `getMinimumCreditCapacity` function to display the minimum collateral needed to maintain liquidity for a given market.

Application could listen for the `MinimumCreditCapacityChanged` event being emitted when collateral delegation changes for a given market or market configuration changes.

## Configurable Values (Via SCCP)
N/A

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

0 comments on commit b7cddb8

Please sign in to comment.