Skip to content

Commit

Permalink
Added ag-ibeur curve pool and gauge.
Browse files Browse the repository at this point in the history
Added vested balance to vesting overview.
Added liquidity providing section to dashboard.
Catering for no yearn/convex staking options.

Signed-off-by: Anton Nell <[email protected]>
  • Loading branch information
antonnell committed Jan 5, 2022
1 parent dac8d72 commit 5df3b59
Show file tree
Hide file tree
Showing 22 changed files with 2,310 additions and 14,041 deletions.
8 changes: 5 additions & 3 deletions components/ffAssetOverview/ffAssetOverview.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ function StakedIcon(props) {
export default function ffAssetOverview({ asset }) {

let balance = 0
if(asset && asset.gauge) {
if(asset && asset.gauge && asset.convex && asset.yearn) {
let pooledBalance = BigNumber(asset.gauge.userPoolBalance).times(asset.gauge.virtualPrice)
let stakedBalance = BigNumber(asset.gauge.userGaugeBalance).times(asset.gauge.virtualPrice)
balance = BigNumber(asset.balance).plus(pooledBalance).plus(stakedBalance)
let convexBalance = BigNumber(asset.convex.balance).times(asset.gauge.virtualPrice)
let yearnBalance = BigNumber(asset.yearn.userVaultBalance)
balance = BigNumber(asset.balance).plus(pooledBalance).plus(convexBalance).plus(stakedBalance).plus(yearnBalance)
}

return (
Expand Down Expand Up @@ -64,7 +66,7 @@ export default function ffAssetOverview({ asset }) {
</div>
<div className={ classes.flex1 }>
<Typography className={ classes.title }>Total Staked:</Typography>
<Typography className={ classes.stakedAmount }>{formatCurrency(BigNumber(asset?.gauge?.userGaugeBalance).plus(asset?.convex?.balance))}</Typography>
<Typography className={ classes.stakedAmount }>{formatCurrency(BigNumber((asset && asset.gauge && asset.gauge.userGaugeBalance) ? asset.gauge.userGaugeBalance : 0).plus((asset && asset.convex && asset.convex.balance) ? asset.convex.balance : 0).plus((asset && asset.yearn && asset.yearn.balance) ? asset.yearn.balance : 0))}</Typography>
<Typography className={ classes.assetSymbol }>{asset?.gauge?.poolSymbol}</Typography>
</div>
</div>
Expand Down
12 changes: 6 additions & 6 deletions components/ffAssets/ffAssetsTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ export default function EnhancedTable({ assets }) {
}

const onView = (asset) => {
router.push(`/asset/${asset.address}/curve`);
router.push(`/asset/${asset.gauge.address}/curve`);
};

const showCurveTooltip = (row) => {
Expand Down Expand Up @@ -301,7 +301,7 @@ export default function EnhancedTable({ assets }) {
/>
<div>
<Typography variant='h2' className={classes.textSpaced}>
{row.symbol}
{row?.gauge?.coin0?.symbol}-{row?.gauge?.coin1?.symbol}
</Typography>
<Typography variant='h5' className={classes.textSpaced} color='textSecondary'>
{row.name}
Expand Down Expand Up @@ -340,18 +340,18 @@ export default function EnhancedTable({ assets }) {
</TableCell>
<TableCell className={classes.cell} align='right'>
<Typography variant='h2' className={classes.textSpaced}>
{formatCurrency(row.convex.balance)}
{ row.convex.address && row.convex.address != '' ? formatCurrency(row.convex.balance) : 'Not Available' }
</Typography>
<Typography variant='h5' className={classes.textSpaced} color='textSecondary'>
{row.gauge.poolSymbol}
{ row.convex.address && row.convex.address != '' ? row.gauge.poolSymbol : '' }
</Typography>
</TableCell>
<TableCell className={classes.cell} align='right'>
<Typography variant='h2' className={classes.textSpaced}>
{formatCurrency(row.yearn.userVaultBalance)}
{ row.yearn.address && row.yearn.address != '' ? formatCurrency(row.yearn.userVaultBalance) : 'Not Available' }
</Typography>
<Typography variant='h5' className={classes.textSpaced} color='textSecondary'>
{row.yearn.apy}%
{ row.yearn.address && row.yearn.address != '' ? row.yearn.apy+'%' : '' }
</Typography>
</TableCell>
<TableCell className={classes.cell} align='right'>
Expand Down
10 changes: 5 additions & 5 deletions components/ffCurveGauge/ffCurveGauge.js
Original file line number Diff line number Diff line change
Expand Up @@ -225,24 +225,24 @@ export default function ffCurveGauge({ asset }) {
fullWidth
className={classes.inputSelect}
>
<MenuItem value={"Yearn"}>
{ asset && asset.yearn && asset.yearn.address && asset.yearn.address !== '' && <MenuItem value={"Yearn"}>
<div className={classes.inline}>
<img className={classes.lpOptionIcon} src="/images/Yearn.png" alt="Convex Logo" width={30} height={30} />
<img className={classes.lpOptionIcon} src="/images/Yearn.png" alt="Yearn Logo" width={30} height={30} />
<Typography>Stake in Yearn</Typography>
</div>
</MenuItem>
</MenuItem>}
<MenuItem value={"Curve"}>
<div className={classes.inline}>
<img className={classes.lpOptionIcon} src="/images/Curve.png" alt="Curve Logo" width={30} height={30} />
<Typography>Stake in Curve</Typography>
</div>
</MenuItem>
<MenuItem value={"Convex"}>
{ asset && asset.convex && asset.convex.address && asset.convex.address !== '' && <MenuItem value={"Convex"}>
<div className={classes.inline}>
<img className={classes.lpOptionIcon} src="/images/Convex.png" alt="Convex Logo" width={30} height={30} />
<Typography>Stake in Convex</Typography>
</div>
</MenuItem>
</MenuItem>}
</Select>
</div>
</Grid>
Expand Down
158 changes: 158 additions & 0 deletions components/ffDashboardAssetOverview/ffDashboardOverview.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,158 @@
import React, { useState, useEffect } from 'react';
import { Paper, Grid, Typography, SvgIcon, Button, TextField, InputAdornment, CircularProgress } from '@material-ui/core';
import Autocomplete from '@material-ui/lab/Autocomplete';
import Skeleton from '@material-ui/lab/Skeleton';
import BigNumber from 'bignumber.js';

import { formatCurrency } from '../../utils';
import classes from './ffDashboardOverview.module.css';

import stores from '../../stores'
import { FIXED_FOREX_UPDATED } from '../../stores/constants';

function BalanceIcon(props) {
const { color, className } = props;
return (
<SvgIcon viewBox="0 0 48 48" stroke-width="3" className={className}>
<g stroke-width="3" transform="translate(0.5, 0.5)"><rect x="16" y="23" width="16" height="10" fill="none" stroke="#ffffff" stroke-linecap="square" stroke-miterlimit="10" stroke-width="3" data-color="color-2" stroke-linejoin="miter"></rect><path d="M20,23V17a4.012,4.012,0,0,1,4-4h0a4.012,4.012,0,0,1,4,4v6" fill="none" stroke="#ffffff" stroke-linecap="square" stroke-miterlimit="10" stroke-width="3" data-color="color-2" stroke-linejoin="miter"></path><path d="M42,27A18,18,0,0,1,6,27V7L24,3,42,7Z" fill="none" stroke="#ffffff" stroke-linecap="square" stroke-miterlimit="10" stroke-width="3" stroke-linejoin="miter"></path></g>
</SvgIcon>
);
}

function VestedBalanceIcon(props) {
const { color, className } = props;
return (
<SvgIcon viewBox="0 0 32 32" stroke-width="1" className={className}>
<g stroke-width="2" transform="translate(0, 0)"><polyline fill="none" stroke="#ffffff" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" points="14,8 14,14 8,14 " stroke-linejoin="miter"></polyline> <path data-cap="butt" data-color="color-2" fill="none" stroke="#ffffff" stroke-width="2" stroke-miterlimit="10" d="M19,20v4c0,1.657,2.686,3,6,3 s6-1.343,6-3v-4" stroke-linejoin="miter" stroke-linecap="butt"></path> <path data-cap="butt" data-color="color-2" fill="none" stroke="#ffffff" stroke-width="2" stroke-miterlimit="10" d="M19,24v4c0,1.657,2.686,3,6,3 s6-1.343,6-3v-4" stroke-linejoin="miter" stroke-linecap="butt"></path> <ellipse data-color="color-2" fill="none" stroke="#ffffff" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" cx="25" cy="20" rx="6" ry="3" stroke-linejoin="miter"></ellipse> <path fill="none" stroke="#ffffff" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" d="M15,26.962 C14.67,26.987,14.336,27,14,27C6.82,27,1,21.18,1,14S6.82,1,14,1c6.843,0,12.452,5.288,12.962,12" stroke-linejoin="miter"></path></g>
</SvgIcon>
);
}

function IbBalanceIcon(props) {
const { color, className } = props;
return (
<SvgIcon viewBox="0 0 32 32" stroke-width="1" className={className}>
<g stroke-width="2" transform="translate(0, 0)"><path data-cap="butt" fill="none" stroke="#ffffff" stroke-width="2" stroke-miterlimit="10" d="M1,5v4c0,1.657,2.686,3,6,3 s6-1.343,6-3V5" stroke-linejoin="miter" stroke-linecap="butt"></path> <path data-cap="butt" fill="none" stroke="#ffffff" stroke-width="2" stroke-miterlimit="10" d="M1,9v4c0,1.657,2.686,3,6,3 s6-1.343,6-3V9" stroke-linejoin="miter" stroke-linecap="butt"></path> <line data-cap="butt" fill="none" stroke="#ffffff" stroke-width="2" stroke-miterlimit="10" x1="13" y1="16.401" x2="13" y2="13" stroke-linejoin="miter" stroke-linecap="butt"></line> <path data-cap="butt" fill="none" stroke="#ffffff" stroke-width="2" stroke-miterlimit="10" d="M1,13v4c0,1.657,2.686,3,6,3 c1.093,0,2.117-0.147,3-0.402" stroke-linejoin="miter" stroke-linecap="butt"></path> <path data-cap="butt" fill="none" stroke="#ffffff" stroke-width="2" stroke-miterlimit="10" d="M1,17v4c0,1.657,2.686,3,6,3 c1.093,0,2.118-0.147,3-0.402" stroke-linejoin="miter" stroke-linecap="butt"></path> <ellipse fill="none" stroke="#ffffff" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" cx="7" cy="5" rx="6" ry="3" stroke-linejoin="miter"></ellipse> <path data-cap="butt" fill="none" stroke="#ffffff" stroke-width="2" stroke-miterlimit="10" d="M19,9v4c0,1.657,2.686,3,6,3 s6-1.343,6-3V9" stroke-linejoin="miter" stroke-linecap="butt"></path> <path data-cap="butt" fill="none" stroke="#ffffff" stroke-width="2" stroke-miterlimit="10" d="M22,19.594 C22.883,19.85,23.906,20,25,20c3.314,0,6-1.343,6-3v-4" stroke-linejoin="miter" stroke-linecap="butt"></path> <line data-cap="butt" fill="none" stroke="#ffffff" stroke-width="2" stroke-miterlimit="10" x1="19" y1="13" x2="19" y2="16.401" stroke-linejoin="miter" stroke-linecap="butt"></line> <path data-cap="butt" fill="none" stroke="#ffffff" stroke-width="2" stroke-miterlimit="10" d="M22,23.596 C22.883,23.851,23.907,24,25,24c3.314,0,6-1.343,6-3v-4" stroke-linejoin="miter" stroke-linecap="butt"></path> <ellipse fill="none" stroke="#ffffff" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" cx="25" cy="9" rx="6" ry="3" stroke-linejoin="miter"></ellipse> <path data-cap="butt" data-color="color-2" fill="none" stroke="#ffffff" stroke-width="2" stroke-miterlimit="10" d="M10,19v4c0,1.657,2.686,3,6,3 s6-1.343,6-3v-4" stroke-linejoin="miter" stroke-linecap="butt"></path> <path data-cap="butt" data-color="color-2" fill="none" stroke="#ffffff" stroke-width="2" stroke-miterlimit="10" d="M10,23v4c0,1.657,2.686,3,6,3 s6-1.343,6-3v-4" stroke-linejoin="miter" stroke-linecap="butt"></path> <ellipse data-color="color-2" fill="none" stroke="#ffffff" stroke-width="2" stroke-linecap="square" stroke-miterlimit="10" cx="16" cy="19" rx="6" ry="3" stroke-linejoin="miter"></ellipse></g>
</SvgIcon>
);
}

export default function ffOverview() {

const [ ibff, setIBFF] = useState(null)
const [ veIBFF, setVeIBFF] = useState(null)
const [ rewards, setRewards] = useState(null)
const [ assets, setAssets] = useState(null)
const [ totalBalanceCurve, setTotalBalanceCurve ] = useState(0)
const [ totalBalanceConvex, setTotalBalanceConvex ] = useState(0)
const [ totalBalanceYearn, setTotalBalanceYearn ] = useState(0)

useEffect(() => {
const forexUpdated = () => {
setIBFF(stores.fixedForexStore.getStore('ibff'))
setVeIBFF(stores.fixedForexStore.getStore('veIBFF'))
setRewards(stores.fixedForexStore.getStore('rewards'))
const ass = stores.fixedForexStore.getStore('assets')
setAssets(ass)

calculateTotalBalance(ass)
}

setIBFF(stores.fixedForexStore.getStore('ibff'))
setVeIBFF(stores.fixedForexStore.getStore('veIBFF'))
setRewards(stores.fixedForexStore.getStore('rewards'))
const ass = stores.fixedForexStore.getStore('assets')
setAssets(ass)

calculateTotalBalance(ass)

stores.emitter.on(FIXED_FOREX_UPDATED, forexUpdated);
return () => {
stores.emitter.removeListener(FIXED_FOREX_UPDATED, forexUpdated);
};
}, []);

const calculateTotalBalance = (ass) => {
if(!ass) {
return
}

let balanceCurve = 0
let balanceConvex = 0
let balanceYearn = 0

for(let i = 0; i < ass.length; i++) {
let asset = ass[i]
if(asset && asset.gauge) {
let pooledBalance = BigNumber(asset.gauge.userPoolBalance).times(asset.gauge.virtualPrice).times(asset.price)
let stakedBalance = BigNumber(asset.gauge.userGaugeBalance).times(asset.gauge.virtualPrice).times(asset.price)
let convexBalance = BigNumber((asset && asset.convex && asset.convex.balance) ? asset.convex.balance : 0).times(asset.gauge.virtualPrice).times(asset.price)
let yearnBalance = BigNumber((asset && asset.yearn && asset.yearn.userVaultBalance) ? asset.yearn.userVaultBalance : 0).times(asset.price)

balanceCurve = BigNumber(balanceCurve).plus(stakedBalance).plus(pooledBalance)
balanceConvex = BigNumber(balanceConvex).plus(convexBalance)
balanceYearn = BigNumber(balanceYearn).plus(yearnBalance)
}
}

setTotalBalanceCurve(balanceCurve)
setTotalBalanceConvex(balanceConvex)
setTotalBalanceYearn(balanceYearn)
}

return (
<div className={ classes.container }>
<Grid container spacing={4}>

<Grid item lg={4} md={4} sm={12} xs={12}>
<Paper elevation={0} className={ classes.itemWrapGrid }>
<Grid container spacing={0}>
<Grid item lg={3} md={3} sm={3} xs={3} className={classes.iconWrap}>
<IbBalanceIcon className={ classes.overviewIcon } />
</Grid>
<Grid item lg={9} md={9} sm={9} xs={9} className={ classes.itemContent }>
<Typography className={ classes.title }>Curve (ib*) Balances:</Typography>
<div className={ classes.inline }>
<Typography className={ classes.value }>${ formatCurrency(totalBalanceCurve) }</Typography>
</div>
</Grid>
</Grid>
</Paper>
</Grid>

<Grid item lg={4} md={4} sm={12} xs={12}>
<Paper elevation={0} className={ classes.itemWrapGrid }>
<Grid container spacing={0}>
<Grid item lg={3} md={3} sm={3} xs={3} className={classes.iconWrap}>
<IbBalanceIcon className={ classes.overviewIcon } />
</Grid>
<Grid item lg={9} md={9} sm={9} xs={9} className={ classes.itemContent }>
<Typography className={ classes.title }>Convex (ib*) Balances:</Typography>
<div className={ classes.inline }>
<Typography className={ classes.value }>${ formatCurrency(totalBalanceConvex) }</Typography>
</div>
</Grid>
</Grid>
</Paper>
</Grid>

<Grid item lg={4} md={4} sm={12} xs={12}>
<Paper elevation={0} className={ classes.itemWrapGrid }>
<Grid container spacing={0}>
<Grid item lg={3} md={3} sm={3} xs={3} className={classes.iconWrap}>
<IbBalanceIcon className={ classes.overviewIcon } />
</Grid>
<Grid item lg={9} md={9} sm={9} xs={9} className={ classes.itemContent }>
<Typography className={ classes.title }>Yearn (ib*) Balances:</Typography>
<div className={ classes.inline }>
<Typography className={ classes.value }>${ formatCurrency(totalBalanceYearn) }</Typography>
</div>
</Grid>
</Grid>
</Paper>
</Grid>

</Grid>
</div>
);
}
111 changes: 111 additions & 0 deletions components/ffDashboardAssetOverview/ffDashboardOverview.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
.container {
width: calc(100% - 0px);
margin-bottom: 0px;
}

.field {
display: flex;
flex-direction: column;
align-items: flex-start;
justify-content: flex-start;
text-align: left !important;
margin-right: 30px !important;
width: auto !important;
border-radius: 12px;
}

@keyframes gradient {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}

.title {
/* background: rgba(256, 256, 256, 0.2); */
border-radius: 30px;
padding: 0px;
width: 100%;
font-size: 14px !important;
margin: 0px 0 6px 0 !important;
text-align: left !important;
opacity: 0.6;
}

.value {
font-size: 24px !important;
font-weight: bold !important;
text-align: left !important;
width: 100%;
}

.inline {
display: flex;
align-items: flex-end;
}

.valueSymbol {
font-size: 20px !important;
font-weight: bold !important;
margin-bottom: 2px !important;
margin-left: 4px !important;
}

.overviewIcon {
color: #fff;
font-size: 26px !important;
}

.itemWrapGrid {
border-radius: 12px;
overflow: hidden;
min-height: 110px;
border: 1px solid rgba(104,108,122, 0.2) !important;
padding: 0 !important;
margin: 0 !important;
}

.itemContent {
background: none;
display: flex;
align-items: flex-start;
justify-content: center;
flex-direction: column;
padding-left: 30px;
text-align: left !important;
}

.iconWrap {
width: 100%;
min-height: 120px;
border-radius: 0px;
display: flex;
align-items: center;
justify-content: center;
background: linear-gradient(-45deg, #23a6d5, #234ce7);
background-size: 200% 200%;
animation: gradient 35s ease infinite;
}

@keyframes gradient {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}

@media screen and (max-width: 600px) {
.container {
margin-bottom: 40px;
}
}
3 changes: 3 additions & 0 deletions components/ffDashboardAssetOverview/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"main": "ffDashboardOverview.js"
}
Loading

0 comments on commit 5df3b59

Please sign in to comment.