-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
50 changed files
with
1,219 additions
and
114 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,56 @@ | ||
import { memo, useMemo } from 'react' | ||
import { StyledAPYIcon } from './styles' | ||
import { CCN } from '@/domain/node' | ||
import { RewardManager } from '@/domain/reward' | ||
import { Tooltip } from '@aleph-front/aleph-core' | ||
|
||
// https://github.com/aleph-im/aleph-account/blob/main/src/components/NodesTable.vue#L586 | ||
export const APYCell = memo(({ node, nodes }: { node: CCN; nodes: CCN[] }) => { | ||
const apyManager = new RewardManager({} as any) | ||
|
||
const nodeAPY = apyManager.computeEstimatedStakersAPY(node, nodes) | ||
const currentAPY = apyManager.currentAPY(nodes) | ||
const performance = nodeAPY / currentAPY | ||
|
||
const isNotFullyLinked = useMemo( | ||
() => node.crnsData.length < 3 || node.crnsData.find((f) => f.score < 0.2), | ||
[node], | ||
) | ||
|
||
const data = ( | ||
<div tw="flex gap-3 items-center"> | ||
<StyledAPYIcon $performance={performance} /> | ||
{Number(nodeAPY * 100).toFixed(2)}% | ||
</div> | ||
) | ||
|
||
return ( | ||
<> | ||
{isNotFullyLinked ? ( | ||
<Tooltip | ||
my="top-center" | ||
at="bottom-center" | ||
content={ | ||
<div className="fs-sm"> | ||
<div> | ||
<div>{3 - node.crnsData.length} missing CRN</div> | ||
<div className="fs-xs"> | ||
Link 3 functioning CRN to that Node to maximise its rewards | ||
</div> | ||
</div> | ||
<div>Performance: {Number(performance * 100).toFixed(2)}%</div> | ||
</div> | ||
} | ||
header="Staking performance" | ||
> | ||
{data} | ||
</Tooltip> | ||
) : ( | ||
data | ||
)} | ||
</> | ||
) | ||
}) | ||
APYCell.displayName = 'APYCell' | ||
|
||
export default APYCell |
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 @@ | ||
export { default } from './cmp' |
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,20 @@ | ||
import tw from 'twin.macro' | ||
import styled, { css } from 'styled-components' | ||
|
||
export const StyledAPYIcon = styled.div<{ $performance: number }>( | ||
({ theme, $performance }) => { | ||
const color = | ||
$performance >= 0.8 | ||
? theme.color.main1 | ||
: $performance >= 0.5 | ||
? theme.color.main0 | ||
: theme.color.error | ||
|
||
return [ | ||
tw`h-4 w-4 rounded-full`, | ||
css` | ||
background-color: ${color}; | ||
`, | ||
] | ||
}, | ||
) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { memo } from 'react' | ||
import { StyledLinkIcon } from './styles' | ||
|
||
// https://github.com/aleph-im/aleph-account/blob/main/src/components/NodesTable.vue#L163 | ||
export const LinkedCell = memo( | ||
({ nodes, max = 3 }: { nodes: string[]; max?: number }) => { | ||
return ( | ||
<div tw="flex items-center gap-3"> | ||
<div tw="flex items-stretch gap-0.5"> | ||
{Array.from({ length: max }).map((_, i) => ( | ||
<StyledLinkIcon key={i} $active={!!nodes[i]} /> | ||
))} | ||
</div> | ||
<div tw="whitespace-nowrap leading-4" className="fs-xs"> | ||
{nodes.length} <span tw="opacity-20">of {max}</span> | ||
</div> | ||
</div> | ||
) | ||
}, | ||
) | ||
LinkedCell.displayName = 'LinkedCell' | ||
|
||
export default LinkedCell |
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 @@ | ||
export { default } from './cmp' |
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,15 @@ | ||
import tw from 'twin.macro' | ||
import styled, { css } from 'styled-components' | ||
|
||
export const StyledLinkIcon = styled.div<{ $active: boolean }>( | ||
({ theme, $active }) => { | ||
const color = $active ? theme.color.main1 : `${theme.color.base0}20` | ||
|
||
return [ | ||
tw`h-3 w-2`, | ||
css` | ||
background-color: ${color}; | ||
`, | ||
] | ||
}, | ||
) |
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
Oops, something went wrong.