-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from gnosis/total-locked-breakdown
Total locked breakdown and fix staked GNO query
- Loading branch information
Showing
13 changed files
with
143 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
packages/app/components/stats/TotalLockedBreakdown.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
.infoBubble { | ||
text-align: left; | ||
position: relative; | ||
margin-left: 4px; | ||
margin-top: -5px; | ||
} | ||
.infoBubble img { | ||
width: 16px; | ||
height: 16px; | ||
cursor: help; | ||
display: block; | ||
} | ||
|
||
.dropdown { | ||
background: #ffffff; | ||
border-radius: 0.5rem; | ||
box-shadow: 1px 2px 10px rgba(40, 54, 61, 0.18); | ||
padding: 0.5rem 1rem; | ||
position: absolute; | ||
right: 0; | ||
top: calc(100% + 4px); | ||
width: 360px; | ||
display: none; | ||
z-index: 99; | ||
} | ||
.infoBubble:hover .dropdown { | ||
display: block; | ||
} | ||
|
||
.breakdown > div { | ||
display: flex; | ||
justify-content: space-between; | ||
margin-bottom: 0.5rem; | ||
} | ||
.breakdown dd { | ||
color: #5d6d74; | ||
font-weight: bold; | ||
margin-left: 2.5rem; | ||
} | ||
.breakdown dt { | ||
font-size: 12px; | ||
} | ||
|
||
.total { | ||
border-top: 1px solid #e8e7e6; | ||
padding-top: 8px; | ||
} | ||
.total dd { | ||
color: #001428; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { BigNumber } from "ethers" | ||
import cls from "./TotalLockedBreakdown.module.css" | ||
import useTokenLockConfig from "../useTokenLockConfig" | ||
import useTotalLocked from "../useTotalLocked" | ||
import { formatToken } from "./formatToken" | ||
|
||
const TotalLockedBreakdown: React.FC<{ balance?: BigNumber }> = () => { | ||
const config = useTokenLockConfig() | ||
const [totalLocked, breakdown] = useTotalLocked() | ||
|
||
return ( | ||
<div className={cls.infoBubble}> | ||
<img src="/info.svg" alt="Show details" title="Show details" /> | ||
<div className={cls.dropdown}> | ||
<dl className={cls.breakdown}> | ||
<div> | ||
<dt>GNO locked on Mainnet:</dt> | ||
<dd> | ||
{breakdown.mainnet | ||
? formatToken(breakdown.mainnet, config.decimals) | ||
: "…"} | ||
</dd> | ||
</div> | ||
<div> | ||
<dt>GNO locked on Gnosis Chain:</dt> | ||
<dd> | ||
{breakdown.gnosisChain | ||
? formatToken(breakdown.gnosisChain, config.decimals) | ||
: "…"} | ||
</dd> | ||
</div> | ||
<div> | ||
<dt>GNO staked by Gnosis Beacon Chain validators:</dt> | ||
<dd> | ||
{breakdown.staked | ||
? formatToken(breakdown.staked, config.decimals) | ||
: "…"} | ||
</dd> | ||
</div> | ||
<div className={cls.total}> | ||
<dt>Total locked GNO:</dt> | ||
<dd> | ||
{totalLocked ? formatToken(totalLocked, config.decimals) : "…"} | ||
</dd> | ||
</div> | ||
</dl> | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default TotalLockedBreakdown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import { BigNumber } from "ethers" | ||
import { formatUnits } from "ethers/lib/utils" | ||
|
||
export const formatToken = (bigNumber: BigNumber, decimals: number) => | ||
new Intl.NumberFormat("en-US", { | ||
maximumFractionDigits: 0, | ||
}).format(parseFloat(formatUnits(bigNumber, decimals))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters