Skip to content

Commit

Permalink
refactor: rename statuses to use two words
Browse files Browse the repository at this point in the history
docs: update diagrams
  • Loading branch information
andreivladbrg committed Jun 14, 2024
1 parent 6c196de commit c932f6c
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 53 deletions.
68 changes: 34 additions & 34 deletions diagrams.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@

### Types

| Type | Statuses | Description |
| :----- | :------------------ | :------------------------------------------------------------ |
| Active | Accruing, Streaming | The amount owed to the recipient is increasing over time. |
| Paused | Liable, Deferred | The amount owed to the recipient is not increasing over time. |

| Status | Description |
| --------- | ------------------------------------ |
| Streaming | Active stream when there is no debt. |
| Accruing | Active stream when there is debt. |
| Liable | Paused stream when there is debt. |
| Deferred | Paused stream when there is no debt. |
| Type | Statuses | Description |
| :----- | :---------------------------------- | :------------------------------------------------------------ |
| Active | Streaming In Debt, StreamingSolvent | The amount owed to the recipient is increasing over time. |
| Paused | PauseSolvent, PausedInDebt | The amount owed to the recipient is not increasing over time. |

| Status | Description |
| ----------------- | ------------------------------------ |
| Streaming Solvent | Active stream when there is no debt. |
| Streaming In Debt | Active stream when there is debt. |
| Pause Solvent | Paused stream when there is debt. |
| Paused In Debt | Paused stream when there is no debt. |

### Statuses diagram

Expand All @@ -24,33 +24,33 @@ stateDiagram-v2
direction LR
state Active {
Streaming
Accruing --> Streaming : deposit
Streaming --> Accruing : time
StreamingSolvent
StreamingInDebt --> StreamingSolvent : deposit
StreamingSolvent --> StreamingInDebt : time
}
state Paused {
state Inactive {
# direction BT
Deferred
Liable
Liable --> Deferred : deposit || void
PausedInDebt
PauseSolvent
PauseSolvent --> PausedInDebt : deposit || void
}
Streaming --> Deferred : pause
Deferred --> Streaming : restart
Accruing --> Liable : pause
Accruing --> Deferred : void
Liable --> Accruing : restart
StreamingSolvent --> PausedInDebt : pause
PausedInDebt --> StreamingSolvent : restart
StreamingInDebt --> PauseSolvent : pause
StreamingInDebt --> PausedInDebt : void
PauseSolvent --> StreamingInDebt : restart
NULL --> Streaming : create
NULL --> StreamingSolvent : create
NULL:::grey
Paused:::lightYellow
Active:::lightGreen
Streaming:::intenseGreen
Accruing:::intenseGreen
Deferred:::intenseYellow
Liable:::intenseYellow
Inactive:::lightYellow
StreamingSolvent:::intenseGreen
StreamingInDebt:::intenseGreen
PausedInDebt:::intenseYellow
PauseSolvent:::intenseYellow
classDef grey fill:#b0b0b0,stroke:#333,stroke-width:2px,color:#000,font-weight:bold;
classDef lightGreen fill:#98FB98,color:#000,font-weight:bold;
Expand All @@ -73,7 +73,7 @@ flowchart LR
subgraph Statuses
NULL((NULL)):::grey
ACV((ACTIVE)):::green
PSD((PAUSED)):::yellow
INACV((INACTIVE)):::yellow
end
Expand Down Expand Up @@ -108,9 +108,9 @@ flowchart LR
PS -- "update ra (+rca)\nupdate rps (0)" --> ACV
BOTH --> ACV & PSD
BOTH --> ACV & INACV
RST -- "update rps \nupdate ltu" --> PSD
RST -- "update rps \nupdate ltu" --> INACV
linkStyle 2,3,5 stroke:#ff0000,stroke-width:2px
```
Expand Down Expand Up @@ -166,7 +166,7 @@ res_rca(["rps*(now - ltu)"]):::green1
rca --> di0
di0 -- "active" --> di1
di0 -- "paused" --> res_00
di0 -- "inactive" --> res_00
di1 -- "now < ltu" --> res_01
di1 -- "now >= ltu" --> res_rca
Expand Down Expand Up @@ -198,7 +198,7 @@ flowchart TD
di0 -- "bal > 0" --> di1
di1 -- "debt > 0" --> res_bal
di1 -- "debt = 0" --> di2
di2 -- "paused" --> res_ra
di2 -- "inactive" --> res_ra
di2 -- "active" --> res_sum
classDef blue0 fill:#DAE8FC,stroke:#333,stroke-width:2px;
Expand Down
16 changes: 8 additions & 8 deletions src/SablierFlow.sol
Original file line number Diff line number Diff line change
Expand Up @@ -98,22 +98,22 @@ contract SablierFlow is
uint128 debt = _streamDebtOf(streamId);

if (_streams[streamId].isPaused) {
// If the stream is paused and has debt, return LIABLE.
// If the stream is paused and has debt, return PAUSED_SOLVENT.
if (debt > 0) {
return Flow.Status.LIABLE;
return Flow.Status.PAUSED_SOLVENT;
}

// If the stream is paused and has no debt, return DEFERRED.
return Flow.Status.DEFERRED;
// If the stream is paused and has no debt, return PAUSED_INDEBT.
return Flow.Status.PAUSED_INDEBT;
}

// If the stream is active and has debt, return ACCRUING.
// If the stream is active and has debt, return STREAMING_INDEBT.
if (debt > 0) {
return Flow.Status.ACCRUING;
return Flow.Status.STREAMING_INDEBT;
}

// If the stream is active and has no debt, return STREAMINIG.
status = Flow.Status.STREAMINIG;
// If the stream is active and has no debt, return STREAMING_SOLVENT.
status = Flow.Status.STREAMING_SOLVENT;
}

/// @inheritdoc ISablierFlow
Expand Down
22 changes: 11 additions & 11 deletions src/types/DataTypes.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ struct Broker {

library Flow {
/// @notice Enum representing the different statuses of a stream.
/// @dev There are two types of statuses:
/// @dev There are two types of streams:
/// - ACTIVE: when the amount owed to the recipient is increasing over time.
/// - PAUSED: when the amount owed to the recipient is not increasing over time.
/// @custom:value0 STREAMINIG Active stream when there is no debt.
/// @custom:value1 ACCRUING Active stream when there is debt.
/// @custom:value2 LIABLE Paused stream when there is debt.
/// @custom:value3 DEFERRED Paused stream when there is no debt.
/// - INACTIVE: when the amount owed to the recipient is not increasing over time.
/// @custom:value0 STREAMING_SOLVENT Active stream when there is no debt.
/// @custom:value1 STREAMING_INDEBT Active stream when there is debt.
/// @custom:value2 PAUSED_SOLVENT Paused stream when there is debt.
/// @custom:value3 PAUSED_INDEBT Paused stream when there is no debt.
enum Status {
// ACTIVE:
STREAMINIG,
ACCRUING,
// PAUSED:
LIABLE,
DEFERRED
STREAMING_SOLVENT,
STREAMING_INDEBT,
// INACTIVE:
PAUSED_SOLVENT,
PAUSED_INDEBT
}

/// @notice Struct representing Flow streams.
Expand Down

0 comments on commit c932f6c

Please sign in to comment.