Skip to content

Commit c246d83

Browse files
committed
change total supply to effective in the circulating computation
1 parent e31c63e commit c246d83

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

swagger.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,7 @@ paths:
801801
/api/v1/chain/circulating-supply:
802802
get:
803803
summary: Get the circulating supply of the native token at the given epoch
804-
description: Calculates circulating supply by subtracting locked amounts from multiple excluded addresses from the total supply
804+
description: Calculates circulating supply by subtracting locked amounts from multiple excluded addresses from the effective supply
805805
parameters:
806806
- in: query
807807
name: epoch
@@ -1319,7 +1319,7 @@ components:
13191319
properties:
13201320
circulatingSupply:
13211321
type: string
1322-
description: Circulating supply of the native token (total supply minus locked supply)
1322+
description: Circulating supply of the native token (effective supply minus locked supply)
13231323
Parameters:
13241324
type: object
13251325
required:

webserver/src/service/chain.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,15 @@ impl ChainService {
132132
total_locked_amount += locked_amount;
133133
}
134134

135-
// Calculate circulating supply = total supply - total locked amount
136-
let total_supply_amount = total_supply.total.clone();
137-
let circulating_amount = &total_supply_amount - &total_locked_amount;
135+
// Calculate circulating supply = effective supply - total locked amount
136+
let effective_supply_amount =
137+
total_supply.effective.ok_or_else(|| {
138+
ChainError::Unknown(
139+
"Effective supply not found for native token".to_string(),
140+
)
141+
})?;
142+
let circulating_amount =
143+
&effective_supply_amount - &total_locked_amount;
138144

139145
Ok(CirculatingSupply {
140146
circulating_supply: circulating_amount.to_string(),

0 commit comments

Comments
 (0)