diff --git a/components/ffDashboardClaimAll/ffDashboardClaimAllTable.js b/components/ffDashboardClaimAll/ffDashboardClaimAllTable.js index 94f3dea..d30a1ea 100644 --- a/components/ffDashboardClaimAll/ffDashboardClaimAllTable.js +++ b/components/ffDashboardClaimAll/ffDashboardClaimAllTable.js @@ -1,12 +1,20 @@ -import React from 'react'; -import PropTypes from 'prop-types'; -import { lighten, makeStyles } from '@material-ui/core/styles'; -import Skeleton from '@material-ui/lab/Skeleton'; -import { Grid, Table, TableBody, TableCell, TableContainer, TableHead, TableRow, TableSortLabel, Typography, Button, CircularProgress } from '@material-ui/core'; -import BigNumber from 'bignumber.js'; -import classes from './ffDashboardClaimAll.module.css'; - -import stores from '../../stores' +import React from "react"; +import { makeStyles } from "@material-ui/core/styles"; +import Skeleton from "@material-ui/lab/Skeleton"; +import { + Grid, + Table, + TableBody, + TableCell, + TableContainer, + TableRow, + Typography, + Button, + CircularProgress, +} from "@material-ui/core"; +import BigNumber from "bignumber.js"; + +import stores from "../../stores"; import { FIXED_FOREX_CLAIM_CURVE_REWARDS, FIXED_FOREX_CURVE_REWARD_CLAIMED, @@ -17,8 +25,8 @@ import { FIXED_FOREX_VESTING_REWARD_CLAIMED, FIXED_FOREX_CLAIM_RKP3R, FIXED_FOREX_RKP3R_CLAIMED, -} from '../../stores/constants'; -import { formatCurrency } from '../../utils'; +} from "../../stores/constants"; +import { formatCurrency } from "../../utils"; function descendingComparator(a, b, orderBy) { if (!a || !b) { @@ -35,7 +43,9 @@ function descendingComparator(a, b, orderBy) { } function getComparator(order, orderBy) { - return order === 'desc' ? (a, b) => descendingComparator(a, b, orderBy) : (a, b) => -descendingComparator(a, b, orderBy); + return order === "desc" + ? (a, b) => descendingComparator(a, b, orderBy) + : (a, b) => -descendingComparator(a, b, orderBy); } function stableSort(array, comparator) { @@ -48,176 +58,158 @@ function stableSort(array, comparator) { return stabilizedThis.map((el) => el[0]); } -const headCells = [ - { id: 'asset', numeric: false, disablePadding: false, label: 'Asset' }, - { - id: 'rewards', - numeric: true, - disablePadding: false, - label: 'Rewards Available', - }, - { - id: 'claim', - numeric: true, - disablePadding: false, - label: '', - } -]; - const useStyles = makeStyles((theme) => ({ root: { - width: '100%', + width: "100%", }, paper: { - width: '100%', + width: "100%", marginBottom: theme.spacing(2), }, visuallyHidden: { border: 0, - clip: 'rect(0 0 0 0)', + clip: "rect(0 0 0 0)", height: 1, margin: -1, - overflow: 'hidden', + overflow: "hidden", padding: 0, - position: 'absolute', + position: "absolute", top: 20, width: 1, }, - inline: { - }, + inline: {}, icon: { - marginRight: '12px', + marginRight: "12px", }, textSpaced: { - lineHeight: '1.4', - }, - cell: { - + lineHeight: "1.4", }, + cell: {}, cellSuccess: { - color: '#4eaf0a', + color: "#4eaf0a", }, cellAddress: { - cursor: 'pointer', + cursor: "pointer", }, aligntRight: { - display: 'flex', - flexDirection: 'column', - alignItems: 'flex-end', + display: "flex", + flexDirection: "column", + alignItems: "flex-end", }, skelly: { - marginBottom: '12px', - marginTop: '12px', + marginBottom: "12px", + marginTop: "12px", }, skelly1: { - marginBottom: '12px', - marginTop: '24px', + marginBottom: "12px", + marginTop: "24px", }, skelly2: { - margin: '12px 6px', + margin: "12px 6px", }, tableBottomSkelly: { - display: 'flex', - justifyContent: 'flex-end', + display: "flex", + justifyContent: "flex-end", }, assetInfo: { - display: 'flex', - alignItems: 'center', - justifyContent: 'space-between', + display: "flex", + alignItems: "center", + justifyContent: "space-between", flex: 1, - padding: '24px', - width: '100%', - flexWrap: 'wrap', - borderBottom: '1px solid rgba(128, 128, 128, 0.32)', - background: 'radial-gradient(circle, rgba(63,94,251,0.7) 0%, rgba(47,128,237,0.7) 48%) rgba(63,94,251,0.7) 100%', + padding: "24px", + width: "100%", + flexWrap: "wrap", + borderBottom: "1px solid rgba(128, 128, 128, 0.32)", + background: + "radial-gradient(circle, rgba(63,94,251,0.7) 0%, rgba(47,128,237,0.7) 48%) rgba(63,94,251,0.7) 100%", }, assetInfoError: { - display: 'flex', - alignItems: 'center', - justifyContent: 'space-between', + display: "flex", + alignItems: "center", + justifyContent: "space-between", flex: 1, - padding: '24px', - width: '100%', - flexWrap: 'wrap', - borderBottom: '1px solid rgba(128, 128, 128, 0.32)', - background: '#dc3545', + padding: "24px", + width: "100%", + flexWrap: "wrap", + borderBottom: "1px solid rgba(128, 128, 128, 0.32)", + background: "#dc3545", }, infoField: { flex: 1, }, flexy: { - padding: '6px 0px', + padding: "6px 0px", }, overrideCell: { - padding: '0px', + padding: "0px", }, hoverRow: { - cursor: 'pointer', + cursor: "pointer", }, statusLiquid: { - color: '#dc3545', + color: "#dc3545", }, statusWarning: { - color: '#FF9029', + color: "#FF9029", }, statusSafe: { - color: 'green', + color: "green", }, imgLogo: { - marginRight: '0px' + marginRight: "0px", }, tableContainer: { - width: '100%', + width: "100%", }, buttonOverride: { - boxShadow: 'none !important', - minWidth: '100%', - background: 'gold', - color: '#000', - padding: '12px 24px !important', - borderRadius: '40px !important', - marginLeft: '-25px', + boxShadow: "none !important", + minWidth: "100%", + background: "gold", + color: "#000", + padding: "12px 24px !important", + borderRadius: "40px !important", + marginLeft: "-25px", }, actionButtonText: { - fontWeight: '700 !important', - fontSize: '13px !important', - textTransform: 'capitalize !important' + fontWeight: "700 !important", + fontSize: "13px !important", + textTransform: "capitalize !important", }, loadingCircle: { - marginLeft: '6px !important', - color: '#FFF !important', + marginLeft: "6px !important", + color: "#FFF !important", }, overrideTableHead: { - borderBottom: '1px solid rgba(104,108,122,0.2) !important', + borderBottom: "1px solid rgba(104,108,122,0.2) !important", }, alignR: { - position: 'relative', + position: "relative", }, endAsset: { - minWidth: '240px', - marginTop: '10px', - marginLeft: '40px', + minWidth: "240px", + marginTop: "10px", + marginLeft: "40px", }, divider: { - height: '1px', - minWidth: '100%', - background: 'rgba(104,108,122,0.2)', - marginTop: '20px', + height: "1px", + minWidth: "100%", + background: "rgba(104,108,122,0.2)", + marginTop: "20px", }, })); export default function EnhancedTable({ claimable, crv, ibEUR, rKP3R }) { const classes = useStyles(); - const [order, setOrder] = React.useState('desc'); - const [orderBy, setOrderBy] = React.useState('balance'); - const [claimLoading, setClaimLoading ] = React.useState(false) - const [claimedAsset, setClaimedAsset] = React.useState() + const [order, setOrder] = React.useState("desc"); + const [orderBy, setOrderBy] = React.useState("balance"); + const [claimLoading, setClaimLoading] = React.useState(false); + const [claimedAsset, setClaimedAsset] = React.useState(); React.useEffect(() => { const rewardClaimed = () => { - setClaimLoading(false) - } + setClaimLoading(false); + }; stores.emitter.on(FIXED_FOREX_CURVE_REWARD_CLAIMED, rewardClaimed); stores.emitter.on(FIXED_FOREX_DISTRIBUTION_REWARD_CLAIMED, rewardClaimed); @@ -226,56 +218,112 @@ export default function EnhancedTable({ claimable, crv, ibEUR, rKP3R }) { stores.emitter.on(ERROR, rewardClaimed); return () => { - stores.emitter.removeListener(FIXED_FOREX_CURVE_REWARD_CLAIMED, rewardClaimed); - stores.emitter.removeListener(FIXED_FOREX_DISTRIBUTION_REWARD_CLAIMED, rewardClaimed); - stores.emitter.removeListener(FIXED_FOREX_VESTING_REWARD_CLAIMED, rewardClaimed); + stores.emitter.removeListener( + FIXED_FOREX_CURVE_REWARD_CLAIMED, + rewardClaimed + ); + stores.emitter.removeListener( + FIXED_FOREX_DISTRIBUTION_REWARD_CLAIMED, + rewardClaimed + ); + stores.emitter.removeListener( + FIXED_FOREX_VESTING_REWARD_CLAIMED, + rewardClaimed + ); stores.emitter.removeListener(FIXED_FOREX_RKP3R_CLAIMED, rewardClaimed); stores.emitter.removeListener(ERROR, rewardClaimed); }; }, []); - const handleRequestSort = (event, property) => { - const isAsc = orderBy === property && order === 'asc'; - setOrder(isAsc ? 'desc' : 'asc'); - setOrderBy(property); - }; - const onClaim = (asset) => { - console.log(asset) - setClaimLoading(true) - setClaimedAsset(asset) + setClaimLoading(true); + setClaimedAsset(asset); - if(asset.gauge) { + if (asset.gauge) { // this is a gauge - stores.dispatcher.dispatch({ type: FIXED_FOREX_CLAIM_CURVE_REWARDS, content: { asset: asset.gauge }}) - } else if(asset.type === 'Fixed Forex' && asset.description === 'Fee Claim') { - stores.dispatcher.dispatch({ type: FIXED_FOREX_CLAIM_DISTRIBUTION_REWARD, content: { }}) - } else if(asset.type === 'Fixed Forex' && asset.description === 'Vesting Rewards') { - stores.dispatcher.dispatch({ type: FIXED_FOREX_CLAIM_VESTING_REWARD, content: { }}) - } else if(asset.type === 'Fixed Forex' && asset.description === 'Redeemable KP3R') { - stores.dispatcher.dispatch({ type: FIXED_FOREX_CLAIM_RKP3R, content: { }}) + stores.dispatcher.dispatch({ + type: FIXED_FOREX_CLAIM_CURVE_REWARDS, + content: { asset: asset.gauge }, + }); + } else if ( + asset.type === "Fixed Forex" && + asset.description === "Fee Claim" + ) { + stores.dispatcher.dispatch({ + type: FIXED_FOREX_CLAIM_DISTRIBUTION_REWARD, + content: {}, + }); + } else if ( + asset.type === "Fixed Forex" && + asset.description === "Vesting Rewards" + ) { + stores.dispatcher.dispatch({ + type: FIXED_FOREX_CLAIM_VESTING_REWARD, + content: {}, + }); + } else if ( + asset.type === "Fixed Forex" && + asset.description === "Redeemable KP3R" + ) { + stores.dispatcher.dispatch({ + type: FIXED_FOREX_CLAIM_RKP3R, + content: {}, + }); } - } + }; if (!claimable) { return (
- - - - - - + + + + + +
); } return (
- - - - + +
{stableSort(claimable, getComparator(order, orderBy)).map((row) => { if (!row) { @@ -283,103 +331,152 @@ export default function EnhancedTable({ claimable, crv, ibEUR, rKP3R }) { } return ( - + -
- - - - + - - { - row?.type === 'Fixed Forex' && } - { - row?.type !== 'Fixed Forex' && - } + {row?.type === "Fixed Forex" && ( + + )} + {row?.type !== "Fixed Forex" && ( + + )} - - { row?.type } + + {row?.type} - - { row?.description } + + {row?.description} - - - - + - - - { formatCurrency(row?.earned) } { row.symbol } + + {formatCurrency(row?.earned)} {row.symbol} - - ${ - row.symbol === 'CRV' && - formatCurrency(BigNumber(row?.earned).times(crv?.price)) - } - { - row.symbol === 'ibEUR' && - formatCurrency(BigNumber(row?.earned).times(ibEUR?.price)) - } - { - (row.symbol === 'rKP3R' || row.symbol === 'kp3R') && - formatCurrency(BigNumber(row?.earned).times(rKP3R?.price)) - - } - { - !['CRV', 'ibEUR', 'rKP3R', 'kp3R'].includes(row.symbol) && - formatCurrency(0) - } + + $ + {row.symbol === "CRV" && + formatCurrency( + BigNumber(row?.earned).times(crv?.price) + )} + {row.symbol === "ibEUR" && + formatCurrency( + BigNumber(row?.earned).times(ibEUR?.price) + )} + {(row.symbol === "rKP3R" || + row.symbol === "kp3R") && + formatCurrency( + BigNumber(row?.earned).times(rKP3R?.price) + )} + {!["CRV", "ibEUR", "rKP3R", "kp3R"].includes( + row.symbol + ) && formatCurrency(0)} - + -
-
-
-
- -
- -
- - -
- -
- - - +
+
); })} diff --git a/components/ffVest/ffVest.js b/components/ffVest/ffVest.js index 7ffd0e7..5ec22e2 100644 --- a/components/ffVest/ffVest.js +++ b/components/ffVest/ffVest.js @@ -1,12 +1,9 @@ import React, { useState, useEffect } from "react"; import BigNumber from "bignumber.js"; -import classes from "./ffVest.module.css"; import stores from "../../stores"; import { FIXED_FOREX_UPDATED } from "../../stores/constants"; import moment from "moment"; -import Lock from "./lock"; -import ExistingLock from "./existingLock"; import NoBalances from "./noBalances"; import Unlock from "./unlock"; import Loading from "./loading"; @@ -14,7 +11,7 @@ import Loading from "./loading"; export default function ffVest() { const [ibff, setIBFF] = useState(null); const [veIBFF, setVeIBFF] = useState(null); - const [veIBFFOld, setVeIBFFOld] = useState(null); + const [, setVeIBFFOld] = useState(null); useEffect(() => { const forexUpdated = () => { @@ -33,41 +30,23 @@ export default function ffVest() { }; }, []); - return ( - <> - {!ibff && !veIBFF && } - {ibff && veIBFF && BigNumber(ibff.balance).eq(0) && BigNumber(veIBFF.balance).eq(0) && BigNumber(veIBFF.vestingInfo.lockEnds).eq(0) && ( - - )} - {ibff && veIBFF && BigNumber(ibff.balance).gt(0) && BigNumber(veIBFF.balance).eq(0) && ( - - )} - {veIBFF && BigNumber(veIBFF.balance).gt(0) && ( - - )} - { - veIBFF && veIBFF.vestingInfo && BigNumber(veIBFF.vestingInfo.lockEnds).lte(moment().unix()) && BigNumber(veIBFF.vestingInfo.lockEnds).gt(0) && ( - - ) // Lock expired - } - - ); + const hasSomethingToUnlock = veIBFF && veIBFF.vestingInfo; + + if (!ibff || !veIBFF) { + return ; + } + if (hasSomethingToUnlock) { + return ( + + ); + } + return ; } diff --git a/components/ffVest/ffVest.module.css b/components/ffVest/ffVest.module.css index 84d029c..41c67e6 100644 --- a/components/ffVest/ffVest.module.css +++ b/components/ffVest/ffVest.module.css @@ -17,7 +17,7 @@ } .contentBox { - background: rgba(104,108,122,0.05); + background: rgba(104, 108, 122, 0.05); padding: 30px; border-radius: 5px; } @@ -113,7 +113,6 @@ .actionsContainer { width: 100%; margin-top: 10px; - } .actionButtonText { @@ -148,7 +147,7 @@ font-size: 20px !important; font-weight: bold !important; padding-bottom: 20px; - border-bottom: 1px solid rgba(104,108,122,0.2); + border-bottom: 1px solid rgba(104, 108, 122, 0.2); margin-bottom: 20px !important; } @@ -224,6 +223,14 @@ display: flex; flex: 1; } +.lockView { + display: flex; + flex: 1; + display: flex; + flex-direction: column; + /* align-items: center; */ + /* justify-content: center; */ +} .activeIcon { height: 10px; @@ -245,7 +252,7 @@ justify-content: center; border-radius: 30px; font-size: 11px !important; - border: 1px solid rgba(104,108,122,0.2); + border: 1px solid rgba(104, 108, 122, 0.2); position: absolute; top: -2px; right: 3px; diff --git a/components/ffVest/lock.js b/components/ffVest/lock.js index cbd37f7..ad170d5 100644 --- a/components/ffVest/lock.js +++ b/components/ffVest/lock.js @@ -1,42 +1,53 @@ -import React, { useState, useEffect } from 'react'; -import { Paper, Typography, Button, TextField, InputAdornment, CircularProgress, RadioGroup, Radio, FormControlLabel, Tooltip } from '@material-ui/core'; -import BigNumber from 'bignumber.js'; -import moment from 'moment'; -import { formatCurrency } from '../../utils'; -import classes from './ffVest.module.css'; - -import stores from '../../stores' +import React, { useState, useEffect } from "react"; +import { + Paper, + Typography, + Button, + TextField, + InputAdornment, + CircularProgress, + RadioGroup, + Radio, + FormControlLabel, + Tooltip, +} from "@material-ui/core"; +import BigNumber from "bignumber.js"; +import moment from "moment"; +import { formatCurrency } from "../../utils"; +import classes from "./ffVest.module.css"; + +import stores from "../../stores"; import { ERROR, FIXED_FOREX_APPROVE_VEST, FIXED_FOREX_VEST_APPROVED, FIXED_FOREX_VEST, - FIXED_FOREX_VESTED -} from '../../stores/constants'; -import AttachMoneyIcon from '@material-ui/icons/AttachMoney'; + FIXED_FOREX_VESTED, +} from "../../stores/constants"; export default function ffLock({ ibff, veIBFF, veIBFFOld }) { + const [approvalLoading, setApprovalLoading] = useState(false); + const [lockLoading, setLockLoading] = useState(false); - const [ approvalLoading, setApprovalLoading ] = useState(false) - const [ lockLoading, setLockLoading ] = useState(false) - - const [amount, setAmount] = useState(''); - const [amountError, setAmountError] = useState(false); - const [selectedValue, setSelectedValue] = useState('week'); - const [selectedDate, setSelectedDate] = useState(moment().add(7, 'days').format('YYYY-MM-DD')); - const [selectedDateError, setSelectedDateError] = useState(false); + const [amount, setAmount] = useState(""); + const [amountError] = useState(false); + const [selectedValue, setSelectedValue] = useState("week"); + const [selectedDate, setSelectedDate] = useState( + moment().add(7, "days").format("YYYY-MM-DD") + ); + const [selectedDateError] = useState(false); useEffect(() => { const lockReturned = () => { - setLockLoading(false) - } + setLockLoading(false); + }; const approveReturned = () => { - setApprovalLoading(false) - } + setApprovalLoading(false); + }; const errorReturned = () => { - setApprovalLoading(false) - setLockLoading(false) - } + setApprovalLoading(false); + setLockLoading(false); + }; stores.emitter.on(ERROR, errorReturned); stores.emitter.on(FIXED_FOREX_VEST_APPROVED, approveReturned); @@ -49,176 +60,243 @@ export default function ffLock({ ibff, veIBFF, veIBFFOld }) { }, []); const setAmountPercent = (percent) => { - setAmount(BigNumber(ibff.balance).times(percent).div(100).toFixed(ibff.decimals)); - } + setAmount( + BigNumber(ibff.balance).times(percent).div(100).toFixed(ibff.decimals) + ); + }; const handleDateChange = (event) => { setSelectedDate(event.target.value); setSelectedValue(null); - } + }; const handleChange = (event) => { setSelectedValue(event.target.value); let days = 0; switch (event.target.value) { - case 'week': + case "week": days = 7; break; - case 'month': + case "month": days = 30; break; - case 'year': + case "year": days = 365; break; - case 'years': + case "years": days = 1461; break; default: } - const newDate = moment().add(days, 'days').format('YYYY-MM-DD'); + const newDate = moment().add(days, "days").format("YYYY-MM-DD"); setSelectedDate(newDate); - } + }; const onApprove = () => { - setApprovalLoading(true) - stores.dispatcher.dispatch({ type: FIXED_FOREX_APPROVE_VEST, content: { amount } }) - } + setApprovalLoading(true); + stores.dispatcher.dispatch({ + type: FIXED_FOREX_APPROVE_VEST, + content: { amount }, + }); + }; const onLock = () => { - setLockLoading(true) + setLockLoading(true); - const selectedDateUnix = moment(selectedDate).unix() - stores.dispatcher.dispatch({ type: FIXED_FOREX_VEST, content: { amount, unlockTime: selectedDateUnix } }) - } + const selectedDateUnix = moment(selectedDate).unix(); + stores.dispatcher.dispatch({ + type: FIXED_FOREX_VEST, + content: { amount, unlockTime: selectedDateUnix }, + }); + }; const formatApproved = (am) => { - if(BigNumber(am).gte(1000000000000000)) { - return 'Approved Forever' + if (BigNumber(am).gte(1000000000000000)) { + return "Approved Forever"; } - return `Approved ${formatCurrency(am)}` - } + return `Approved ${formatCurrency(am)}`; + }; - let depositApprovalNotRequired = false - if(ibff) { - depositApprovalNotRequired = BigNumber(ibff.vestAllowance).gte(amount) || ((!amount || amount === '') && BigNumber(ibff.vestAllowance).gt(0) ) + let depositApprovalNotRequired = false; + if (ibff) { + depositApprovalNotRequired = + BigNumber(ibff.vestAllowance).gte(amount) || + ((!amount || amount === "") && BigNumber(ibff.vestAllowance).gt(0)); } - let min = 0 - if(BigNumber(veIBFFOld?.vestingInfo?.lockEnds).gt(0)) { - min = moment.unix(veIBFFOld?.vestingInfo?.lockEnds).format('YYYY-MM-DD') + let min = 0; + if (BigNumber(veIBFFOld?.vestingInfo?.lockEnds).gt(0)) { + min = moment.unix(veIBFFOld?.vestingInfo?.lockEnds).format("YYYY-MM-DD"); } else { - min = moment().add(7, 'days').format('YYYY-MM-DD') + min = moment().add(7, "days").format("YYYY-MM-DD"); } return ( <> - Vest KP3R to Earn Rewards - -
-
-
-
- - Vest Amount: - -
-
- { - setAmountPercent(100); - }} - className={classes.value} - noWrap - > - Balance: {formatCurrency(ibff ? ibff.balance : 0)} - + + Vest KP3R to Earn Rewards + + +
+
+
+
+ + Vest Amount: + +
+
+ { + setAmountPercent(100); + }} + className={classes.value} + noWrap + > + Balance: {formatCurrency(ibff ? ibff.balance : 0)} + +
+ { + setAmount(e.target.value); + }} + InputProps={{ + startAdornment: ( + + + + ), + }} + /> + + How many kp3r tokens you will be locking up. +
- { - setAmount(e.target.value); - }} - InputProps={{ - startAdornment: ( - - - - ), - }} - /> - How many kp3r tokens you will be locking up. -
-
-
-
- - Vest Expires: - - -
?
-
+
+
+
+ + Vest Expires: + + +
?
+
+
+ + + } + label="1 week" + labelPlacement="left" + /> + } + label="1 month" + labelPlacement="left" + /> + } + label="1 year" + labelPlacement="left" + /> + } + label="4 years" + labelPlacement="left" + /> +
- - - } label="1 week" labelPlacement="left" /> - } label="1 month" labelPlacement="left" /> - } label="1 year" labelPlacement="left" /> - } label="4 years" labelPlacement="left" /> -
-
-
- - + -
-

+ + {lockLoading ? `Locking` : `Lock`} + + {lockLoading && ( + + )} + +
+
+
+
); } diff --git a/components/ffVest/unlock.js b/components/ffVest/unlock.js index 7368069..14ba100 100644 --- a/components/ffVest/unlock.js +++ b/components/ffVest/unlock.js @@ -1,25 +1,25 @@ -import React, { useState, useEffect } from 'react'; -import { Paper, Typography, Button, CircularProgress } from '@material-ui/core'; -import classes from './ffVest.module.css'; +import React, { useState, useEffect } from "react"; +import { Paper, Typography, Button, CircularProgress } from "@material-ui/core"; +import classes from "./ffVest.module.css"; +import moment from "moment"; -import stores from '../../stores' +import stores from "../../stores"; import { ERROR, FIXED_FOREX_WITHDRAW_LOCK, - FIXED_FOREX_LOCK_WITHDRAWN -} from '../../stores/constants'; + FIXED_FOREX_LOCK_WITHDRAWN, +} from "../../stores/constants"; -export default function Unlock({ ibff, veIBFF }) { - - const [ lockLoading, setLockLoading ] = useState(false) +export default function Unlock({ hasExpired, expirationDate }) { + const [lockLoading, setLockLoading] = useState(false); useEffect(() => { const lockReturned = () => { - setLockLoading(false) - } + setLockLoading(false); + }; const errorReturned = () => { - setLockLoading(false) - } + setLockLoading(false); + }; stores.emitter.on(ERROR, errorReturned); stores.emitter.on(FIXED_FOREX_LOCK_WITHDRAWN, lockReturned); @@ -30,32 +30,49 @@ export default function Unlock({ ibff, veIBFF }) { }, []); const onWithdraw = () => { - setLockLoading(true) - stores.dispatcher.dispatch({ type: FIXED_FOREX_WITHDRAW_LOCK, content: { } }) - } + setLockLoading(true); + stores.dispatcher.dispatch({ + type: FIXED_FOREX_WITHDRAW_LOCK, + content: {}, + }); + }; + + const title = hasExpired + ? "Lock expired:" + : `Lock expires on ${moment(expirationDate * 1000).format( + "MM/DD/YYYY HH:mm" + )}`; + const message = hasExpired + ? "Your lock has expired. Please withdraw your lock before you can re-lock." + : "Your lock is not yet expired. Please wait until the lock expires before you can withdraw."; return ( - -
-
-
- Lock expired: - Your lock has expired. Please withdraw your lock before you can re-lock. -
-
-
- + + {lockLoading ? `Withrawing` : `Withdraw`} + + {lockLoading && ( + + )} + +
-
- + +
); } diff --git a/components/header/header.js b/components/header/header.js index 99c1443..e83a91a 100644 --- a/components/header/header.js +++ b/components/header/header.js @@ -1,34 +1,82 @@ -import React, { useState, useEffect } from 'react'; +import React, { useState, useEffect } from "react"; -import { Typography, Switch, Button, SvgIcon } from '@material-ui/core'; -import { withStyles } from '@material-ui/core/styles'; -import { withTheme } from '@material-ui/core/styles'; +import { Typography, Switch, Button, SvgIcon } from "@material-ui/core"; +import { withStyles } from "@material-ui/core/styles"; +import { withTheme } from "@material-ui/core/styles"; import { useRouter } from "next/router"; -import Paper from '@material-ui/core/Paper'; -import InputBase from '@material-ui/core/InputBase'; +import Paper from "@material-ui/core/Paper"; -import WbSunnyOutlinedIcon from '@material-ui/icons/WbSunnyOutlined'; -import Brightness2Icon from '@material-ui/icons/Brightness2'; -import ArrowBackIcon from '@material-ui/icons/ArrowBack'; -import MonetizationOnIcon from '@material-ui/icons/MonetizationOn'; +import WbSunnyOutlinedIcon from "@material-ui/icons/WbSunnyOutlined"; +import Brightness2Icon from "@material-ui/icons/Brightness2"; +import MonetizationOnIcon from "@material-ui/icons/MonetizationOn"; -import { CONNECT_WALLET,CONNECTION_DISCONNECTED, ACCOUNT_CONFIGURED, ACCOUNT_CHANGED, FIXED_FOREX_BALANCES_RETURNED, FIXED_FOREX_CLAIM_VECLAIM, FIXED_FOREX_VECLAIM_CLAIMED, FIXED_FOREX_UPDATED, ERROR } from '../../stores/constants'; +import { + CONNECT_WALLET, + ACCOUNT_CONFIGURED, + ACCOUNT_CHANGED, + FIXED_FOREX_BALANCES_RETURNED, + FIXED_FOREX_CLAIM_VECLAIM, + FIXED_FOREX_VECLAIM_CLAIMED, + FIXED_FOREX_UPDATED, + ERROR, +} from "../../stores/constants"; -import Unlock from '../unlock'; +import Unlock from "../unlock"; -import stores from '../../stores'; -import { formatAddress } from '../../utils'; +import stores from "../../stores"; +import { formatAddress } from "../../utils"; -import classes from './header.module.css'; -import HelpIcon from '@material-ui/icons/Help'; -import AboutModal from './aboutModal'; +import classes from "./header.module.css"; +import HelpIcon from "@material-ui/icons/Help"; +import AboutModal from "./aboutModal"; function WrongNetworkIcon(props) { - const { color, className } = props; + const { className } = props; return ( - - + + {" "} + {" "} + {" "} + + + ); } @@ -41,31 +89,31 @@ const StyledSwitch = withStyles((theme) => ({ }, switchBase: { paddingTop: 1.5, - width: '70%', - margin: 'auto', - borderRadius: '20px', - '&$checked': { - paddingTop: '6px', - transform: 'translateX(18px)', - color: 'rgba(128,128,128, 1)', - width: '25px', - height: '25px', - '& + $track': { - backgroundColor: 'rgba(0,0,0, 0.3)', + width: "70%", + margin: "auto", + borderRadius: "20px", + "&$checked": { + paddingTop: "6px", + transform: "translateX(18px)", + color: "rgba(128,128,128, 1)", + width: "25px", + height: "25px", + "& + $track": { + backgroundColor: "rgba(0,0,0, 0.3)", opacity: 1, }, }, - '&$focusVisible $thumb': { - color: '#ffffff', - border: '6px solid #fff', + "&$focusVisible $thumb": { + color: "#ffffff", + border: "6px solid #fff", }, }, track: { borderRadius: 32 / 2, - border: '1px solid rgba(104,108,122, 0.25)', - backgroundColor: 'rgba(0,0,0, 0)', + border: "1px solid rgba(104,108,122, 0.25)", + backgroundColor: "rgba(0,0,0, 0)", opacity: 1, - transition: theme.transitions.create(['background-color', 'border']), + transition: theme.transitions.create(["background-color", "border"]), }, checked: {}, focusVisible: {}, @@ -87,21 +135,22 @@ const StyledSwitch = withStyles((theme) => ({ }); function Header(props) { - - const accountStore = stores.accountStore.getStore('account'); + const accountStore = stores.accountStore.getStore("account"); const router = useRouter(); const [account, setAccount] = useState(accountStore); const [toggleAboutModal, setToggleAboutModal] = useState(false); - const [darkMode, setDarkMode] = useState(props.theme.palette.type === 'dark' ? true : false); + const [darkMode, setDarkMode] = useState( + props.theme.palette.type === "dark" ? true : false + ); const [unlockOpen, setUnlockOpen] = useState(false); - const [chainInvalid, setChainInvalid] = useState(false) - const [claimable, setClaimable] = useState(0) - const [loading, setLoading] = useState(false) + const [chainInvalid, setChainInvalid] = useState(false); + const [claimable, setClaimable] = useState(0); + const [loading, setLoading] = useState(false); useEffect(() => { const accountConfigure = () => { - const accountStore = stores.accountStore.getStore('account'); + const accountStore = stores.accountStore.getStore("account"); setAccount(accountStore); closeUnlock(); }; @@ -109,21 +158,21 @@ function Header(props) { onAddressClicked(); }; const accountChanged = () => { - const invalid = stores.accountStore.getStore('chainInvalid'); - setChainInvalid(invalid) - } + const invalid = stores.accountStore.getStore("chainInvalid"); + setChainInvalid(invalid); + }; const balancesReturned = () => { - const rewards = stores.fixedForexStore.getStore('rewards') - setClaimable(rewards?.veClaimRewards?.claimable) - } + const rewards = stores.fixedForexStore.getStore("rewards"); + setClaimable(rewards?.veClaimRewards?.claimable); + }; const claimedReturned = () => { - const rewards = stores.fixedForexStore.getStore('rewards') - setClaimable(rewards?.veClaimRewards?.claimable) - setLoading(false) - } + const rewards = stores.fixedForexStore.getStore("rewards"); + setClaimable(rewards?.veClaimRewards?.claimable); + setLoading(false); + }; - const invalid = stores.accountStore.getStore('chainInvalid'); - setChainInvalid(invalid) + const invalid = stores.accountStore.getStore("chainInvalid"); + setChainInvalid(invalid); stores.emitter.on(ACCOUNT_CONFIGURED, accountConfigure); stores.emitter.on(CONNECT_WALLET, connectWallet); @@ -137,13 +186,19 @@ function Header(props) { stores.emitter.removeListener(CONNECT_WALLET, connectWallet); stores.emitter.removeListener(ACCOUNT_CHANGED, accountChanged); stores.emitter.removeListener(FIXED_FOREX_UPDATED, balancesReturned); - stores.emitter.removeListener(FIXED_FOREX_BALANCES_RETURNED, balancesReturned); - stores.emitter.removeListener(FIXED_FOREX_VECLAIM_CLAIMED, claimedReturned); + stores.emitter.removeListener( + FIXED_FOREX_BALANCES_RETURNED, + balancesReturned + ); + stores.emitter.removeListener( + FIXED_FOREX_VECLAIM_CLAIMED, + claimedReturned + ); stores.emitter.removeListener(ERROR, claimedReturned); }; }, []); - const handleToggleChange = (event, val) => { + const handleToggleChange = (_, val) => { setDarkMode(val); props.changeTheme(val); }; @@ -157,81 +212,108 @@ function Header(props) { }; useEffect(function () { - const localStorageDarkMode = window.localStorage.getItem('yearn.finance-dark-mode'); - setDarkMode(localStorageDarkMode ? localStorageDarkMode === 'dark' : false); + const localStorageDarkMode = window.localStorage.getItem( + "yearn.finance-dark-mode" + ); + setDarkMode(localStorageDarkMode ? localStorageDarkMode === "dark" : false); }, []); - const navigate = (url) => { - router.push(url) - } - const callClaim = () => { - setLoading(true) - stores.dispatcher.dispatch({ type: FIXED_FOREX_CLAIM_VECLAIM, content: {} }) - } + setLoading(true); + stores.dispatcher.dispatch({ + type: FIXED_FOREX_CLAIM_VECLAIM, + content: {}, + }); + }; - const switchChain =async()=>{ + const switchChain = async () => { try { await window.ethereum.request({ - method: 'wallet_switchEthereumChain', - params: [{ chainId:'0x1' }], + method: "wallet_switchEthereumChain", + params: [{ chainId: "0x1" }], }); } catch (switchError) { - console.log("switch error",switchError) + console.log("switch error", switchError); } - } + }; return (
- { - props.title && - { props.title } - - } + {props.title && ( + {props.title} + )} - router.push('/dashboard')} className={classes.linkz}> - - - - - - - - - + + + + + + + + + - - - - - + + + + + - - - + + + - - + L18.3,12.2z" + /> + + -
} @@ -241,28 +323,32 @@ function Header(props) { />
- {account && account.address ? + {account && account.address ? (
- +
- : -
 
- } + ) : ( +
 
+ )} - {unlockOpen && } - {toggleAboutModal && } -
- {chainInvalid ? ( -
-
- - - The chain you're connected to isn't supported. Please check that your wallet is connected to Ethereum Mainnet. + color={props.theme.palette.type === "dark" ? "primary" : "secondary"} + onClick={onAddressClicked} + > + {account && account.address && ( +
+ )} + + {account && account.address + ? formatAddress(account.address) + : "Connect Wallet"} - + + {unlockOpen && ( + + )} + {toggleAboutModal && ( + + )} + + {chainInvalid ? ( +
+
+ + + The chain you're connected to isn't supported. Please check that + your wallet is connected to Ethereum Mainnet. + + +
-
- ) : null} + ) : null}
); } diff --git a/components/navigation/navigation.js b/components/navigation/navigation.js index cdfb0e3..af4fe78 100644 --- a/components/navigation/navigation.js +++ b/components/navigation/navigation.js @@ -1,33 +1,24 @@ -import React, { useState, useEffect } from 'react'; -import { Typography, Paper, Switch, Button, Tooltip, Grid } from '@material-ui/core'; -import { withTheme } from '@material-ui/core/styles'; -import { withStyles } from '@material-ui/core/styles'; - -import { useRouter } from 'next/router'; -import FFWarning from '../ffWarning'; -import MenuIcon from '@material-ui/icons/Menu'; -import CloseIcon from '@material-ui/icons/Close'; -import WbSunnyOutlinedIcon from '@material-ui/icons/WbSunnyOutlined'; -import Brightness2Icon from '@material-ui/icons/Brightness2'; -import ArrowBackIcon from '@material-ui/icons/ArrowBack'; - -import SwapHorizIcon from '@material-ui/icons/SwapHoriz'; -import TimerIcon from '@material-ui/icons/Timer'; -import HowToVoteIcon from '@material-ui/icons/HowToVote'; -import SpaceBarIcon from '@material-ui/icons/SpaceBar'; -import WarningIcon from '@material-ui/icons/Warning'; -import MonetizationOnIcon from '@material-ui/icons/MonetizationOn'; -import TableChartIcon from '@material-ui/icons/TableChart'; -import BuildIcon from '@material-ui/icons/Build'; +import React, { useState, useEffect } from "react"; +import { Typography, Paper, Switch, Button, Grid } from "@material-ui/core"; +import { withTheme } from "@material-ui/core/styles"; +import { withStyles } from "@material-ui/core/styles"; + +import { useRouter } from "next/router"; +import FFWarning from "../ffWarning"; +import MenuIcon from "@material-ui/icons/Menu"; +import CloseIcon from "@material-ui/icons/Close"; +import WbSunnyOutlinedIcon from "@material-ui/icons/WbSunnyOutlined"; +import Brightness2Icon from "@material-ui/icons/Brightness2"; +import ArrowBackIcon from "@material-ui/icons/ArrowBack"; import { SvgIcon } from "@material-ui/core"; -import Unlock from '../unlock'; +import Unlock from "../unlock"; -import stores from '../../stores'; -import { formatAddress } from '../../utils'; +import stores from "../../stores"; +import { formatAddress } from "../../utils"; -import classes from './navigation.module.css'; +import classes from "./navigation.module.css"; const StyledSwitch = withStyles((theme) => ({ root: { @@ -38,17 +29,17 @@ const StyledSwitch = withStyles((theme) => ({ }, switchBase: { padding: 1, - '&$checked': { - transform: 'translateX(28px)', - color: '#212529', - '& + $track': { - backgroundColor: '#ffffff', + "&$checked": { + transform: "translateX(28px)", + color: "#212529", + "& + $track": { + backgroundColor: "#ffffff", opacity: 1, }, }, - '&$focusVisible $thumb': { - color: '#ffffff', - border: '6px solid #fff', + "&$focusVisible $thumb": { + color: "#ffffff", + border: "6px solid #fff", }, }, thumb: { @@ -58,9 +49,9 @@ const StyledSwitch = withStyles((theme) => ({ track: { borderRadius: 32 / 2, border: `1px solid #212529`, - backgroundColor: '#212529', + backgroundColor: "#212529", opacity: 1, - transition: theme.transitions.create(['background-color', 'border']), + transition: theme.transitions.create(["background-color", "border"]), }, checked: {}, focusVisible: {}, @@ -84,7 +75,7 @@ const StyledSwitch = withStyles((theme) => ({ function Navigation(props) { const router = useRouter(); - const account = stores.accountStore.getStore('account'); + const account = stores.accountStore.getStore("account"); const [darkMode, setDarkMode] = useState(false); const [unlockOpen, setUnlockOpen] = useState(false); @@ -113,158 +104,78 @@ function Navigation(props) { }; useEffect(function () { - const localStorageDarkMode = window.localStorage.getItem('yearn.finance-dark-mode'); - setDarkMode(localStorageDarkMode ? localStorageDarkMode === 'dark' : false); + const localStorageDarkMode = window.localStorage.getItem( + "yearn.finance-dark-mode" + ); + setDarkMode(localStorageDarkMode ? localStorageDarkMode === "dark" : false); - const localStorageWarningAccepted = window.localStorage.getItem('fixed.forex-warning-accepted'); - setWarningOpen(localStorageWarningAccepted ? localStorageWarningAccepted !== 'accepted' : true); + const localStorageWarningAccepted = window.localStorage.getItem( + "fixed.forex-warning-accepted" + ); + setWarningOpen( + localStorageWarningAccepted + ? localStorageWarningAccepted !== "accepted" + : true + ); }, []); useEffect( function () { - setDarkMode(props.theme.palette.type === 'dark' ? true : false); + setDarkMode(props.theme.palette.type === "dark" ? true : false); }, - [props.theme], + [props.theme] ); const activePath = router.asPath; const renderNavs = () => { return ( - {renderNav( - 'Dashboard', - 'dashboard', - )} - {renderSubNav( - 'Swap', - 'swap', - )} + {renderNav("Dashboard", "dashboard")} + {renderSubNav("Swap", "swap")}
- {renderSectionHeader( - 'Collateral' - )} - {renderNav( - 'Mint Assets', - 'mint', - )} + {renderSectionHeader("Collateral")} + {renderNav("Mint Assets", "mint")}
- {renderSectionHeader( - 'Liquidity Providing' - )} -
+ {renderSectionHeader("Liquidity Providing")} +
{/* {renderSubNav( 'Curve + Convex + Yearn', 'home', )} */} - {renderSubNav( - 'Uniswap', - 'staking', - )} - {renderSubNav( - 'Withdraw Inactive', - 'withdraw', - )} + {renderSubNav("Uniswap", "staking")} + {renderSubNav("Withdraw Inactive", "withdraw")}
- {renderSectionHeader( - 'Rewards' - )} -
- {renderSubNav( - 'rKP3R Options', - 'options', - )} - {renderSubNav( - 'Claim', - 'rewards', - )} + {renderSectionHeader("Rewards")} +
+ {renderSubNav("rKP3R Options", "options")} + {renderSubNav("Claim", "rewards")}
- {renderSectionHeader( - 'Governance' - )} -
- {renderSubNav( - 'Vest', - 'vest', - )} - {renderSubNav( - 'Vote', - 'vote', - )} + {renderSectionHeader("Governance")} +
+ {renderSubNav("Vest", "vest")} + {renderSubNav("Vote", "vote")}
- {renderSectionHeader( - 'Stats' - )} - {renderNav( - 'Stats', - 'ffDashboard', - 'https://fixedforex.live/' - )} + {renderSectionHeader("Stats")} + {renderNav("Stats", "ffDashboard", "https://fixedforex.live/")}
); }; - /* - -
- {renderSubNav( - 'ibAUD', - 'asset/0x3F1B0278A9ee595635B61817630cC19DE792f506/curve', - , - , - )} - {renderSubNav( - 'ibCHF', - 'asset/0x9c2C8910F113181783c249d8F6Aa41b51Cde0f0c/curve', - , - , - )} - {renderSubNav( - 'ibEUR', - 'asset/0x96E61422b6A9bA0e068B6c5ADd4fFaBC6a4aae27/curve', - , - , - )} - {renderSubNav( - 'ibGBP', - 'asset/0xD6Ac1CB9019137a896343Da59dDE6d097F710538/curve', - , - , - )} - {renderSubNav( - 'ibJPY', - 'asset/0x8818a9bb44Fbf33502bE7c15c500d0C783B73067/curve', - , - , - )} - {renderSubNav( - 'ibKRW', - 'asset/0x95dFDC8161832e4fF7816aC4B6367CE201538253/curve', - , - , - )} -
- - */ - - const openWarning = () => { - setWarningOpen(true) - } - const closeWarning = () => { - window.localStorage.setItem('fixed.forex-warning-accepted', 'accepted'); - setWarningOpen(false) - } + window.localStorage.setItem("fixed.forex-warning-accepted", "accepted"); + setWarningOpen(false); + }; const renderSectionHeader = (title) => { return ( -
+
- {title} + + {title} +
); }; @@ -274,22 +185,28 @@ function Navigation(props) {
{ - - if(anotherLink) { - window.open(anotherLink, '_blank') + if (anotherLink) { + window.open(anotherLink, "_blank"); } else { - handleNavigate('/' + link); + handleNavigate("/" + link); } - }} > - {activePath.includes('/' + link) ? ( -
+ {activePath.includes("/" + link) ? ( +
) : (
)} - {title} - { anotherLink && '↗'} + + {title} + + {anotherLink && "↗"}
); }; @@ -299,15 +216,23 @@ function Navigation(props) {
{ - handleNavigate('/' + link); + handleNavigate("/" + link); }} > - {activePath.includes('/' + link) ? ( -
+ {activePath.includes("/" + link) ? ( +
) : (
)} - {title} + + {title} +
); }; @@ -315,7 +240,7 @@ function Navigation(props) { return ( @@ -362,52 +316,87 @@ function Navigation(props) { {menuOpen && (
-
{renderNavs()}
@@ -415,42 +404,61 @@ function Navigation(props) {
} - checkedIcon={} + checkedIcon={ + + } checked={darkMode} onChange={handleToggleChange} />
- - {unlockOpen && } + {unlockOpen && ( + + )}
)}
-
{props.backClicked && (
-
)} - {/*
- - - -
*/}
@@ -462,7 +470,9 @@ function Navigation(props) { > @@ -476,7 +486,12 @@ function Navigation(props) { rel="noopener noreferrer" > - + @@ -489,7 +504,9 @@ function Navigation(props) { > @@ -504,7 +521,9 @@ function Navigation(props) { > @@ -513,9 +532,7 @@ function Navigation(props) {
Version 0.9.0 - { warningOpen && - - } + {warningOpen && } ); } diff --git a/components/unlock/unlock.js b/components/unlock/unlock.js index 48f644a..6389318 100644 --- a/components/unlock/unlock.js +++ b/components/unlock/unlock.js @@ -15,19 +15,19 @@ import { import stores from "../../stores"; -const styles = theme => ({ +const styles = (theme) => ({ root: { flex: 1, height: "auto", display: "flex", - position: "relative" + position: "relative", }, contentContainer: { margin: "auto", textAlign: "center", padding: "12px", display: "flex", - flexWrap: "wrap" + flexWrap: "wrap", }, cardContainer: { marginTop: "60px", @@ -35,19 +35,19 @@ const styles = theme => ({ display: "flex", flexDirection: "column", justifyContent: "space-around", - alignItems: "center" + alignItems: "center", }, unlockCard: { - padding: "24px" + padding: "24px", }, buttonText: { marginLeft: "12px", - fontWeight: "700" + fontWeight: "700", }, instruction: { maxWidth: "400px", marginBottom: "32px", - marginTop: "32px" + marginTop: "32px", }, actionButton: { padding: "12px", @@ -56,18 +56,18 @@ const styles = theme => ({ border: "1px solid #E1E1E1", fontWeight: 500, [theme.breakpoints.up("md")]: { - padding: "15px" - } + padding: "15px", + }, }, connect: { - width: "100%" + width: "100%", }, closeIcon: { position: "absolute", right: "-8px", top: "-8px", - cursor: "pointer" - } + cursor: "pointer", + }, }); class Unlock extends Component { @@ -76,7 +76,7 @@ class Unlock extends Component { this.state = { loading: false, - error: null + error: null, }; } @@ -98,14 +98,14 @@ class Unlock extends Component { stores.emitter.removeListener(ERROR, this.error); } - error = err => { + error = (err) => { this.setState({ loading: false, error: err }); }; connectionConnected = () => { stores.dispatcher.dispatch({ type: CONFIGURE_FIXED_FOREX, - content: { connected: true } + content: { connected: true }, }); if (this.props.closeModal != null) { @@ -116,7 +116,7 @@ class Unlock extends Component { connectionDisconnected = () => { stores.dispatcher.dispatch({ type: CONFIGURE_FIXED_FOREX, - content: { connected: false} + content: { connected: false }, }); if (this.props.closeModal != null) { this.props.closeModal(); @@ -176,15 +176,8 @@ function MyComponent(props) { if (localContext) { localConnector = localContext.connector; } - const { - connector, - library, - account, - activate, - deactivate, - active, - error - } = context; + const { connector, library, account, activate, deactivate, active, error } = + context; var connectorsByName = stores.accountStore.getStore("connectorsByName"); const { closeModal } = props; @@ -200,7 +193,7 @@ function MyComponent(props) { if (account && active && library) { stores.accountStore.setStore({ account: { address: account }, - web3context: context + web3context: context, }); stores.emitter.emit(CONNECTION_CONNECTED); } @@ -214,10 +207,10 @@ function MyComponent(props) { display: "flex", flexWrap: "wrap", justifyContent: width > 576 ? "space-between" : "center", - alignItems: "center" + alignItems: "center", }} > - {Object.keys(connectorsByName).map(name => { + {Object.keys(connectorsByName).map((name) => { const currentConnector = connectorsByName[name]; const activating = currentConnector === activatingConnector; const connected = @@ -271,7 +264,7 @@ function MyComponent(props) { style={{ padding: "0px", display: "flex", - margin: width > 576 ? "12px 0px" : "0px" + margin: width > 576 ? "12px 0px" : "0px", }} >
)} diff --git a/components/welcomeHeader/welcomeHeader.js b/components/welcomeHeader/welcomeHeader.js index 0dd2ebe..40b93a1 100644 --- a/components/welcomeHeader/welcomeHeader.js +++ b/components/welcomeHeader/welcomeHeader.js @@ -1,33 +1,78 @@ -import React, { useState, useEffect } from 'react'; +import React, { useState, useEffect } from "react"; -import { Typography, Switch, Button, SvgIcon } from '@material-ui/core'; -import { withStyles } from '@material-ui/core/styles'; -import { withTheme } from '@material-ui/core/styles'; +import { Typography, Switch, Button, SvgIcon } from "@material-ui/core"; +import { withStyles } from "@material-ui/core/styles"; +import { withTheme } from "@material-ui/core/styles"; import { useRouter } from "next/router"; -import Paper from '@material-ui/core/Paper'; -import InputBase from '@material-ui/core/InputBase'; +import Paper from "@material-ui/core/Paper"; -import WbSunnyOutlinedIcon from '@material-ui/icons/WbSunnyOutlined'; -import Brightness2Icon from '@material-ui/icons/Brightness2'; -import ArrowBackIcon from '@material-ui/icons/ArrowBack'; -import MonetizationOnIcon from '@material-ui/icons/MonetizationOn'; +import WbSunnyOutlinedIcon from "@material-ui/icons/WbSunnyOutlined"; +import Brightness2Icon from "@material-ui/icons/Brightness2"; -import { CONNECT_WALLET,CONNECTION_DISCONNECTED, ACCOUNT_CONFIGURED, ACCOUNT_CHANGED, FIXED_FOREX_BALANCES_RETURNED, FIXED_FOREX_CLAIM_VECLAIM, FIXED_FOREX_VECLAIM_CLAIMED, FIXED_FOREX_UPDATED, ERROR } from '../../stores/constants'; +import { + CONNECT_WALLET, + ACCOUNT_CONFIGURED, + ACCOUNT_CHANGED, + FIXED_FOREX_BALANCES_RETURNED, + FIXED_FOREX_VECLAIM_CLAIMED, + FIXED_FOREX_UPDATED, + ERROR, +} from "../../stores/constants"; -import Unlock from '../unlock'; +import Unlock from "../unlock"; -import stores from '../../stores'; -import { formatAddress } from '../../utils'; +import stores from "../../stores"; +import { formatAddress } from "../../utils"; -import classes from './welcomeHeader.module.css'; -import HelpIcon from '@material-ui/icons/Help'; +import classes from "./welcomeHeader.module.css"; function WrongNetworkIcon(props) { - const { color, className } = props; + const { className } = props; return ( - - + + {" "} + {" "} + {" "} + + + ); } @@ -40,28 +85,28 @@ const StyledSwitch = withStyles((theme) => ({ }, switchBase: { paddingTop: 1.5, - width: '75%', - margin: 'auto', - '&$checked': { - transform: 'translateX(28px)', - color: 'rgba(128,128,128, 1)', - width: '30%', - '& + $track': { - backgroundColor: 'rgba(0,0,0, 0.3)', + width: "75%", + margin: "auto", + "&$checked": { + transform: "translateX(28px)", + color: "rgba(128,128,128, 1)", + width: "30%", + "& + $track": { + backgroundColor: "rgba(0,0,0, 0.3)", opacity: 1, }, }, - '&$focusVisible $thumb': { - color: '#ffffff', - border: '6px solid #fff', + "&$focusVisible $thumb": { + color: "#ffffff", + border: "6px solid #fff", }, }, track: { borderRadius: 32 / 2, - border: '1px solid rgba(128,128,128, 0.2)', - backgroundColor: 'rgba(0,0,0, 0)', + border: "1px solid rgba(128,128,128, 0.2)", + backgroundColor: "rgba(0,0,0, 0)", opacity: 1, - transition: theme.transitions.create(['background-color', 'border']), + transition: theme.transitions.create(["background-color", "border"]), }, checked: {}, focusVisible: {}, @@ -83,21 +128,21 @@ const StyledSwitch = withStyles((theme) => ({ }); function Header(props) { - - const accountStore = stores.accountStore.getStore('account'); + const accountStore = stores.accountStore.getStore("account"); const router = useRouter(); const [account, setAccount] = useState(accountStore); - const [toggleAboutModal, setToggleAboutModal] = useState(false); - const [darkMode, setDarkMode] = useState(props.theme.palette.type === 'dark' ? true : false); + const [darkMode, setDarkMode] = useState( + props.theme.palette.type === "dark" ? true : false + ); const [unlockOpen, setUnlockOpen] = useState(false); - const [chainInvalid, setChainInvalid] = useState(false) - const [claimable, setClaimable] = useState(0) - const [loading, setLoading] = useState(false) + const [chainInvalid, setChainInvalid] = useState(false); + const [, setClaimable] = useState(0); + const [, setLoading] = useState(false); useEffect(() => { const accountConfigure = () => { - const accountStore = stores.accountStore.getStore('account'); + const accountStore = stores.accountStore.getStore("account"); setAccount(accountStore); closeUnlock(); }; @@ -105,21 +150,21 @@ function Header(props) { onAddressClicked(); }; const accountChanged = () => { - const invalid = stores.accountStore.getStore('chainInvalid'); - setChainInvalid(invalid) - } + const invalid = stores.accountStore.getStore("chainInvalid"); + setChainInvalid(invalid); + }; const balancesReturned = () => { - const rewards = stores.fixedForexStore.getStore('rewards') - setClaimable(rewards?.veClaimRewards?.claimable) - } + const rewards = stores.fixedForexStore.getStore("rewards"); + setClaimable(rewards?.veClaimRewards?.claimable); + }; const claimedReturned = () => { - const rewards = stores.fixedForexStore.getStore('rewards') - setClaimable(rewards?.veClaimRewards?.claimable) - setLoading(false) - } + const rewards = stores.fixedForexStore.getStore("rewards"); + setClaimable(rewards?.veClaimRewards?.claimable); + setLoading(false); + }; - const invalid = stores.accountStore.getStore('chainInvalid'); - setChainInvalid(invalid) + const invalid = stores.accountStore.getStore("chainInvalid"); + setChainInvalid(invalid); stores.emitter.on(ACCOUNT_CONFIGURED, accountConfigure); stores.emitter.on(CONNECT_WALLET, connectWallet); @@ -133,8 +178,14 @@ function Header(props) { stores.emitter.removeListener(CONNECT_WALLET, connectWallet); stores.emitter.removeListener(ACCOUNT_CHANGED, accountChanged); stores.emitter.removeListener(FIXED_FOREX_UPDATED, balancesReturned); - stores.emitter.removeListener(FIXED_FOREX_BALANCES_RETURNED, balancesReturned); - stores.emitter.removeListener(FIXED_FOREX_VECLAIM_CLAIMED, claimedReturned); + stores.emitter.removeListener( + FIXED_FOREX_BALANCES_RETURNED, + balancesReturned + ); + stores.emitter.removeListener( + FIXED_FOREX_VECLAIM_CLAIMED, + claimedReturned + ); stores.emitter.removeListener(ERROR, claimedReturned); }; }, []); @@ -153,77 +204,97 @@ function Header(props) { }; useEffect(function () { - const localStorageDarkMode = window.localStorage.getItem('yearn.finance-dark-mode'); - setDarkMode(localStorageDarkMode ? localStorageDarkMode === 'dark' : false); + const localStorageDarkMode = window.localStorage.getItem( + "yearn.finance-dark-mode" + ); + setDarkMode(localStorageDarkMode ? localStorageDarkMode === "dark" : false); }, []); - const navigate = (url) => { - router.push(url) - } - - const callClaim = () => { - setLoading(true) - stores.dispatcher.dispatch({ type: FIXED_FOREX_CLAIM_VECLAIM, content: {} }) - } - - const switchChain =async()=>{ + const switchChain = async () => { try { await window.ethereum.request({ - method: 'wallet_switchEthereumChain', - params: [{ chainId:'0x1' }], + method: "wallet_switchEthereumChain", + params: [{ chainId: "0x1" }], }); } catch (switchError) { - console.log("switch error",switchError) + console.log("switch error", switchError); } - } + }; return (
- { - props.title && - { props.title } - - } - router.push('/')} className={classes.linkz}> - - - - - - - - - + + + + + + + + + - - - - - + + + + + - - - + + + - - + L18.3,12.2z" + /> + +
@@ -235,29 +306,44 @@ function Header(props) { />
- - {unlockOpen && } -
- {chainInvalid ? ( -
-
- - - The chain you're connected to isn't supported. Please check that your wallet is connected to Ethereum Mainnet. + color={props.theme.palette.type === "dark" ? "primary" : "secondary"} + onClick={onAddressClicked} + > + {account && account.address && ( +
+ )} + + {account && account.address + ? formatAddress(account.address) + : "Connect Wallet"} - + + {unlockOpen && ( + + )} + + {chainInvalid ? ( +
+
+ + + The chain you're connected to isn't supported. Please check that + your wallet is connected to Ethereum Mainnet. + + +
-
- ) : null} + ) : null}
); } diff --git a/next.config.js b/next.config.js index 06c3877..f053ebf 100644 --- a/next.config.js +++ b/next.config.js @@ -1,12 +1 @@ -module.exports = { - webpack: (config, { isServer }) => { - // Fixes npm packages that depend on `fs` module - if (!isServer) { - config.node = { - fs: 'empty' - } - } - - return config - }, -} +module.exports = {}; diff --git a/package.json b/package.json index 53f7837..11c9b2c 100644 --- a/package.json +++ b/package.json @@ -28,11 +28,11 @@ "bignumber.js": "^9.0.1", "flux": "^4.0.1", "moment": "^2.29.1", - "next": "^10.2.3", + "next": "^15.3.0", "node-fetch": "^2.6.2", "query-string": "^7.0.1", - "react": "17.0.1", - "react-dom": "17.0.1", + "react": "18.2.0", + "react-dom": "18.2.0", "recharts": "^2.1.2", "web3": "^1.5.2" }, diff --git a/pages/configure/index.js b/pages/configure/index.js index a68371d..87a9a1b 100644 --- a/pages/configure/index.js +++ b/pages/configure/index.js @@ -2,8 +2,7 @@ import { SvgIcon } from "@material-ui/core"; import { withTheme } from "@material-ui/core/styles"; import classes from "./configure.module.css"; -function YearnIcon(props) { - const { color, className, width, height } = props; +function YearnIcon() { return ( - - - - - - - + + + + + + - - - - - + + + + + - - - + + + - + L18.3,12.2z" + /> + ); } @@ -51,16 +79,12 @@ function Configure({ theme }) {
{ const that = this; - const res = window.ethereum.on('accountsChanged', function (accounts) { + window.ethereum.on("accountsChanged", function (accounts) { that.setStore({ account: { address: accounts[0] }, web3context: { library: { provider: window.ethereum } }, @@ -146,7 +141,7 @@ class Store { }); }); - window.ethereum.on('chainChanged', function (chainId) { + window.ethereum.on("chainChanged", function (chainId) { const supportedChainIds = [1]; const parsedChainId = parseInt(chainId, 16); const isChainSupported = supportedChainIds.includes(parsedChainId); @@ -154,7 +149,7 @@ class Store { that.emitter.emit(ACCOUNT_CHANGED); that.emitter.emit(ACCOUNT_CONFIGURED); - that.configure() + that.configure(); }); }; @@ -164,17 +159,17 @@ class Store { const block = await web3.eth.getBlockNumber(); this.setStore({ currentBlock: block }); } catch (ex) { - console.log(ex); + console.error(ex); } }; getGasPrices = async (payload) => { const gasPrices = await this._getGasPrices(); - let gasSpeed = localStorage.getItem('yearn.finance-gas-speed'); + let gasSpeed = localStorage.getItem("yearn.finance-gas-speed"); if (!gasSpeed) { - gasSpeed = 'fast'; - localStorage.getItem('yearn.finance-gas-speed', 'fast'); + gasSpeed = "fast"; + localStorage.getItem("yearn.finance-gas-speed", "fast"); } this.setStore({ gasPrices: gasPrices, gasSpeed: gasSpeed }); @@ -191,8 +186,8 @@ class Store { return priceJSON; } } catch (e) { - console.log(e); - const web3 = await this._getWeb3Provider(); + console.error(e); + const web3 = await this.getWeb3Provider(); const gasPrice = await web3.eth.getGasPrice(); const gasPriceInGwei = web3.utils.fromWei(gasPrice, "gwei"); return { @@ -203,12 +198,7 @@ class Store { } }; - getGasPrice = async speed => { - let gasSpeed = speed; - if (!speed) { - gasSpeed = this.getStore('gasSpeed'); - } - + getGasPrice = async (speed) => { try { const web3 = await this.getWeb3Provider(); const gasPrice = await web3.eth.getGasPrice(); @@ -221,11 +211,11 @@ class Store { }; getWeb3Provider = async () => { - let web3context = this.getStore('web3context'); + let web3context = this.getStore("web3context"); let provider = null; if (!web3context) { - provider = network.providers['1']; + provider = network.providers["1"]; } else { provider = web3context.library.provider; } diff --git a/stores/constants/constants.js b/stores/constants/constants.js index 2289fcb..0c46966 100644 --- a/stores/constants/constants.js +++ b/stores/constants/constants.js @@ -1,357 +1,442 @@ -import BigNumber from 'bignumber.js' +import BigNumber from "bignumber.js"; // URLS -export const GAS_PRICE_API = 'https://gasprice.poa.network/' -export const ZAPPER_GAS_PRICE_API = 'https://api.zapper.fi/v1/gas-price?api_key=96e0cc51-a62e-42ca-acee-910ea7d2a241' -export const ETHERSCAN_URL = 'https://etherscan.io/' -export const CURVE_FI_STATS_API = 'https://api.curve.fi/' - -export const CREAM_PRICE_ORACLE_ADDRESS = '0xde19f5a7cf029275be9cec538e81aa298e297266' -export const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000' -export const FF_FEE_DISTRIBUTION_LOOKUP_ADDRESS = '0x7779C09F6a42834758349C31A26471483E8D2D71' -export const FF_MULTICALL_ADDRESS = '0xb1c3f9277fb3a7a3220c18435e7c7d10d34a569a' // -> get data in 3 calls -export const IBEUR_ETH_ADDRESS = '0xa2d81bedf22201a77044cdf3ab4d9dc1ffbc391b' // -> sushi lp pair for EUR -export const IBFF_ADDRESS = '0xb347132eFf18a3f63426f4988ef626d2CbE274F5' // -> reward asset (think CRV) -export const VEIBFF_ADDRESS = '0x4d0518c9136025903751209ddddf6c67067357b1' // -> vested reward asset (think veCRV) -export const FF_FAUCET_ADDRESS = '0x7d254d9adc588126edaee52a1029278180a802e8' // -> stake sushi lp pair, get reward asset -export const FF_FEE_CLAIM_DISTRIBUTION_ADDRESS = '0x27761efeb0c7b411e71d0fd0aee5dde35c810cc2' // -> after locking, get protocol fees -export const GAUGE_PROXY_ADDRESS = '0x81a8CAb6bb568fC94bCa70C9AdbFCF05592dEd7b' // -> gauge proxy for voting etc. -export const FF_VEIBFF_DISTRIBUTION_ADDRESS = '0x15E61581AFa2707bca42Bae529387eEa11f68E6e' // -> some other distribution contract ???? -export const FF_BOOST_DELEGATE_ADDRESS = '0x0ea89fb2E5b8FA8F14b741ffe1A4617A32611DfC' -export const FF_CRV_ADDRESS = '0xd533a949740bb3306d119cc777fa900ba034cd52' -export const FF_CVX_ADDRESS = '0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B' - -export const FF_IBEUR_CLAIMABLE_ADDRESS = '0xB9d18ab94cf61bB2Bcebe6aC8Ba8c19fF0CDB0cA' -export const FF_KP3R_CLAIMABLE_ADDRESS = '0xd4260B2781e2460f49dB746112BB592ba3fb6382' -export const FF_CURVE_TOKEN_MINTER_ADDRESS = '0xd061D61a4d941c39E5453435B6345Dc261C2fcE0' -export const FF_RKP3R_ADDRESS = '0xEdB67Ee1B171c4eC66E6c10EC43EDBbA20FaE8e9' -export const FF_OKP3R_ADDRESS = '0xba15ab4c5b27917e19f772c9718095e248feff35' -export const FF_STAKING_REWARDS_V3_ADDRESS = '0x68924dbd6eb82bFe666B2E0403f4cd1Cd6790C3f' -export const FF_UNSIWAP_POSITIONS_MANAGER_ADDRESS = '0xC36442b4a4522E871399CD717aBDD847Ab11FE88' -export const FF_CURVE_GAUGE_CONTROLLER = '0x2f50d538606fa9edd2b11e2446beb18c9d5846bb' - -export const FF_CONVEX_POOL_MANAGEMENT_ADDRESS = '0xF403C135812408BFbE8713b5A23a04b3D48AAE31' -export const FF_CONVEX_CLAIM_ZAP = '0x92Cf9E5e4D1Dfbf7dA0d2BB3e884a68416a65070' - -export const FF_IBAMM_ADDRESS = '0x8338aa899fb3168598d871edc1fe2b4f0ca6bbef' -export const FF_IBAMM_V2_ADDRESS = '0x34fFE9469D518ecbaa8dAeD2683B0344C71F08E1' -export const FF_IBAMM_V3_ADDRESS = '0x0a0B06322825cb979678C722BA9932E0e4B5fd90' - -export const FF_KP3R_ADDRESS = '0x1cEB5cB57C4D4E2b2433641b95Dd330A33185A44' -export const FF_VEKP3R_ADDRESS = '0x2FC52C61fB0C03489649311989CE2689D93dC1a2' -export const FF_VECLAIM_ADDRESS = '0x076BBBD5384acd0550D8D58Bc758Dd9E0287CCCF' - -export const IBKRW_ADDRESS = '0x95dFDC8161832e4fF7816aC4B6367CE201538253' // -> KRW -export const IBKRW_GAUGE_ADDRESS = '0x1750a3a3d80A3F5333BBe9c4695B0fAd41061ab1' // -> KRW Gauge -export const IBKRW_POOL_ADDRESS = '0x8461A004b50d321CB22B7d034969cE6803911899' // -> KRW Pool -export const IBKRW_CONVEX_GAUGE_ADDRESS = '0x8F18C0AF0d7d511E8Bdc6B3c64926B04EDfE4892' -export const IBKRW_YEARN_GAUGE_ADDRESS = '0x528D50dC9a333f01544177a924893FA1F5b9F748' -export const IBKRW_CONVEX_PID = 47 +export const GAS_PRICE_API = "https://gasprice.poa.network/"; +export const ZAPPER_GAS_PRICE_API = + "https://api.zapper.fi/v1/gas-price?api_key=96e0cc51-a62e-42ca-acee-910ea7d2a241"; +export const ETHERSCAN_URL = "https://etherscan.io/"; +export const CURVE_FI_STATS_API = "https://api.curve.fi/"; + +export const CREAM_PRICE_ORACLE_ADDRESS = + "0xde19f5a7cf029275be9cec538e81aa298e297266"; +export const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000"; +export const FF_FEE_DISTRIBUTION_LOOKUP_ADDRESS = + "0x7779C09F6a42834758349C31A26471483E8D2D71"; +export const FF_MULTICALL_ADDRESS = + "0xb1c3f9277fb3a7a3220c18435e7c7d10d34a569a"; // -> get data in 3 calls +export const IBEUR_ETH_ADDRESS = "0xa2d81bedf22201a77044cdf3ab4d9dc1ffbc391b"; // -> sushi lp pair for EUR +export const IBFF_ADDRESS = "0xb347132eFf18a3f63426f4988ef626d2CbE274F5"; // -> reward asset (think CRV) +export const VEIBFF_ADDRESS = "0x4d0518c9136025903751209ddddf6c67067357b1"; // -> vested reward asset (think veCRV) +export const FF_FAUCET_ADDRESS = "0x7d254d9adc588126edaee52a1029278180a802e8"; // -> stake sushi lp pair, get reward asset +export const FF_FEE_CLAIM_DISTRIBUTION_ADDRESS = + "0x27761efeb0c7b411e71d0fd0aee5dde35c810cc2"; // -> after locking, get protocol fees +export const GAUGE_PROXY_ADDRESS = "0x81a8CAb6bb568fC94bCa70C9AdbFCF05592dEd7b"; // -> gauge proxy for voting etc. +export const FF_VEIBFF_DISTRIBUTION_ADDRESS = + "0x15E61581AFa2707bca42Bae529387eEa11f68E6e"; // -> some other distribution contract ???? +export const FF_BOOST_DELEGATE_ADDRESS = + "0x0ea89fb2E5b8FA8F14b741ffe1A4617A32611DfC"; +export const FF_CRV_ADDRESS = "0xd533a949740bb3306d119cc777fa900ba034cd52"; +export const FF_CVX_ADDRESS = "0x4e3FBD56CD56c3e72c1403e103b45Db9da5B9D2B"; + +export const FF_IBEUR_CLAIMABLE_ADDRESS = + "0xB9d18ab94cf61bB2Bcebe6aC8Ba8c19fF0CDB0cA"; +export const FF_KP3R_CLAIMABLE_ADDRESS = + "0xd4260B2781e2460f49dB746112BB592ba3fb6382"; +export const FF_CURVE_TOKEN_MINTER_ADDRESS = + "0xd061D61a4d941c39E5453435B6345Dc261C2fcE0"; +export const FF_RKP3R_ADDRESS = "0xEdB67Ee1B171c4eC66E6c10EC43EDBbA20FaE8e9"; +export const FF_OKP3R_ADDRESS = "0xba15ab4c5b27917e19f772c9718095e248feff35"; +export const FF_STAKING_REWARDS_V3_ADDRESS = + "0x68924dbd6eb82bFe666B2E0403f4cd1Cd6790C3f"; +export const FF_UNSIWAP_POSITIONS_MANAGER_ADDRESS = + "0xC36442b4a4522E871399CD717aBDD847Ab11FE88"; +export const FF_CURVE_GAUGE_CONTROLLER = + "0x2f50d538606fa9edd2b11e2446beb18c9d5846bb"; + +export const FF_CONVEX_POOL_MANAGEMENT_ADDRESS = + "0xF403C135812408BFbE8713b5A23a04b3D48AAE31"; +export const FF_CONVEX_CLAIM_ZAP = "0x92Cf9E5e4D1Dfbf7dA0d2BB3e884a68416a65070"; + +export const FF_IBAMM_ADDRESS = "0x8338aa899fb3168598d871edc1fe2b4f0ca6bbef"; +export const FF_IBAMM_V2_ADDRESS = "0x34fFE9469D518ecbaa8dAeD2683B0344C71F08E1"; +export const FF_IBAMM_V3_ADDRESS = "0x0a0B06322825cb979678C722BA9932E0e4B5fd90"; + +export const FF_KP3R_ADDRESS = "0x1cEB5cB57C4D4E2b2433641b95Dd330A33185A44"; +export const FF_VEKP3R_ADDRESS = "0x2FC52C61fB0C03489649311989CE2689D93dC1a2"; +export const FF_VECLAIM_ADDRESS = "0x076BBBD5384acd0550D8D58Bc758Dd9E0287CCCF"; + +export const IBKRW_ADDRESS = "0x95dFDC8161832e4fF7816aC4B6367CE201538253"; // -> KRW +export const IBKRW_GAUGE_ADDRESS = "0x1750a3a3d80A3F5333BBe9c4695B0fAd41061ab1"; // -> KRW Gauge +export const IBKRW_POOL_ADDRESS = "0x8461A004b50d321CB22B7d034969cE6803911899"; // -> KRW Pool +export const IBKRW_CONVEX_GAUGE_ADDRESS = + "0x8F18C0AF0d7d511E8Bdc6B3c64926B04EDfE4892"; +export const IBKRW_YEARN_GAUGE_ADDRESS = + "0x528D50dC9a333f01544177a924893FA1F5b9F748"; +export const IBKRW_CONVEX_PID = 47; // kp3r + Eth -export const KP3RETH_ORACLE = '0x86BBD9ac8B9B44C95FFc6BAAe58E25033B7548AA' -export const KP3RETH_ADDRESS = '0x4647B6D835f3B393C7A955df51EEfcf0db961606' -export const KP3RETH_GAUGE_ADDRESS = '0x6d3328F0333f6FB0B2FaC87cF5a0FFa7e77beB60' -export const KP3RETH_POOL_ADDRESS = '0x21410232b484136404911780bc32756d5d1a9fa9' -export const KP3RETH_YEARN_GAUGE_ADDRESS = '' -export const KP3RETH_CONVEX_GAUGE_ADDRESS = '0x0c2da920E577960f39991030CfBdd4cF0a0CfEBD' -export const KP3RETH_CONVEX_PID = 90 - +export const KP3RETH_ORACLE = "0x86BBD9ac8B9B44C95FFc6BAAe58E25033B7548AA"; +export const KP3RETH_ADDRESS = "0x4647B6D835f3B393C7A955df51EEfcf0db961606"; +export const KP3RETH_GAUGE_ADDRESS = + "0x6d3328F0333f6FB0B2FaC87cF5a0FFa7e77beB60"; +export const KP3RETH_POOL_ADDRESS = + "0x21410232b484136404911780bc32756d5d1a9fa9"; +export const KP3RETH_YEARN_GAUGE_ADDRESS = ""; +export const KP3RETH_CONVEX_GAUGE_ADDRESS = + "0x0c2da920E577960f39991030CfBdd4cF0a0CfEBD"; +export const KP3RETH_CONVEX_PID = 90; // ibAUD + USDC -export const IBAUDUSDC_ORACLE = '0x86BBD9ac8B9B44C95FFc6BAAe58E25033B7548AA' -export const IBAUDUSDC_ADDRESS = '0x54c8Ecf46A81496eEB0608BD3353388b5D7a2a33' -export const IBAUDUSDC_GAUGE_ADDRESS = '0x1779AEB087C5BdBe48749ab03575f5f25D1DEeaF' -export const IBAUDUSDC_POOL_ADDRESS = '0x5b692073f141c31384fae55856cfb6cbffe91e60' -export const IBAUDUSDC_YEARN_GAUGE_ADDRESS = '' -export const IBAUDUSDC_CONVEX_GAUGE_ADDRESS = '0xbAFC4FAeB733C18411886A04679F11877D8629b1' -export const IBAUDUSDC_CONVEX_PID = 84 +export const IBAUDUSDC_ORACLE = "0x86BBD9ac8B9B44C95FFc6BAAe58E25033B7548AA"; +export const IBAUDUSDC_ADDRESS = "0x54c8Ecf46A81496eEB0608BD3353388b5D7a2a33"; +export const IBAUDUSDC_GAUGE_ADDRESS = + "0x1779AEB087C5BdBe48749ab03575f5f25D1DEeaF"; +export const IBAUDUSDC_POOL_ADDRESS = + "0x5b692073f141c31384fae55856cfb6cbffe91e60"; +export const IBAUDUSDC_YEARN_GAUGE_ADDRESS = ""; +export const IBAUDUSDC_CONVEX_GAUGE_ADDRESS = + "0xbAFC4FAeB733C18411886A04679F11877D8629b1"; +export const IBAUDUSDC_CONVEX_PID = 84; // ibCHF + USDC -export const IBCHFUSDC_ORACLE = '0x1b3E95E8ECF7A7caB6c4De1b344F94865aBD12d5' -export const IBCHFUSDC_ADDRESS = '0x08ceA8E5B4551722dEB97113C139Dd83C26c5398' -export const IBCHFUSDC_GAUGE_ADDRESS = '0x36C66bC294fEf4e94B3e40A1801d0AB0085Fe96e' -export const IBCHFUSDC_POOL_ADDRESS = '0x6df0d77f0496ce44e72d695943950d8641fca5cf' -export const IBCHFUSDC_YEARN_GAUGE_ADDRESS = '' -export const IBCHFUSDC_CONVEX_GAUGE_ADDRESS = '0x9BEc26bDd9702F4e0e4de853dd65Ec75F90b1F2e' -export const IBCHFUSDC_CONVEX_PID = 85 +export const IBCHFUSDC_ORACLE = "0x1b3E95E8ECF7A7caB6c4De1b344F94865aBD12d5"; +export const IBCHFUSDC_ADDRESS = "0x08ceA8E5B4551722dEB97113C139Dd83C26c5398"; +export const IBCHFUSDC_GAUGE_ADDRESS = + "0x36C66bC294fEf4e94B3e40A1801d0AB0085Fe96e"; +export const IBCHFUSDC_POOL_ADDRESS = + "0x6df0d77f0496ce44e72d695943950d8641fca5cf"; +export const IBCHFUSDC_YEARN_GAUGE_ADDRESS = ""; +export const IBCHFUSDC_CONVEX_GAUGE_ADDRESS = + "0x9BEc26bDd9702F4e0e4de853dd65Ec75F90b1F2e"; +export const IBCHFUSDC_CONVEX_PID = 85; // ibEUR + USDC -export const IBEURUSDC_ORACLE = '0x00e5c0774A5F065c285068170b20393925C84BF3' -export const IBEURUSDC_ADDRESS = '0x8682Fbf0CbF312C891532BA9F1A91e44f81ad7DF' -export const IBEURUSDC_GAUGE_ADDRESS = '0xE1D520B1263D6Be5678568BD699c84F7f9086023' -export const IBEURUSDC_POOL_ADDRESS = '0x1570af3df649fc74872c5b8f280a162a3bdd4eb6' -export const IBEURUSDC_YEARN_GAUGE_ADDRESS = '' -export const IBEURUSDC_CONVEX_GAUGE_ADDRESS = '0xAab7202D93B5633eB7FB3b80873C817B240F6F44' -export const IBEURUSDC_CONVEX_PID = 86 +export const IBEURUSDC_ORACLE = "0x00e5c0774A5F065c285068170b20393925C84BF3"; +export const IBEURUSDC_ADDRESS = "0x8682Fbf0CbF312C891532BA9F1A91e44f81ad7DF"; +export const IBEURUSDC_GAUGE_ADDRESS = + "0xE1D520B1263D6Be5678568BD699c84F7f9086023"; +export const IBEURUSDC_POOL_ADDRESS = + "0x1570af3df649fc74872c5b8f280a162a3bdd4eb6"; +export const IBEURUSDC_YEARN_GAUGE_ADDRESS = ""; +export const IBEURUSDC_CONVEX_GAUGE_ADDRESS = + "0xAab7202D93B5633eB7FB3b80873C817B240F6F44"; +export const IBEURUSDC_CONVEX_PID = 86; // ibGBP + USDC -export const IBGBPUSDC_ORACLE = '0xecaB2C76f1A8359A06fAB5fA0CEea51280A97eCF' -export const IBGBPUSDC_ADDRESS = '0x22CF19EB64226e0E1A79c69b345b31466fD273A7' -export const IBGBPUSDC_GAUGE_ADDRESS = '0x1Ba86c33509013c937344f6e231DA2E63ea45197' -export const IBGBPUSDC_POOL_ADDRESS = '0xacce4fe9ce2a6fe9af83e7cf321a3ff7675e0ab6' -export const IBGBPUSDC_YEARN_GAUGE_ADDRESS = '' -export const IBGBPUSDC_CONVEX_GAUGE_ADDRESS = '0x8C87E32000ADD1a7D7D69a1AE180C415AF769361' -export const IBGBPUSDC_CONVEX_PID = 87 +export const IBGBPUSDC_ORACLE = "0xecaB2C76f1A8359A06fAB5fA0CEea51280A97eCF"; +export const IBGBPUSDC_ADDRESS = "0x22CF19EB64226e0E1A79c69b345b31466fD273A7"; +export const IBGBPUSDC_GAUGE_ADDRESS = + "0x1Ba86c33509013c937344f6e231DA2E63ea45197"; +export const IBGBPUSDC_POOL_ADDRESS = + "0xacce4fe9ce2a6fe9af83e7cf321a3ff7675e0ab6"; +export const IBGBPUSDC_YEARN_GAUGE_ADDRESS = ""; +export const IBGBPUSDC_CONVEX_GAUGE_ADDRESS = + "0x8C87E32000ADD1a7D7D69a1AE180C415AF769361"; +export const IBGBPUSDC_CONVEX_PID = 87; // ibJPY + USDC -export const IBJPYUSDC_ORACLE = '0x215F34af6557A6598DbdA9aa11cc556F5AE264B1' -export const IBJPYUSDC_ADDRESS = '0x127091edE112aEd7Bae281747771b3150Bb047bB' -export const IBJPYUSDC_GAUGE_ADDRESS = '0x3A748A2F4765BDFB119Cb7143b884Db7594a68c3' -export const IBJPYUSDC_POOL_ADDRESS = '0xEB0265938c1190Ab4E3E1f6583bC956dF47C0F93' -export const IBJPYUSDC_YEARN_GAUGE_ADDRESS = '' -export const IBJPYUSDC_CONVEX_GAUGE_ADDRESS = '0x58563C872c791196d0eA17c4E53e77fa1d381D4c' -export const IBJPYUSDC_CONVEX_PID = 88 +export const IBJPYUSDC_ORACLE = "0x215F34af6557A6598DbdA9aa11cc556F5AE264B1"; +export const IBJPYUSDC_ADDRESS = "0x127091edE112aEd7Bae281747771b3150Bb047bB"; +export const IBJPYUSDC_GAUGE_ADDRESS = + "0x3A748A2F4765BDFB119Cb7143b884Db7594a68c3"; +export const IBJPYUSDC_POOL_ADDRESS = + "0xEB0265938c1190Ab4E3E1f6583bC956dF47C0F93"; +export const IBJPYUSDC_YEARN_GAUGE_ADDRESS = ""; +export const IBJPYUSDC_CONVEX_GAUGE_ADDRESS = + "0x58563C872c791196d0eA17c4E53e77fa1d381D4c"; +export const IBJPYUSDC_CONVEX_PID = 88; // ibKRW + USDC -export const IBKRWUSDC_ORACLE = '0x3c9f5385c288cE438Ed55620938A4B967c080101' -export const IBKRWUSDC_ADDRESS = '0x80CAcCdBD3f07BbdB558DB4a9e146D099933D677' -export const IBKRWUSDC_GAUGE_ADDRESS = '0xb6d7C2bda5a907832d4556AE5f7bA800FF084C2a' -export const IBKRWUSDC_POOL_ADDRESS = '0xef04f337fcb2ea220b6e8db5edbe2d774837581c' -export const IBKRWUSDC_YEARN_GAUGE_ADDRESS = '' -export const IBKRWUSDC_CONVEX_GAUGE_ADDRESS = '0x1900249c7a90D27b246032792004FF0E092Ac2cE' -export const IBKRWUSDC_CONVEX_PID = 89 - -export const IBEUR_ADDRESS = '0x96E61422b6A9bA0e068B6c5ADd4fFaBC6a4aae27' // -> EUR -export const IBEUR_GAUGE_ADDRESS = '0x99fb76F75501039089AAC8f20f487bf84E51d76F' // -> EUR Gauge -export const IBEUR_POOL_ADDRESS = '0x19b080FE1ffA0553469D20Ca36219F17Fcf03859' // -> EUR Pool -export const IBEUR_CONVEX_GAUGE_ADDRESS = '0xCd0559ADb6fAa2fc83aB21Cf4497c3b9b45bB29f' -export const IBEUR_YEARN_GAUGE_ADDRESS = '0x67e019bfbd5a67207755D04467D6A70c0B75bF60' -export const IBEUR_CONVEX_PID = 45 - -export const IBEUR_AG_ADDRESS = '0x96E61422b6A9bA0e068B6c5ADd4fFaBC6a4aae27' // -> EUR -export const IBEUR_AG_GAUGE_ADDRESS = '0x38039dD47636154273b287F74C432Cac83Da97e2' // -> EUR Gauge -export const IBEUR_AG_POOL_ADDRESS = '0xB37D6c07482Bc11cd28a1f11f1a6ad7b66Dec933' // -> EUR Pool -export const IBEUR_AG_CONVEX_GAUGE_ADDRESS = '' -export const IBEUR_AG_YEARN_GAUGE_ADDRESS = '' -export const IBEUR_AG_CONVEX_PID = 999 - -export const IBAUD_ADDRESS = '0xFAFdF0C4c1CB09d430Bf88c75D88BB46DAe09967' // -> AUD -export const IBAUD_GAUGE_ADDRESS = '0x05ca5c01629a8E5845f12ea3A03fF7331932233A' // -> AUD Gauge -export const IBAUD_POOL_ADDRESS = '0x3F1B0278A9ee595635B61817630cC19DE792f506' // -> AUD Pool -export const IBAUD_CONVEX_GAUGE_ADDRESS = '0xb1Fae59F23CaCe4949Ae734E63E42168aDb0CcB3' -export const IBAUD_YEARN_GAUGE_ADDRESS = '0x1b905331F7dE2748F4D6a0678e1521E20347643F' -export const IBAUD_CONVEX_PID = 44 - -export const IBCHF_ADDRESS = '0x1CC481cE2BD2EC7Bf67d1Be64d4878b16078F309' // -> CHF -export const IBCHF_GAUGE_ADDRESS = '0x2fA53e8fa5fAdb81f4332C8EcE39Fe62eA2f919E' // -> CHF Gauge -export const IBCHF_POOL_ADDRESS = '0x9c2C8910F113181783c249d8F6Aa41b51Cde0f0c' // -> CHF Pool -export const IBCHF_CONVEX_GAUGE_ADDRESS = '0xa5A5905efc55B05059eE247d5CaC6DD6791Cfc33' -export const IBCHF_YEARN_GAUGE_ADDRESS = '0x490bD0886F221A5F79713D3E84404355A9293C50' -export const IBCHF_CONVEX_PID = 46 - -export const IBGBP_ADDRESS = '0x69681f8fde45345C3870BCD5eaf4A05a60E7D227' // -> GBP -export const IBGBP_GAUGE_ADDRESS = '0x63d9f3aB7d0c528797A12a0684E50C397E9e79dC' // -> GBP Gauge -export const IBGBP_POOL_ADDRESS = '0xD6Ac1CB9019137a896343Da59dDE6d097F710538' // -> GBP Pool -export const IBGBP_CONVEX_GAUGE_ADDRESS = '0x51a16DA36c79E28dD3C8c0c19214D8aF413984Aa' -export const IBGBP_YEARN_GAUGE_ADDRESS = '0x595a68a8c9D5C230001848B69b1947ee2A607164' -export const IBGBP_CONVEX_PID = 43 - -export const IBJPY_ADDRESS = '0x5555f75e3d5278082200Fb451D1b6bA946D8e13b' // -> JPY -export const IBJPY_GAUGE_ADDRESS = '0xeFF437A56A22D7dD86C1202A308536ED8C7da7c1' // -> JPY Gauge -export const IBJPY_POOL_ADDRESS = '0x8818a9bb44Fbf33502bE7c15c500d0C783B73067' // -> JPY Pool -export const IBJPY_CONVEX_GAUGE_ADDRESS = '0xbA8fE590498ed24D330Bb925E69913b1Ac35a81E' -export const IBJPY_YEARN_GAUGE_ADDRESS = '0x59518884EeBFb03e90a18ADBAAAB770d4666471e' -export const IBJPY_CONVEX_PID = 42 - -export const USDC_ADDRESS = '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48' +export const IBKRWUSDC_ORACLE = "0x3c9f5385c288cE438Ed55620938A4B967c080101"; +export const IBKRWUSDC_ADDRESS = "0x80CAcCdBD3f07BbdB558DB4a9e146D099933D677"; +export const IBKRWUSDC_GAUGE_ADDRESS = + "0xb6d7C2bda5a907832d4556AE5f7bA800FF084C2a"; +export const IBKRWUSDC_POOL_ADDRESS = + "0xef04f337fcb2ea220b6e8db5edbe2d774837581c"; +export const IBKRWUSDC_YEARN_GAUGE_ADDRESS = ""; +export const IBKRWUSDC_CONVEX_GAUGE_ADDRESS = + "0x1900249c7a90D27b246032792004FF0E092Ac2cE"; +export const IBKRWUSDC_CONVEX_PID = 89; + +export const IBEUR_ADDRESS = "0x96E61422b6A9bA0e068B6c5ADd4fFaBC6a4aae27"; // -> EUR +export const IBEUR_GAUGE_ADDRESS = "0x99fb76F75501039089AAC8f20f487bf84E51d76F"; // -> EUR Gauge +export const IBEUR_POOL_ADDRESS = "0x19b080FE1ffA0553469D20Ca36219F17Fcf03859"; // -> EUR Pool +export const IBEUR_CONVEX_GAUGE_ADDRESS = + "0xCd0559ADb6fAa2fc83aB21Cf4497c3b9b45bB29f"; +export const IBEUR_YEARN_GAUGE_ADDRESS = + "0x67e019bfbd5a67207755D04467D6A70c0B75bF60"; +export const IBEUR_CONVEX_PID = 45; + +export const IBEUR_AG_ADDRESS = "0x96E61422b6A9bA0e068B6c5ADd4fFaBC6a4aae27"; // -> EUR +export const IBEUR_AG_GAUGE_ADDRESS = + "0x38039dD47636154273b287F74C432Cac83Da97e2"; // -> EUR Gauge +export const IBEUR_AG_POOL_ADDRESS = + "0xB37D6c07482Bc11cd28a1f11f1a6ad7b66Dec933"; // -> EUR Pool +export const IBEUR_AG_CONVEX_GAUGE_ADDRESS = ""; +export const IBEUR_AG_YEARN_GAUGE_ADDRESS = ""; +export const IBEUR_AG_CONVEX_PID = 999; + +export const IBAUD_ADDRESS = "0xFAFdF0C4c1CB09d430Bf88c75D88BB46DAe09967"; // -> AUD +export const IBAUD_GAUGE_ADDRESS = "0x05ca5c01629a8E5845f12ea3A03fF7331932233A"; // -> AUD Gauge +export const IBAUD_POOL_ADDRESS = "0x3F1B0278A9ee595635B61817630cC19DE792f506"; // -> AUD Pool +export const IBAUD_CONVEX_GAUGE_ADDRESS = + "0xb1Fae59F23CaCe4949Ae734E63E42168aDb0CcB3"; +export const IBAUD_YEARN_GAUGE_ADDRESS = + "0x1b905331F7dE2748F4D6a0678e1521E20347643F"; +export const IBAUD_CONVEX_PID = 44; + +export const IBCHF_ADDRESS = "0x1CC481cE2BD2EC7Bf67d1Be64d4878b16078F309"; // -> CHF +export const IBCHF_GAUGE_ADDRESS = "0x2fA53e8fa5fAdb81f4332C8EcE39Fe62eA2f919E"; // -> CHF Gauge +export const IBCHF_POOL_ADDRESS = "0x9c2C8910F113181783c249d8F6Aa41b51Cde0f0c"; // -> CHF Pool +export const IBCHF_CONVEX_GAUGE_ADDRESS = + "0xa5A5905efc55B05059eE247d5CaC6DD6791Cfc33"; +export const IBCHF_YEARN_GAUGE_ADDRESS = + "0x490bD0886F221A5F79713D3E84404355A9293C50"; +export const IBCHF_CONVEX_PID = 46; + +export const IBGBP_ADDRESS = "0x69681f8fde45345C3870BCD5eaf4A05a60E7D227"; // -> GBP +export const IBGBP_GAUGE_ADDRESS = "0x63d9f3aB7d0c528797A12a0684E50C397E9e79dC"; // -> GBP Gauge +export const IBGBP_POOL_ADDRESS = "0xD6Ac1CB9019137a896343Da59dDE6d097F710538"; // -> GBP Pool +export const IBGBP_CONVEX_GAUGE_ADDRESS = + "0x51a16DA36c79E28dD3C8c0c19214D8aF413984Aa"; +export const IBGBP_YEARN_GAUGE_ADDRESS = + "0x595a68a8c9D5C230001848B69b1947ee2A607164"; +export const IBGBP_CONVEX_PID = 43; + +export const IBJPY_ADDRESS = "0x5555f75e3d5278082200Fb451D1b6bA946D8e13b"; // -> JPY +export const IBJPY_GAUGE_ADDRESS = "0xeFF437A56A22D7dD86C1202A308536ED8C7da7c1"; // -> JPY Gauge +export const IBJPY_POOL_ADDRESS = "0x8818a9bb44Fbf33502bE7c15c500d0C783B73067"; // -> JPY Pool +export const IBJPY_CONVEX_GAUGE_ADDRESS = + "0xbA8fE590498ed24D330Bb925E69913b1Ac35a81E"; +export const IBJPY_YEARN_GAUGE_ADDRESS = + "0x59518884EeBFb03e90a18ADBAAAB770d4666471e"; +export const IBJPY_CONVEX_PID = 42; + +export const USDC_ADDRESS = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"; // OLD CONTRACTS, WE JUST USING THESE FOR PEOPLE TO WITHDRAW FROM -export const IBKRW_GAUGE_ADDRESS_OLD = '0x8992FD229B574b8083de1249BC6Fd3711fDA45dD' -export const IBEUR_GAUGE_ADDRESS_OLD = '0x9d7CA778d067045a9d6B871c9D28589875308018' -export const IBEUR_ETH_ADDRESS_OLD = '0x7d254d9adc588126edaee52a1029278180a802e8' +export const IBKRW_GAUGE_ADDRESS_OLD = + "0x8992FD229B574b8083de1249BC6Fd3711fDA45dD"; +export const IBEUR_GAUGE_ADDRESS_OLD = + "0x9d7CA778d067045a9d6B871c9D28589875308018"; +export const IBEUR_ETH_ADDRESS_OLD = + "0x7d254d9adc588126edaee52a1029278180a802e8"; // LEND CONTRACTS -export const COMPTROLLER_ADDRESS = '0xAB1c342C7bf5Ec5F02ADEA1c2270670bCa144CbB' -export const IRON_BANK_REGISTRY_ADAPTER = '0xFF0bd2d0C7E9424ccB149ED3757155eEf41a793D' +export const COMPTROLLER_ADDRESS = "0xAB1c342C7bf5Ec5F02ADEA1c2270670bCa144CbB"; +export const IRON_BANK_REGISTRY_ADAPTER = + "0xFF0bd2d0C7E9424ccB149ED3757155eEf41a793D"; // GENERAL -export const ERROR = 'ERROR' -export const STORE_UPDATED = 'STORE_UPDATED' -export const TX_SUBMITTED = 'TX_SUBMITTED' +export const ERROR = "ERROR"; +export const STORE_UPDATED = "STORE_UPDATED"; +export const TX_SUBMITTED = "TX_SUBMITTED"; -export const CONNECTION_CONNECTED = 'CONNECTION_CONNECTED' -export const CONNECTION_DISCONNECTED = 'CONNECTION_DISCONNECTED' -export const CONNECT_WALLET = 'CONNECT_WALLET' +export const CONNECTION_CONNECTED = "CONNECTION_CONNECTED"; +export const CONNECTION_DISCONNECTED = "CONNECTION_DISCONNECTED"; +export const CONNECT_WALLET = "CONNECT_WALLET"; -export const CONFIGURE = 'CONFIGURE' -export const CONFIGURE_RETURNED = 'CONFIGURE_RETURNED' +export const CONFIGURE = "CONFIGURE"; +export const CONFIGURE_RETURNED = "CONFIGURE_RETURNED"; -export const ACCOUNT_CONFIGURED = 'ACCOUNT_CONFIGURED' -export const ACCOUNT_CHANGED = 'ACCOUNT_CHANGED' +export const ACCOUNT_CONFIGURED = "ACCOUNT_CONFIGURED"; +export const ACCOUNT_CHANGED = "ACCOUNT_CHANGED"; -export const GET_GAS_PRICES = 'GET_GAS_PRICES' -export const GAS_PRICES_RETURNED = 'GAS_PRICES_RETURNED' +export const GET_GAS_PRICES = "GET_GAS_PRICES"; +export const GAS_PRICES_RETURNED = "GAS_PRICES_RETURNED"; // FIXED FOREX -export const FIXED_FOREX_UPDATED = 'FIXED_FOREX_UPDATED' +export const FIXED_FOREX_UPDATED = "FIXED_FOREX_UPDATED"; -export const CONFIGURE_FIXED_FOREX = 'CONFIGURE_FIXED_FOREX' -export const FIXED_FOREX_CONFIGURED = 'FIXED_FOREX_CONFIGURED' +export const CONFIGURE_FIXED_FOREX = "CONFIGURE_FIXED_FOREX"; +export const FIXED_FOREX_CONFIGURED = "FIXED_FOREX_CONFIGURED"; -export const GET_FIXED_FOREX_BALANCES = 'GET_FIXED_FOREX_BALANCES' -export const FIXED_FOREX_BALANCES_RETURNED = 'FIXED_FOREX_BALANCES_RETURNED' +export const GET_FIXED_FOREX_BALANCES = "GET_FIXED_FOREX_BALANCES"; +export const FIXED_FOREX_BALANCES_RETURNED = "FIXED_FOREX_BALANCES_RETURNED"; -export const FIXED_FOREX_CLAIM_VESTING_REWARD = 'FIXED_FOREX_CLAIM_VESTING_REWARD' -export const FIXED_FOREX_VESTING_REWARD_CLAIMED = 'FIXED_FOREX_VESTING_REWARD_CLAIMED' +export const FIXED_FOREX_CLAIM_VESTING_REWARD = + "FIXED_FOREX_CLAIM_VESTING_REWARD"; +export const FIXED_FOREX_VESTING_REWARD_CLAIMED = + "FIXED_FOREX_VESTING_REWARD_CLAIMED"; -export const FIXED_FOREX_CLAIM_STAKING_REWARD = 'FIXED_FOREX_CLAIM_STAKING_REWARD' -export const FIXED_FOREX_STAKING_REWARD_CLAIMED = 'FIXED_FOREX_STAKING_REWARD_CLAIMED' +export const FIXED_FOREX_CLAIM_STAKING_REWARD = + "FIXED_FOREX_CLAIM_STAKING_REWARD"; +export const FIXED_FOREX_STAKING_REWARD_CLAIMED = + "FIXED_FOREX_STAKING_REWARD_CLAIMED"; -export const FIXED_FOREX_APPROVE_STAKE_SLP = 'FIXED_FOREX_APPROVE_STAKE_SLP' -export const FIXED_FOREX_STAKE_SLP_APPROVED = 'FIXED_FOREX_STAKE_SLP_APPROVED' +export const FIXED_FOREX_APPROVE_STAKE_SLP = "FIXED_FOREX_APPROVE_STAKE_SLP"; +export const FIXED_FOREX_STAKE_SLP_APPROVED = "FIXED_FOREX_STAKE_SLP_APPROVED"; -export const FIXED_FOREX_STAKE_SLP = 'FIXED_FOREX_STAKE_SLP' -export const FIXED_FOREX_SLP_STAKED = 'FIXED_FOREX_SLP_STAKED' +export const FIXED_FOREX_STAKE_SLP = "FIXED_FOREX_STAKE_SLP"; +export const FIXED_FOREX_SLP_STAKED = "FIXED_FOREX_SLP_STAKED"; -export const FIXED_FOREX_UNSTAKE_SLP = 'FIXED_FOREX_UNSTAKE_SLP' -export const FIXED_FOREX_SLP_UNSTAKED = 'FIXED_FOREX_SLP_UNSTAKED' +export const FIXED_FOREX_UNSTAKE_SLP = "FIXED_FOREX_UNSTAKE_SLP"; +export const FIXED_FOREX_SLP_UNSTAKED = "FIXED_FOREX_SLP_UNSTAKED"; -export const FIXED_FOREX_APPROVE_VEST = 'FIXED_FOREX_APPROVE_VEST' -export const FIXED_FOREX_VEST_APPROVED = 'FIXED_FOREX_VEST_APPROVED' +export const FIXED_FOREX_APPROVE_VEST = "FIXED_FOREX_APPROVE_VEST"; +export const FIXED_FOREX_VEST_APPROVED = "FIXED_FOREX_VEST_APPROVED"; -export const FIXED_FOREX_VEST = 'FIXED_FOREX_VEST' -export const FIXED_FOREX_VESTED = 'FIXED_FOREX_VESTED' +export const FIXED_FOREX_VEST = "FIXED_FOREX_VEST"; +export const FIXED_FOREX_VESTED = "FIXED_FOREX_VESTED"; -export const FIXED_FOREX_VEST_AMOUNT = 'FIXED_FOREX_VEST_AMOUNT' -export const FIXED_FOREX_AMOUNT_VESTED = 'FIXED_FOREX_AMOUNT_VESTED' +export const FIXED_FOREX_VEST_AMOUNT = "FIXED_FOREX_VEST_AMOUNT"; +export const FIXED_FOREX_AMOUNT_VESTED = "FIXED_FOREX_AMOUNT_VESTED"; -export const FIXED_FOREX_VEST_DURATION = 'FIXED_FOREX_VEST_DURATION' -export const FIXED_FOREX_DURATION_VESTED = 'FIXED_FOREX_DURATION_VESTED' +export const FIXED_FOREX_VEST_DURATION = "FIXED_FOREX_VEST_DURATION"; +export const FIXED_FOREX_DURATION_VESTED = "FIXED_FOREX_DURATION_VESTED"; -export const FIXED_FOREX_VOTE = 'FIXED_FOREX_VOTE' -export const FIXED_FOREX_VOTE_RETURNED = 'FIXED_FOREX_VOTE_RETURNED' +export const FIXED_FOREX_VOTE = "FIXED_FOREX_VOTE"; +export const FIXED_FOREX_VOTE_RETURNED = "FIXED_FOREX_VOTE_RETURNED"; -export const FIXED_FOREX_APPROVE_DEPOSIT_CURVE = 'FIXED_FOREX_APPROVE_DEPOSIT_CURVE' -export const FIXED_FOREX_DEPOSIT_CURVE_APPROVED = 'FIXED_FOREX_DEPOSIT_CURVE_APPROVED' +export const FIXED_FOREX_APPROVE_DEPOSIT_CURVE = + "FIXED_FOREX_APPROVE_DEPOSIT_CURVE"; +export const FIXED_FOREX_DEPOSIT_CURVE_APPROVED = + "FIXED_FOREX_DEPOSIT_CURVE_APPROVED"; -export const FIXED_FOREX_DEPOSIT_CURVE = 'FIXED_FOREX_DEPOSIT_CURVE' -export const FIXED_FOREX_CURVE_DEPOSITED = 'FIXED_FOREX_CURVE_DEPOSITED' +export const FIXED_FOREX_DEPOSIT_CURVE = "FIXED_FOREX_DEPOSIT_CURVE"; +export const FIXED_FOREX_CURVE_DEPOSITED = "FIXED_FOREX_CURVE_DEPOSITED"; -export const FIXED_FOREX_WITHDRAW_CURVE = 'FIXED_FOREX_WITHDRAW_CURVE' -export const FIXED_FOREX_CURVE_WITHDRAWN = 'FIXED_FOREX_CURVE_WITHDRAWN' +export const FIXED_FOREX_WITHDRAW_CURVE = "FIXED_FOREX_WITHDRAW_CURVE"; +export const FIXED_FOREX_CURVE_WITHDRAWN = "FIXED_FOREX_CURVE_WITHDRAWN"; -export const FIXED_FOREX_APPROVE_STAKE_CURVE = 'FIXED_FOREX_APPROVE_STAKE_CURVE' -export const FIXED_FOREX_STAKE_CURVE_APPROVED = 'FIXED_FOREX_STAKE_CURVE_APPROVED' +export const FIXED_FOREX_APPROVE_STAKE_CURVE = + "FIXED_FOREX_APPROVE_STAKE_CURVE"; +export const FIXED_FOREX_STAKE_CURVE_APPROVED = + "FIXED_FOREX_STAKE_CURVE_APPROVED"; -export const FIXED_FOREX_STAKE_CURVE = 'FIXED_FOREX_STAKE_CURVE' -export const FIXED_FOREX_CURVE_STAKED = 'FIXED_FOREX_CURVE_STAKED' +export const FIXED_FOREX_STAKE_CURVE = "FIXED_FOREX_STAKE_CURVE"; +export const FIXED_FOREX_CURVE_STAKED = "FIXED_FOREX_CURVE_STAKED"; -export const FIXED_FOREX_UNSTAKE_CURVE = 'FIXED_FOREX_UNSTAKE_CURVE' -export const FIXED_FOREX_CURVE_UNSTAKED = 'FIXED_FOREX_CURVE_UNSTAKED' +export const FIXED_FOREX_UNSTAKE_CURVE = "FIXED_FOREX_UNSTAKE_CURVE"; +export const FIXED_FOREX_CURVE_UNSTAKED = "FIXED_FOREX_CURVE_UNSTAKED"; -export const FIXED_FOREX_CLAIM_DISTRIBUTION_REWARD = 'FIXED_FOREX_CLAIM_DISTRIBUTION_REWARD' -export const FIXED_FOREX_DISTRIBUTION_REWARD_CLAIMED = 'FIXED_FOREX_DISTRIBUTION_REWARD_CLAIMED' +export const FIXED_FOREX_CLAIM_DISTRIBUTION_REWARD = + "FIXED_FOREX_CLAIM_DISTRIBUTION_REWARD"; +export const FIXED_FOREX_DISTRIBUTION_REWARD_CLAIMED = + "FIXED_FOREX_DISTRIBUTION_REWARD_CLAIMED"; -export const FIXED_FOREX_CLAIM_CURVE_REWARDS = 'FIXED_FOREX_CLAIM_CURVE_REWARDS' -export const FIXED_FOREX_CURVE_REWARD_CLAIMED = 'FIXED_FOREX_CURVE_REWARD_CLAIMED' +export const FIXED_FOREX_CLAIM_CURVE_REWARDS = + "FIXED_FOREX_CLAIM_CURVE_REWARDS"; +export const FIXED_FOREX_CURVE_REWARD_CLAIMED = + "FIXED_FOREX_CURVE_REWARD_CLAIMED"; -export const FIXED_FOREX_GET_SLIPPAGE_INFO = 'FIXED_FOREX_GET_SLIPPAGE_INFO' -export const FIXED_FOREX_SLIPPAGE_INFO_RETURNED = 'FIXED_FOREX_SLIPPAGE_INFO_RETURNED' +export const FIXED_FOREX_GET_SLIPPAGE_INFO = "FIXED_FOREX_GET_SLIPPAGE_INFO"; +export const FIXED_FOREX_SLIPPAGE_INFO_RETURNED = + "FIXED_FOREX_SLIPPAGE_INFO_RETURNED"; -export const FIXED_FOREX_WITHDRAW_LOCK = 'FIXED_FOREX_WITHDRAW_LOCK' -export const FIXED_FOREX_LOCK_WITHDRAWN = 'FIXED_FOREX_LOCK_WITHDRAWN' +export const FIXED_FOREX_WITHDRAW_LOCK = "FIXED_FOREX_WITHDRAW_LOCK"; +export const FIXED_FOREX_LOCK_WITHDRAWN = "FIXED_FOREX_LOCK_WITHDRAWN"; -export const FIXED_FOREX_CLAIM_VECLAIM = 'FIXED_FOREX_CLAIM_VECLAIM' -export const FIXED_FOREX_VECLAIM_CLAIMED = 'FIXED_FOREX_VECLAIM_CLAIMED' +export const FIXED_FOREX_CLAIM_VECLAIM = "FIXED_FOREX_CLAIM_VECLAIM"; +export const FIXED_FOREX_VECLAIM_CLAIMED = "FIXED_FOREX_VECLAIM_CLAIMED"; -export const FIXED_FOREX_CLAIM_ALL = 'FIXED_FOREX_CLAIM_ALL' -export const FIXED_FOREX_ALL_CLAIMED = 'FIXED_FOREX_ALL_CLAIMED' +export const FIXED_FOREX_CLAIM_ALL = "FIXED_FOREX_CLAIM_ALL"; +export const FIXED_FOREX_ALL_CLAIMED = "FIXED_FOREX_ALL_CLAIMED"; -export const FIXED_FOREX_CLAIM_CURVE_RKP3R_REWARDS = 'FIXED_FOREX_CLAIM_CURVE_RKP3R_REWARDS' -export const FIXED_FOREX_CURVE_RKP3R_REWARD_CLAIMED = 'FIXED_FOREX_CURVE_RKP3R_REWARD_CLAIMED' +export const FIXED_FOREX_CLAIM_CURVE_RKP3R_REWARDS = + "FIXED_FOREX_CLAIM_CURVE_RKP3R_REWARDS"; +export const FIXED_FOREX_CURVE_RKP3R_REWARD_CLAIMED = + "FIXED_FOREX_CURVE_RKP3R_REWARD_CLAIMED"; -export const FIXED_FOREX_CLAIM_RKP3R = 'FIXED_FOREX_CLAIM_RKP3R' -export const FIXED_FOREX_RKP3R_CLAIMED = 'FIXED_FOREX_RKP3R_CLAIMED' +export const FIXED_FOREX_CLAIM_RKP3R = "FIXED_FOREX_CLAIM_RKP3R"; +export const FIXED_FOREX_RKP3R_CLAIMED = "FIXED_FOREX_RKP3R_CLAIMED"; -export const FIXED_FOREX_REDEEM_OPTION = 'FIXED_FOREX_REDEEM_OPTION' -export const FIXED_FOREX_OPTION_REDEEMED = 'FIXED_FOREX_OPTION_REDEEMED' +export const FIXED_FOREX_REDEEM_OPTION = "FIXED_FOREX_REDEEM_OPTION"; +export const FIXED_FOREX_OPTION_REDEEMED = "FIXED_FOREX_OPTION_REDEEMED"; -export const FIXED_FOREX_APPROVE_REDEEM_OPTION = 'FIXED_FOREX_APPROVE_REDEEM_OPTION' -export const FIXED_FOREX_REDEEM_OPTION_APPROVED = 'FIXED_FOREX_REDEEM_OPTION_APPROVED' +export const FIXED_FOREX_APPROVE_REDEEM_OPTION = + "FIXED_FOREX_APPROVE_REDEEM_OPTION"; +export const FIXED_FOREX_REDEEM_OPTION_APPROVED = + "FIXED_FOREX_REDEEM_OPTION_APPROVED"; -export const FIXED_FOREX_WITHDRAW_OLD = 'FIXED_FOREX_WITHDRAW_OLD' -export const FIXED_FOREX_OLD_WITHDRAWN = 'FIXED_FOREX_OLD_WITHDRAWN' +export const FIXED_FOREX_WITHDRAW_OLD = "FIXED_FOREX_WITHDRAW_OLD"; +export const FIXED_FOREX_OLD_WITHDRAWN = "FIXED_FOREX_OLD_WITHDRAWN"; -export const FIXED_FOREX_APPROVE_DEPOSIT_UNI = 'FIXED_FOREX_APPROVE_DEPOSIT_UNI' -export const FIXED_FOREX_DEPOSIT_UNI_APPROVED = 'FIXED_FOREX_DEPOSIT_UNI_APPROVED' +export const FIXED_FOREX_APPROVE_DEPOSIT_UNI = + "FIXED_FOREX_APPROVE_DEPOSIT_UNI"; +export const FIXED_FOREX_DEPOSIT_UNI_APPROVED = + "FIXED_FOREX_DEPOSIT_UNI_APPROVED"; -export const FIXED_FOREX_DEPOSIT_UNI = 'FIXED_FOREX_DEPOSIT_UNI' -export const FIXED_FOREX_UNI_DEPOSITED = 'FIXED_FOREX_UNI_DEPOSITED' +export const FIXED_FOREX_DEPOSIT_UNI = "FIXED_FOREX_DEPOSIT_UNI"; +export const FIXED_FOREX_UNI_DEPOSITED = "FIXED_FOREX_UNI_DEPOSITED"; -export const FIXED_FOREX_WITHDRAW_UNI = 'FIXED_FOREX_WITHDRAW_UNI' -export const FIXED_FOREX_UNI_WITHDRAWN = 'FIXED_FOREX_UNI_WITHDRAWN' +export const FIXED_FOREX_WITHDRAW_UNI = "FIXED_FOREX_WITHDRAW_UNI"; +export const FIXED_FOREX_UNI_WITHDRAWN = "FIXED_FOREX_UNI_WITHDRAWN"; -export const FIXED_FOREX_GET_UNI_REWARDS = 'FIXED_FOREX_GET_UNI_REWARDS' -export const FIXED_FOREX_UNI_REWARDS_RETURNED = 'FIXED_FOREX_UNI_REWARDS_RETURNED' +export const FIXED_FOREX_GET_UNI_REWARDS = "FIXED_FOREX_GET_UNI_REWARDS"; +export const FIXED_FOREX_UNI_REWARDS_RETURNED = + "FIXED_FOREX_UNI_REWARDS_RETURNED"; -export const FIXED_FOREX_GET_ALL_UNI_REWARDS = 'FIXED_FOREX_GET_ALL_UNI_REWARDS' -export const FIXED_FOREX_ALL_UNI_REWARDS_RETURNED = 'FIXED_FOREX_ALL_UNI_REWARDS_RETURNED' +export const FIXED_FOREX_GET_ALL_UNI_REWARDS = + "FIXED_FOREX_GET_ALL_UNI_REWARDS"; +export const FIXED_FOREX_ALL_UNI_REWARDS_RETURNED = + "FIXED_FOREX_ALL_UNI_REWARDS_RETURNED"; -export const FIXED_FOREX_STAKE_CONVEX = 'FIXED_FOREX_STAKE_CONVEX' -export const FIXED_FOREX_CONVEX_STAKED = 'FIXED_FOREX_CONVEX_STAKED' +export const FIXED_FOREX_STAKE_CONVEX = "FIXED_FOREX_STAKE_CONVEX"; +export const FIXED_FOREX_CONVEX_STAKED = "FIXED_FOREX_CONVEX_STAKED"; -export const FIXED_FOREX_APPROVE_STAKE_CONVEX = 'FIXED_FOREX_APPROVE_STAKE_CONVEX' -export const FIXED_FOREX_STAKE_CONVEX_APPROVED = 'FIXED_FOREX_STAKE_CONVEX_APPROVED' +export const FIXED_FOREX_APPROVE_STAKE_CONVEX = + "FIXED_FOREX_APPROVE_STAKE_CONVEX"; +export const FIXED_FOREX_STAKE_CONVEX_APPROVED = + "FIXED_FOREX_STAKE_CONVEX_APPROVED"; -export const FIXED_FOREX_UNSTAKE_CONVEX = 'FIXED_FOREX_UNSTAKE_CONVEX' -export const FIXED_FOREX_CONVEX_UNSTAKED = 'FIXED_FOREX_CONVEX_UNSTAKED' +export const FIXED_FOREX_UNSTAKE_CONVEX = "FIXED_FOREX_UNSTAKE_CONVEX"; +export const FIXED_FOREX_CONVEX_UNSTAKED = "FIXED_FOREX_CONVEX_UNSTAKED"; -export const FIXED_FOREX_CLAIM_CONVEX_REWARDS = 'FIXED_FOREX_CLAIM_CONVEX_REWARDS' -export const FIXED_FOREX_CONVEX_REWARD_CLAIMED = 'FIXED_FOREX_CONVEX_REWARD_CLAIMED' +export const FIXED_FOREX_CLAIM_CONVEX_REWARDS = + "FIXED_FOREX_CLAIM_CONVEX_REWARDS"; +export const FIXED_FOREX_CONVEX_REWARD_CLAIMED = + "FIXED_FOREX_CONVEX_REWARD_CLAIMED"; -export const FIXED_FOREX_STAKE_YEARN = 'FIXED_FOREX_STAKE_YEARN' -export const FIXED_FOREX_YEARN_STAKED = 'FIXED_FOREX_YEARN_STAKED' +export const FIXED_FOREX_STAKE_YEARN = "FIXED_FOREX_STAKE_YEARN"; +export const FIXED_FOREX_YEARN_STAKED = "FIXED_FOREX_YEARN_STAKED"; -export const FIXED_FOREX_APPROVE_STAKE_YEARN = 'FIXED_FOREX_APPROVE_STAKE_YEARN' -export const FIXED_FOREX_STAKE_YEARN_APPROVED = 'FIXED_FOREX_STAKE_YEARN_APPROVED' +export const FIXED_FOREX_APPROVE_STAKE_YEARN = + "FIXED_FOREX_APPROVE_STAKE_YEARN"; +export const FIXED_FOREX_STAKE_YEARN_APPROVED = + "FIXED_FOREX_STAKE_YEARN_APPROVED"; -export const FIXED_FOREX_UNSTAKE_YEARN = 'FIXED_FOREX_UNSTAKE_YEARN' -export const FIXED_FOREX_YEARN_UNSTAKED = 'FIXED_FOREX_YEARN_UNSTAKED' +export const FIXED_FOREX_UNSTAKE_YEARN = "FIXED_FOREX_UNSTAKE_YEARN"; +export const FIXED_FOREX_YEARN_UNSTAKED = "FIXED_FOREX_YEARN_UNSTAKED"; -export const FIXED_FOREX_SWAP = 'FIXED_FOREX_SWAP' -export const FIXED_FOREX_SWAP_RETURNED = 'FIXED_FOREX_SWAP_RETURNED' +export const FIXED_FOREX_SWAP = "FIXED_FOREX_SWAP"; +export const FIXED_FOREX_SWAP_RETURNED = "FIXED_FOREX_SWAP_RETURNED"; -export const FIXED_FOREX_APPROVE_SWAP = 'FIXED_FOREX_APPROVE_SWAP' -export const FIXED_FOREX_SWAP_APPROVED = 'FIXED_FOREX_SWAP_APPROVED' +export const FIXED_FOREX_APPROVE_SWAP = "FIXED_FOREX_APPROVE_SWAP"; +export const FIXED_FOREX_SWAP_APPROVED = "FIXED_FOREX_SWAP_APPROVED"; -export const FIXED_FOREX_QUOTE_SWAP = 'FIXED_FOREX_QUOTE_SWAP' -export const FIXED_FOREX_QUOTE_SWAP_RETURNED = 'FIXED_FOREX_QUOTE_SWAP_RETURNED' -export const FIXED_FOREX_CLAIM_YEARN_REWARDS = 'FIXED_FOREX_CLAIM_YEARN_REWARDS' -export const FIXED_FOREX_YEARN_REWARD_CLAIMED = 'FIXED_FOREX_YEARN_REWARD_CLAIMED' +export const FIXED_FOREX_QUOTE_SWAP = "FIXED_FOREX_QUOTE_SWAP"; +export const FIXED_FOREX_QUOTE_SWAP_RETURNED = + "FIXED_FOREX_QUOTE_SWAP_RETURNED"; +export const FIXED_FOREX_CLAIM_YEARN_REWARDS = + "FIXED_FOREX_CLAIM_YEARN_REWARDS"; +export const FIXED_FOREX_YEARN_REWARD_CLAIMED = + "FIXED_FOREX_YEARN_REWARD_CLAIMED"; //LEND -export const CONFIGURE_LENDING = 'CONFIGURE_LENDING' -export const LENDING_CONFIGURED = 'LENDING_CONFIGURED' +export const CONFIGURE_LENDING = "CONFIGURE_LENDING"; +export const LENDING_CONFIGURED = "LENDING_CONFIGURED"; -export const LEND_UPDATED = 'LEND_UPDATED' +export const LEND_UPDATED = "LEND_UPDATED"; -export const GET_LENDING_BALANCES = 'GET_LENDING_BALANCES' -export const LENDING_BALANCES_RETURNED = 'LENDING_BALANCES_RETURNED' +export const GET_LENDING_BALANCES = "GET_LENDING_BALANCES"; +export const LENDING_BALANCES_RETURNED = "LENDING_BALANCES_RETURNED"; -export const APPROVE_LEND = 'APPROVE_LEND' -export const APPROVE_LEND_RETURNED = 'APPROVE_LEND_RETURNED' +export const APPROVE_LEND = "APPROVE_LEND"; +export const APPROVE_LEND_RETURNED = "APPROVE_LEND_RETURNED"; -export const LENDING_SUPPLY_RETURNED = 'LENDING_SUPPLY_RETURNED' -export const LENDING_BORROW_RETURNED = 'LENDING_BORROW_RETURNED' -export const LENDING_REPAY_RETURNED = 'LENDING_REPAY_RETURNED' +export const LENDING_SUPPLY_RETURNED = "LENDING_SUPPLY_RETURNED"; +export const LENDING_BORROW_RETURNED = "LENDING_BORROW_RETURNED"; +export const LENDING_REPAY_RETURNED = "LENDING_REPAY_RETURNED"; -export const DEPOSIT_LEND = 'DEPOSIT_LEND' -export const DEPOSIT_LEND_RETURNED = 'DEPOSIT_LEND_RETURNED' +export const DEPOSIT_LEND = "DEPOSIT_LEND"; +export const DEPOSIT_LEND_RETURNED = "DEPOSIT_LEND_RETURNED"; -export const WITHDRAW_LEND = 'WITHDRAW_LEND' -export const WITHDRAW_LEND_RETURNED = 'WITHDRAW_LEND_RETURNED' +export const WITHDRAW_LEND = "WITHDRAW_LEND"; +export const WITHDRAW_LEND_RETURNED = "WITHDRAW_LEND_RETURNED"; -export const BORROW_LEND = 'BORROW_LEND' -export const BORROW_LEND_RETURNED = 'BORROW_LEND_RETURNED' +export const BORROW_LEND = "BORROW_LEND"; +export const BORROW_LEND_RETURNED = "BORROW_LEND_RETURNED"; -export const REPAY_LEND = 'REPAY_LEND' -export const REPAY_LEND_RETURNED = 'REPAY_LEND_RETURNED' +export const REPAY_LEND = "REPAY_LEND"; +export const REPAY_LEND_RETURNED = "REPAY_LEND_RETURNED"; -export const ENABLE_COLLATERAL_LEND = 'ENABLE_COLLATERAL_LEND' -export const ENABLE_COLLATERAL_LEND_RETURNED = 'ENABLE_COLLATERAL_LEND_RETURNED' +export const ENABLE_COLLATERAL_LEND = "ENABLE_COLLATERAL_LEND"; +export const ENABLE_COLLATERAL_LEND_RETURNED = + "ENABLE_COLLATERAL_LEND_RETURNED"; -export const DISABLE_COLLATERAL_LEND = 'DISABLE_COLLATERAL_LEND' -export const DISABLE_COLLATERAL_LEND_RETURNED = 'DISABLE_COLLATERAL_LEND_RETURNED' +export const DISABLE_COLLATERAL_LEND = "DISABLE_COLLATERAL_LEND"; +export const DISABLE_COLLATERAL_LEND_RETURNED = + "DISABLE_COLLATERAL_LEND_RETURNED"; -export const MAX_UINT256 = new BigNumber(2).pow(256).minus(1).toFixed(0) +export const MAX_UINT256 = new BigNumber(2).pow(256).minus(1).toFixed(0); diff --git a/stores/fixedForexStore.js b/stores/fixedForexStore.js index d657735..8a55c8e 100644 --- a/stores/fixedForexStore.js +++ b/stores/fixedForexStore.js @@ -114,11 +114,9 @@ import { FF_UNSIWAP_POSITIONS_MANAGER_ADDRESS, FF_CURVE_GAUGE_CONTROLLER, FF_CONVEX_POOL_MANAGEMENT_ADDRESS, - FF_IBAMM_ADDRESS, FF_IBAMM_V2_ADDRESS, FF_IBAMM_V3_ADDRESS, - IBEUR_ETH_ADDRESS_OLD, IBEUR_GAUGE_ADDRESS_OLD, IBKRW_GAUGE_ADDRESS_OLD, @@ -149,14 +147,12 @@ import { FIXED_FOREX_DURATION_VESTED, FIXED_FOREX_VOTE, FIXED_FOREX_VOTE_RETURNED, - FIXED_FOREX_QUOTE_SWAP, FIXED_FOREX_QUOTE_SWAP_RETURNED, FIXED_FOREX_APPROVE_SWAP, FIXED_FOREX_SWAP_APPROVED, FIXED_FOREX_SWAP, FIXED_FOREX_SWAP_RETURNED, - FIXED_FOREX_APPROVE_DEPOSIT_CURVE, FIXED_FOREX_DEPOSIT_CURVE_APPROVED, FIXED_FOREX_DEPOSIT_CURVE, @@ -213,7 +209,6 @@ import { import { Pool, tickToPrice } from "@uniswap/v3-sdk"; import { Token } from "@uniswap/sdk-core"; - import stores from "./"; import abis from "./abis"; import { bnToFixed, sumArray } from "../utils"; @@ -235,7 +230,7 @@ class Store { rewards: null, rKP3R: null, oldAssets: [], - swapFromAssets: [] + swapFromAssets: [], }; dispatcher.register( @@ -377,7 +372,7 @@ class Store { this.getAllUniRewards(payload); break; - //swap + //swap case FIXED_FOREX_QUOTE_SWAP: this.quoteSwap(payload); break; @@ -390,7 +385,7 @@ class Store { default: { } } - }.bind(this), + }.bind(this) ); } @@ -466,7 +461,7 @@ class Store { this.emitter.emit(FIXED_FOREX_CONFIGURED); this.dispatcher.dispatch({ type: GET_FIXED_FOREX_BALANCES }); } catch (ex) { - console.log(ex); + console.error(ex); this.emitter.emit(ERROR, ex); } }; @@ -474,28 +469,28 @@ class Store { _getSwapFromAssets = () => { return [ { - address: '0x6b175474e89094c44da98b954eedeac495271d0f', - symbol: 'DAI', - name: 'Dai', + address: "0x6b175474e89094c44da98b954eedeac495271d0f", + symbol: "DAI", + name: "Dai", decimals: 18, - icon: 'https://assets.coingecko.com/coins/images/9956/large/4943.png' + icon: "https://assets.coingecko.com/coins/images/9956/large/4943.png", }, { - address: '0x57ab1ec28d129707052df4df418d58a2d46d5f51', - symbol: 'sUSD', - name: 'Synthetix USD', + address: "0x57ab1ec28d129707052df4df418d58a2d46d5f51", + symbol: "sUSD", + name: "Synthetix USD", decimals: 18, - icon: 'https://assets.coingecko.com/coins/images/5013/large/sUSD.png' + icon: "https://assets.coingecko.com/coins/images/5013/large/sUSD.png", }, { - address: '0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3', - symbol: 'MIM', - name: 'Magic Internet Money', + address: "0x99d8a9c45b2eca8864373a26d1459e3dff1e17f3", + symbol: "MIM", + name: "Magic Internet Money", decimals: 18, - icon: 'https://assets.coingecko.com/coins/images/16786/large/mimlogopng.png' + icon: "https://assets.coingecko.com/coins/images/16786/large/mimlogopng.png", }, - ] - } + ]; + }; _getSystemAssets = () => { return { @@ -572,16 +567,17 @@ class Store { convex: { address: KP3RETH_CONVEX_GAUGE_ADDRESS, pid: KP3RETH_CONVEX_PID, - rewards: [{ + rewards: [ + { poolAddress: "0x21034ccc4f8D07d0cF8998Fdd4c45e426540dEc1", //rKP3R Reward Pool address: FF_RKP3R_ADDRESS, decimals: 18, symbol: "rKP3R", name: "Redeemable Keep3r", - }, - ], }, + ], }, + }, { address: IBAUDUSDC_ADDRESS, logoAddress: IBAUDUSDC_ADDRESS, @@ -592,23 +588,24 @@ class Store { name: "Curve ibaudusdc pool", oracleAddress: IBAUDUSDC_ORACLE, gauge: { - address: IBAUDUSDC_GAUGE_ADDRESS, - poolAddress: IBAUDUSDC_POOL_ADDRESS, + address: IBAUDUSDC_GAUGE_ADDRESS, + poolAddress: IBAUDUSDC_POOL_ADDRESS, }, yearn: { - address: IBAUDUSDC_YEARN_GAUGE_ADDRESS, + address: IBAUDUSDC_YEARN_GAUGE_ADDRESS, }, convex: { - address: IBAUDUSDC_CONVEX_GAUGE_ADDRESS, - pid: IBAUDUSDC_CONVEX_PID, - rewards: [{ - poolAddress: "0x21034ccc4f8D07d0cF8998Fdd4c45e426540dEc1", //rKP3R Reward Pool - address: FF_RKP3R_ADDRESS, - decimals: 18, - symbol: "rKP3R", - name: "Redeemable Keep3r", - }, - ], + address: IBAUDUSDC_CONVEX_GAUGE_ADDRESS, + pid: IBAUDUSDC_CONVEX_PID, + rewards: [ + { + poolAddress: "0x21034ccc4f8D07d0cF8998Fdd4c45e426540dEc1", //rKP3R Reward Pool + address: FF_RKP3R_ADDRESS, + decimals: 18, + symbol: "rKP3R", + name: "Redeemable Keep3r", + }, + ], }, }, { @@ -621,23 +618,24 @@ class Store { name: "Curve ibchfusdc pool", oracleAddress: IBCHFUSDC_ORACLE, gauge: { - address: IBCHFUSDC_GAUGE_ADDRESS, - poolAddress: IBCHFUSDC_POOL_ADDRESS, + address: IBCHFUSDC_GAUGE_ADDRESS, + poolAddress: IBCHFUSDC_POOL_ADDRESS, }, yearn: { - address: IBCHFUSDC_YEARN_GAUGE_ADDRESS, + address: IBCHFUSDC_YEARN_GAUGE_ADDRESS, }, convex: { - address: IBCHFUSDC_CONVEX_GAUGE_ADDRESS, - pid: IBCHFUSDC_CONVEX_PID, - rewards: [{ - poolAddress: "0x21034ccc4f8D07d0cF8998Fdd4c45e426540dEc1", //rKP3R Reward Pool - address: FF_RKP3R_ADDRESS, - decimals: 18, - symbol: "rKP3R", - name: "Redeemable Keep3r", - }, - ], + address: IBCHFUSDC_CONVEX_GAUGE_ADDRESS, + pid: IBCHFUSDC_CONVEX_PID, + rewards: [ + { + poolAddress: "0x21034ccc4f8D07d0cF8998Fdd4c45e426540dEc1", //rKP3R Reward Pool + address: FF_RKP3R_ADDRESS, + decimals: 18, + symbol: "rKP3R", + name: "Redeemable Keep3r", + }, + ], }, }, { @@ -650,23 +648,24 @@ class Store { name: "Curve ibeurusdc pool", oracleAddress: IBEURUSDC_ORACLE, gauge: { - address: IBEURUSDC_GAUGE_ADDRESS, - poolAddress: IBEURUSDC_POOL_ADDRESS, + address: IBEURUSDC_GAUGE_ADDRESS, + poolAddress: IBEURUSDC_POOL_ADDRESS, }, yearn: { - address: IBEURUSDC_YEARN_GAUGE_ADDRESS, + address: IBEURUSDC_YEARN_GAUGE_ADDRESS, }, convex: { - address: IBEURUSDC_CONVEX_GAUGE_ADDRESS, - pid: IBEURUSDC_CONVEX_PID, - rewards: [{ - poolAddress: "0x21034ccc4f8D07d0cF8998Fdd4c45e426540dEc1", //rKP3R Reward Pool - address: FF_RKP3R_ADDRESS, - decimals: 18, - symbol: "rKP3R", - name: "Redeemable Keep3r", - }, - ], + address: IBEURUSDC_CONVEX_GAUGE_ADDRESS, + pid: IBEURUSDC_CONVEX_PID, + rewards: [ + { + poolAddress: "0x21034ccc4f8D07d0cF8998Fdd4c45e426540dEc1", //rKP3R Reward Pool + address: FF_RKP3R_ADDRESS, + decimals: 18, + symbol: "rKP3R", + name: "Redeemable Keep3r", + }, + ], }, }, { @@ -679,25 +678,26 @@ class Store { name: "Curve ibgbpusdc pool", oracleAddress: IBGBPUSDC_ORACLE, gauge: { - address: IBGBPUSDC_GAUGE_ADDRESS, - poolAddress: IBGBPUSDC_POOL_ADDRESS, + address: IBGBPUSDC_GAUGE_ADDRESS, + poolAddress: IBGBPUSDC_POOL_ADDRESS, }, yearn: { - address: IBGBPUSDC_YEARN_GAUGE_ADDRESS, + address: IBGBPUSDC_YEARN_GAUGE_ADDRESS, }, convex: { - address: IBGBPUSDC_CONVEX_GAUGE_ADDRESS, - pid: IBGBPUSDC_CONVEX_PID, - rewards: [{ - poolAddress: "0x21034ccc4f8D07d0cF8998Fdd4c45e426540dEc1", //rKP3R Reward Pool - address: FF_RKP3R_ADDRESS, - decimals: 18, - symbol: "rKP3R", - name: "Redeemable Keep3r", - }, - ], + address: IBGBPUSDC_CONVEX_GAUGE_ADDRESS, + pid: IBGBPUSDC_CONVEX_PID, + rewards: [ + { + poolAddress: "0x21034ccc4f8D07d0cF8998Fdd4c45e426540dEc1", //rKP3R Reward Pool + address: FF_RKP3R_ADDRESS, + decimals: 18, + symbol: "rKP3R", + name: "Redeemable Keep3r", + }, + ], }, - }, + }, { address: IBJPYUSDC_ADDRESS, logoAddress: IBJPYUSDC_ADDRESS, @@ -717,7 +717,8 @@ class Store { convex: { address: IBJPYUSDC_CONVEX_GAUGE_ADDRESS, pid: IBJPYUSDC_CONVEX_PID, - rewards: [{ + rewards: [ + { poolAddress: "0x21034ccc4f8D07d0cF8998Fdd4c45e426540dEc1", //rKP3R Reward Pool address: FF_RKP3R_ADDRESS, decimals: 18, @@ -746,7 +747,8 @@ class Store { convex: { address: IBKRWUSDC_CONVEX_GAUGE_ADDRESS, pid: IBKRWUSDC_CONVEX_PID, - rewards: [{ + rewards: [ + { poolAddress: "0x21034ccc4f8D07d0cF8998Fdd4c45e426540dEc1", //rKP3R Reward Pool address: FF_RKP3R_ADDRESS, decimals: 18, @@ -967,13 +969,15 @@ class Store { _getAssetBalance = async (web3, asset, account) => { try { const assetContract = new web3.eth.Contract(abis.erc20ABI, asset.address); - const balanceOf = await assetContract.methods.balanceOf(account.address).call(); + const balanceOf = await assetContract.methods + .balanceOf(account.address) + .call(); const balance = BigNumber(balanceOf) .div(10 ** asset.decimals) .toFixed(asset.decimals); return balance; } catch (ex) { - console.log(ex); + console.error(ex); return null; } }; @@ -995,24 +999,24 @@ class Store { return null; } - const systemAssets = this._getSystemAssets() - - this._setIBFF(web3, account, systemAssets) - this._setVEIBFF(web3, account, systemAssets) - this._setVEIBFFOld(web3, account, systemAssets) - this._setRKP3R(web3, account, systemAssets) - this._setOKP3R(web3, account, systemAssets) - this._getCRV(web3, account, systemAssets) - this._getAssetInfo(web3, account, assets) - this._getRewardInfo(web3, account) - this._getOldGaugeInfo(web3, account) - this._getUniV3Info(web3, account) - this._getStakingV3Rewards(web3, account) - this._getSwapFromBalances(web3, account) - this._getBreaker(web3, account) - } catch(ex) { - console.log(ex) - this.emitter.emit(ERROR, ex) + const systemAssets = this._getSystemAssets(); + + this._setIBFF(web3, account, systemAssets); + this._setVEIBFF(web3, account, systemAssets); + this._setVEIBFFOld(web3, account, systemAssets); + this._setRKP3R(web3, account, systemAssets); + this._setOKP3R(web3, account, systemAssets); + this._getCRV(web3, account, systemAssets); + this._getAssetInfo(web3, account, assets); + this._getRewardInfo(web3, account); + this._getOldGaugeInfo(web3, account); + this._getUniV3Info(web3, account); + this._getStakingV3Rewards(web3, account); + this._getSwapFromBalances(web3, account); + this._getBreaker(web3, account); + } catch (ex) { + console.log(ex); + this.emitter.emit(ERROR, ex); } }; @@ -1020,8 +1024,13 @@ class Store { try { const crv = systemAssets.crv; - const priceOracleContract = new web3.eth.Contract(abis.creamPriceOracleABI, CREAM_PRICE_ORACLE_ADDRESS); - const price = await priceOracleContract.methods.getUnderlyingPrice(crv.oracleAddress).call(); + const priceOracleContract = new web3.eth.Contract( + abis.creamPriceOracleABI, + CREAM_PRICE_ORACLE_ADDRESS + ); + const price = await priceOracleContract.methods + .getUnderlyingPrice(crv.oracleAddress) + .call(); crv.price = BigNumber(price) .div(10 ** (36 - crv.decimals)) .toFixed(18); @@ -1029,7 +1038,7 @@ class Store { this.setStore({ crv }); this.emitter.emit(FIXED_FOREX_UPDATED); } catch (ex) { - console.log(ex); + console.error(ex); } }; @@ -1037,7 +1046,12 @@ class Store { try { const ibff = systemAssets.kp3r; ibff.balance = await this._getAssetBalance(web3, ibff, account); - const vestingContractApprovalAmount = await this._getApprovalAmount(web3, ibff, account.address, FF_VEKP3R_ADDRESS); + const vestingContractApprovalAmount = await this._getApprovalAmount( + web3, + ibff, + account.address, + FF_VEKP3R_ADDRESS + ); ibff.vestAllowance = vestingContractApprovalAmount; // const priceOracleContract = new web3.eth.Contract(abis.creamPriceOracleABI, CREAM_PRICE_ORACLE_ADDRESS) @@ -1047,7 +1061,7 @@ class Store { this.setStore({ ibff }); this.emitter.emit(FIXED_FOREX_UPDATED); } catch (ex) { - console.log(ex); + console.error(ex); } }; @@ -1065,7 +1079,7 @@ class Store { this.setStore({ veIBFF }); this.emitter.emit(FIXED_FOREX_UPDATED); } catch (ex) { - console.log(ex); + console.error(ex); } }; @@ -1079,7 +1093,7 @@ class Store { this.setStore({ veIBFFOld }); this.emitter.emit(FIXED_FOREX_UPDATED); } catch (ex) { - console.log(ex); + console.error(ex); } }; @@ -1088,7 +1102,10 @@ class Store { const rKP3R = systemAssets.rKP3R; rKP3R.balance = await this._getAssetBalance(web3, rKP3R, account); - const rKP3RContract = new web3.eth.Contract(abis.rKP3RABI, FF_RKP3R_ADDRESS); + const rKP3RContract = new web3.eth.Contract( + abis.rKP3RABI, + FF_RKP3R_ADDRESS + ); const price = await rKP3RContract.methods.twap().call(); const discount = await rKP3RContract.methods.discount().call(); rKP3R.price = BigNumber(price) @@ -1100,24 +1117,36 @@ class Store { this.setStore({ rKP3R }); this.emitter.emit(FIXED_FOREX_UPDATED); } catch (ex) { - console.log(ex); + console.error(ex); } }; _setOKP3R = async (web3, account, systemAssets) => { try { - const oKP3RContract = new web3.eth.Contract(abis.oKP3RABI, FF_OKP3R_ADDRESS); - const rKP3RContract = new web3.eth.Contract(abis.rKP3RABI, FF_RKP3R_ADDRESS); + const oKP3RContract = new web3.eth.Contract( + abis.oKP3RABI, + FF_OKP3R_ADDRESS + ); + const rKP3RContract = new web3.eth.Contract( + abis.rKP3RABI, + FF_RKP3R_ADDRESS + ); const usdcContract = new web3.eth.Contract(abis.erc20ABI, USDC_ADDRESS); - const balanceOf = await oKP3RContract.methods.balanceOf(account.address).call(); + const balanceOf = await oKP3RContract.methods + .balanceOf(account.address) + .call(); const arr = [...Array(parseInt(balanceOf)).keys()]; const oKP3ROptions = await Promise.all( arr.map(async (idx) => { - const tokenIdx = await oKP3RContract.methods.tokenOfOwnerByIndex(account.address, idx).call(); + const tokenIdx = await oKP3RContract.methods + .tokenOfOwnerByIndex(account.address, idx) + .call(); const option = await rKP3RContract.methods.options(tokenIdx).call(); - const rKP3RAllowance = await usdcContract.methods.allowance(account.address, FF_RKP3R_ADDRESS).call(); + const rKP3RAllowance = await usdcContract.methods + .allowance(account.address, FF_RKP3R_ADDRESS) + .call(); return { id: tokenIdx, @@ -1133,21 +1162,31 @@ class Store { .div(10 ** 6) .toFixed(18), //USDC with 6 decimals }; - }), + }) ); this.setStore({ oKP3ROptions }); this.emitter.emit(FIXED_FOREX_UPDATED); } catch (ex) { - console.log(ex); + console.error(ex); } }; //need to get $ value of ibAssets and sAssets, as well as pool ratios and take things further from there. fk knows. - calcPoolAPY = (gaugeWeight, totalWeight, inflationRate, workingSupply, virtualPrice, assetPrice, curvePrice) => { + calcPoolAPY = ( + gaugeWeight, + totalWeight, + inflationRate, + workingSupply, + virtualPrice, + assetPrice, + curvePrice + ) => { try { let weightOfRewards = gaugeWeight / totalWeight; - let rate = (((inflationRate * weightOfRewards * 31536000) / workingSupply) * 0.4) / (virtualPrice * (assetPrice / 1e18)); + let rate = + (((inflationRate * weightOfRewards * 31536000) / workingSupply) * 0.4) / + (virtualPrice * (assetPrice / 1e18)); let apy = rate * curvePrice * 100 * 1e36; return apy; @@ -1159,25 +1198,58 @@ class Store { _getAssetInfo = async (web3, account, assets) => { try { - const gaugeProxyContract = new web3.eth.Contract(abis.gaugeProxyABI, GAUGE_PROXY_ADDRESS); - const priceOracleContract = new web3.eth.Contract(abis.creamPriceOracleABI, CREAM_PRICE_ORACLE_ADDRESS); - const [totalGaugeVotes] = await Promise.all([gaugeProxyContract.methods.totalWeight().call()]); - const convexCVXContract = new web3.eth.Contract(abis.convexCVXABI, FF_CVX_ADDRESS); - const [convexReductionPerCliff, convexTotalSupply, convexMaxSupply, convexTotalCliffs] = await Promise.all([ + const gaugeProxyContract = new web3.eth.Contract( + abis.gaugeProxyABI, + GAUGE_PROXY_ADDRESS + ); + const priceOracleContract = new web3.eth.Contract( + abis.creamPriceOracleABI, + CREAM_PRICE_ORACLE_ADDRESS + ); + const [totalGaugeVotes] = await Promise.all([ + gaugeProxyContract.methods.totalWeight().call(), + ]); + const convexCVXContract = new web3.eth.Contract( + abis.convexCVXABI, + FF_CVX_ADDRESS + ); + const [ + convexReductionPerCliff, + convexTotalSupply, + convexMaxSupply, + convexTotalCliffs, + ] = await Promise.all([ convexCVXContract.methods.reductionPerCliff().call(), convexCVXContract.methods.totalSupply().call(), convexCVXContract.methods.maxSupply().call(), convexCVXContract.methods.totalCliffs().call(), ]); - let gaugeControllerContract = new web3.eth.Contract(abis.curveGaugeControllerABI, FF_CURVE_GAUGE_CONTROLLER); + let gaugeControllerContract = new web3.eth.Contract( + abis.curveGaugeControllerABI, + FF_CURVE_GAUGE_CONTROLLER + ); let curveFiBaseAPY = []; try { const url = `${CURVE_FI_STATS_API}api/getFactoryAPYs?version=2`; const apysResult = await fetch(url); const apysJSON = await apysResult.json(); curveFiBaseAPY = apysJSON.data.poolDetails.filter((pool) => { - return [IBAUDUSDC_POOL_ADDRESS, IBCHFUSDC_POOL_ADDRESS, IBEURUSDC_POOL_ADDRESS, IBGBPUSDC_POOL_ADDRESS, IBJPYUSDC_POOL_ADDRESS, IBKRWUSDC_POOL_ADDRESS, IBGBP_POOL_ADDRESS, IBJPY_POOL_ADDRESS, IBKRW_POOL_ADDRESS, IBAUD_POOL_ADDRESS, IBCHF_POOL_ADDRESS, IBEUR_POOL_ADDRESS, IBEUR_AG_POOL_ADDRESS].includes(pool.poolAddress); + return [ + IBAUDUSDC_POOL_ADDRESS, + IBCHFUSDC_POOL_ADDRESS, + IBEURUSDC_POOL_ADDRESS, + IBGBPUSDC_POOL_ADDRESS, + IBJPYUSDC_POOL_ADDRESS, + IBKRWUSDC_POOL_ADDRESS, + IBGBP_POOL_ADDRESS, + IBJPY_POOL_ADDRESS, + IBKRW_POOL_ADDRESS, + IBAUD_POOL_ADDRESS, + IBCHF_POOL_ADDRESS, + IBEUR_POOL_ADDRESS, + IBEUR_AG_POOL_ADDRESS, + ].includes(pool.poolAddress); }); } catch (ex) { console.warn(ex); @@ -1201,60 +1273,74 @@ class Store { } catch (ex) { console.warn(ex); } - + const assetsBalances = await Promise.all( assets.map(async (asset) => { let balanceOf, - userGaugeBalance, - userGaugeEarned, - userRKP3REarned, - poolBalances, - userPoolBalance, - poolSymbol, - virtualPrice, - poolGaugeAllowance, - coins0, - coins1, - gaugeVotes, - userGaugeVotes, - price, - curveInflationRate, - curveWorkingSupply, - curveGaugeWeight, - curveTotalWeight, - poolConvexAllowance, - poolYearnAllowance, - curveRewardData, - coin0Symbol, - coin0Decimals, - coin0Balance, - coin0GaugeAllowance, - coin1Symbol, - coin1Decimals, - coin1Balance, - coin1GaugeAllowance, - convexBalanceOf, - convexEarned, - userVaultBalance, - yearnPoolSymbol, - yearnBalanceOf, - coin0, - coin1, - convexRewardCallsResponse, - swapAllowanceV2, - swapAllowanceV3, - poolBalances0, - poolBalances1 - - poolBalances = [] - let _poolContract = new web3.eth.Contract(abis.poolABI, asset.gauge.poolAddress); + userGaugeBalance, + userGaugeEarned, + userRKP3REarned, + poolBalances, + userPoolBalance, + poolSymbol, + virtualPrice, + poolGaugeAllowance, + coins0, + coins1, + gaugeVotes, + userGaugeVotes, + price, + curveInflationRate, + curveWorkingSupply, + curveGaugeWeight, + curveTotalWeight, + poolConvexAllowance, + poolYearnAllowance, + curveRewardData, + coin0Symbol, + coin0Decimals, + coin0Balance, + coin0GaugeAllowance, + coin1Symbol, + coin1Decimals, + coin1Balance, + coin1GaugeAllowance, + convexBalanceOf, + convexEarned, + userVaultBalance, + yearnPoolSymbol, + yearnBalanceOf, + coin0, + coin1, + convexRewardCallsResponse, + swapAllowanceV2, + swapAllowanceV3, + poolBalances0, + poolBalances1; + poolBalances = []; + let _poolContract = new web3.eth.Contract( + abis.poolABI, + asset.gauge.poolAddress + ); if (asset.shouldUseNewABI) { - const assetContract = new web3.eth.Contract(abis.erc20ABI, asset.address); - const gaugeContract = new web3.eth.Contract(abis.ibsmtusdc, asset.gauge.address); - const poolContract = new web3.eth.Contract(abis.ibsmtusdcPool, asset.gauge.poolAddress); - const tokenContract = new web3.eth.Contract(abis.erc20ABI, asset.address); + const assetContract = new web3.eth.Contract( + abis.erc20ABI, + asset.address + ); + const gaugeContract = new web3.eth.Contract( + abis.ibsmtusdc, + asset.gauge.address + ); + const poolContract = new web3.eth.Contract( + abis.ibsmtusdcPool, + asset.gauge.poolAddress + ); + const tokenContract = new web3.eth.Contract( + abis.erc20ABI, + asset.address + ); _poolContract = tokenContract; [ @@ -1279,43 +1365,70 @@ class Store { curveTotalWeight, curveRewardData, swapAllowanceV2, - swapAllowanceV3 + swapAllowanceV3, ] = await Promise.all([ assetContract.methods.balanceOf(account.address).call(), gaugeContract.methods.balanceOf(account.address).call(), - + // gaugeContract.methods.claimable_tokens(account.address).call(), - gaugeContract.methods.claimable_reward(account.address, FF_RKP3R_ADDRESS).call(), - - gaugeContract.methods.claimable_reward(account.address, FF_RKP3R_ADDRESS).call(), + gaugeContract.methods + .claimable_reward(account.address, FF_RKP3R_ADDRESS) + .call(), + + gaugeContract.methods + .claimable_reward(account.address, FF_RKP3R_ADDRESS) + .call(), poolContract.methods.balances(0).call(), poolContract.methods.balances(1).call(), tokenContract.methods.balanceOf(account.address).call(), tokenContract.methods.symbol().call(), poolContract.methods.get_virtual_price().call(), - tokenContract.methods.allowance(account.address, asset.gauge.address).call(), + tokenContract.methods + .allowance(account.address, asset.gauge.address) + .call(), poolContract.methods.coins(0).call(), poolContract.methods.coins(1).call(), - gaugeProxyContract.methods.weights(asset.gauge.poolAddress).call(), - gaugeProxyContract.methods.votes(account.address, asset.gauge.poolAddress).call(), - priceOracleContract.methods.getUnderlyingPrice(asset.oracleAddress).call(), + gaugeProxyContract.methods + .weights(asset.gauge.poolAddress) + .call(), + gaugeProxyContract.methods + .votes(account.address, asset.gauge.poolAddress) + .call(), + priceOracleContract.methods + .getUnderlyingPrice(asset.oracleAddress) + .call(), gaugeContract.methods.inflation_rate().call(), gaugeContract.methods.working_supply().call(), - gaugeControllerContract.methods.get_gauge_weight(asset.gauge.address).call(), + gaugeControllerContract.methods + .get_gauge_weight(asset.gauge.address) + .call(), gaugeControllerContract.methods.get_total_weight().call(), gaugeContract.methods.reward_data(FF_RKP3R_ADDRESS).call(), - assetContract.methods.allowance(account.address, FF_IBAMM_V2_ADDRESS).call(), - assetContract.methods.allowance(account.address, FF_IBAMM_V3_ADDRESS).call(), + assetContract.methods + .allowance(account.address, FF_IBAMM_V2_ADDRESS) + .call(), + assetContract.methods + .allowance(account.address, FF_IBAMM_V3_ADDRESS) + .call(), ]); - poolBalances[0] = poolBalances0 - poolBalances[1] = poolBalances1 + poolBalances[0] = poolBalances0; + poolBalances[1] = poolBalances1; if (asset.address === KP3RETH_ADDRESS) { - price = 0 + price = 0; } } else { - const assetContract = new web3.eth.Contract(abis.erc20ABI, asset.address); - const gaugeContract = new web3.eth.Contract(abis.gaugeABI, asset.gauge.address); - const poolContract = new web3.eth.Contract(abis.poolABI, asset.gauge.poolAddress); + const assetContract = new web3.eth.Contract( + abis.erc20ABI, + asset.address + ); + const gaugeContract = new web3.eth.Contract( + abis.gaugeABI, + asset.gauge.address + ); + const poolContract = new web3.eth.Contract( + abis.poolABI, + asset.gauge.poolAddress + ); [ balanceOf, @@ -1338,45 +1451,74 @@ class Store { curveTotalWeight, curveRewardData, swapAllowanceV2, - swapAllowanceV3 + swapAllowanceV3, ] = await Promise.all([ assetContract.methods.balanceOf(account.address).call(), gaugeContract.methods.balanceOf(account.address).call(), gaugeContract.methods.claimable_tokens(account.address).call(), - gaugeContract.methods.claimable_reward(account.address, FF_RKP3R_ADDRESS).call(), + gaugeContract.methods + .claimable_reward(account.address, FF_RKP3R_ADDRESS) + .call(), poolContract.methods.get_balances().call(), poolContract.methods.balanceOf(account.address).call(), poolContract.methods.symbol().call(), poolContract.methods.get_virtual_price().call(), - poolContract.methods.allowance(account.address, asset.gauge.address).call(), + poolContract.methods + .allowance(account.address, asset.gauge.address) + .call(), poolContract.methods.coins(0).call(), poolContract.methods.coins(1).call(), - gaugeProxyContract.methods.weights(asset.gauge.poolAddress).call(), - gaugeProxyContract.methods.votes(account.address, asset.gauge.poolAddress).call(), - priceOracleContract.methods.getUnderlyingPrice(asset.oracleAddress).call(), + gaugeProxyContract.methods + .weights(asset.gauge.poolAddress) + .call(), + gaugeProxyContract.methods + .votes(account.address, asset.gauge.poolAddress) + .call(), + priceOracleContract.methods + .getUnderlyingPrice(asset.oracleAddress) + .call(), gaugeContract.methods.inflation_rate().call(), gaugeContract.methods.working_supply().call(), - gaugeControllerContract.methods.get_gauge_weight(asset.gauge.address).call(), + gaugeControllerContract.methods + .get_gauge_weight(asset.gauge.address) + .call(), gaugeControllerContract.methods.get_total_weight().call(), gaugeContract.methods.reward_data(FF_RKP3R_ADDRESS).call(), - assetContract.methods.allowance(account.address, FF_IBAMM_V2_ADDRESS).call(), - assetContract.methods.allowance(account.address, FF_IBAMM_V3_ADDRESS).call(), + assetContract.methods + .allowance(account.address, FF_IBAMM_V2_ADDRESS) + .call(), + assetContract.methods + .allowance(account.address, FF_IBAMM_V3_ADDRESS) + .call(), ]); } // get coin asset info const coin0Contract = new web3.eth.Contract(abis.erc20ABI, coins0); const coin1Contract = new web3.eth.Contract(abis.erc20ABI, coins1); - [coin0Symbol, coin0Decimals, coin0Balance, coin0GaugeAllowance, coin1Symbol, coin1Decimals, coin1Balance, coin1GaugeAllowance] = await Promise.all([ - coin0Contract.methods.symbol().call(), - coin0Contract.methods.decimals().call(), - coin0Contract.methods.balanceOf(account.address).call(), - coin0Contract.methods.allowance(account.address, asset.gauge.poolAddress).call(), - - coin1Contract.methods.symbol().call(), - coin1Contract.methods.decimals().call(), - coin1Contract.methods.balanceOf(account.address).call(), - coin1Contract.methods.allowance(account.address, asset.gauge.poolAddress).call(), + [ + coin0Symbol, + coin0Decimals, + coin0Balance, + coin0GaugeAllowance, + coin1Symbol, + coin1Decimals, + coin1Balance, + coin1GaugeAllowance, + ] = await Promise.all([ + coin0Contract.methods.symbol().call(), + coin0Contract.methods.decimals().call(), + coin0Contract.methods.balanceOf(account.address).call(), + coin0Contract.methods + .allowance(account.address, asset.gauge.poolAddress) + .call(), + + coin1Contract.methods.symbol().call(), + coin1Contract.methods.decimals().call(), + coin1Contract.methods.balanceOf(account.address).call(), + coin1Contract.methods + .allowance(account.address, asset.gauge.poolAddress) + .call(), ]); let intCoin0Decimasls = parseInt(coin0Decimals); @@ -1385,44 +1527,75 @@ class Store { address: coins0, symbol: coin0Symbol, decimals: intCoin0Decimasls, - balance: BigNumber(coin0Balance).div(10 ** intCoin0Decimasls).toFixed(intCoin0Decimasls), - poolBalance: BigNumber(poolBalances[0]).div(10 ** intCoin0Decimasls).toFixed(intCoin0Decimasls), - gaugeAllowance: BigNumber(coin0GaugeAllowance).div(10 ** intCoin0Decimasls).toFixed(intCoin0Decimasls), + balance: BigNumber(coin0Balance) + .div(10 ** intCoin0Decimasls) + .toFixed(intCoin0Decimasls), + poolBalance: BigNumber(poolBalances[0]) + .div(10 ** intCoin0Decimasls) + .toFixed(intCoin0Decimasls), + gaugeAllowance: BigNumber(coin0GaugeAllowance) + .div(10 ** intCoin0Decimasls) + .toFixed(intCoin0Decimasls), }; coin1 = { address: coins1, symbol: coin1Symbol, decimals: intCoin1Decimasls, - balance: BigNumber(coin1Balance).div(10 ** intCoin1Decimasls).toFixed(intCoin1Decimasls), - poolBalance: BigNumber(poolBalances[1]).div(10 ** intCoin1Decimasls).toFixed(intCoin1Decimasls), - gaugeAllowance: BigNumber(coin1GaugeAllowance).div(10 ** intCoin1Decimasls).toFixed(intCoin1Decimasls), + balance: BigNumber(coin1Balance) + .div(10 ** intCoin1Decimasls) + .toFixed(intCoin1Decimasls), + poolBalance: BigNumber(poolBalances[1]) + .div(10 ** intCoin1Decimasls) + .toFixed(intCoin1Decimasls), + gaugeAllowance: BigNumber(coin1GaugeAllowance) + .div(10 ** intCoin1Decimasls) + .toFixed(intCoin1Decimasls), }; - if (asset.convex.address && asset.convex.address !== '') { - const convexGaugeContract = new web3.eth.Contract(abis.convexBaseRewardPoolABI, asset.convex.address); - [convexBalanceOf, convexEarned, poolConvexAllowance] = await Promise.all([ - convexGaugeContract.methods.balanceOf(account.address).call(), - convexGaugeContract.methods.earned(account.address).call(), - _poolContract.methods.allowance(account.address, FF_CONVEX_POOL_MANAGEMENT_ADDRESS).call(), - ]); - - const convexRewardContract = new web3.eth.Contract(abis.convexVirtualBalanceRewardPoolABI, asset.convex.rewards[0].poolAddress); - convexRewardCallsResponse = await convexRewardContract.methods.earned(account.address).call(); + if (asset.convex.address && asset.convex.address !== "") { + const convexGaugeContract = new web3.eth.Contract( + abis.convexBaseRewardPoolABI, + asset.convex.address + ); + [convexBalanceOf, convexEarned, poolConvexAllowance] = + await Promise.all([ + convexGaugeContract.methods.balanceOf(account.address).call(), + convexGaugeContract.methods.earned(account.address).call(), + _poolContract.methods + .allowance(account.address, FF_CONVEX_POOL_MANAGEMENT_ADDRESS) + .call(), + ]); + + const convexRewardContract = new web3.eth.Contract( + abis.convexVirtualBalanceRewardPoolABI, + asset.convex.rewards[0].poolAddress + ); + convexRewardCallsResponse = await convexRewardContract.methods + .earned(account.address) + .call(); } - if (asset.yearn.address && asset.yearn.address !== '') { - const yearnVaultContract = new web3.eth.Contract(abis.yearnVaultABI, asset.yearn.address); + if (asset.yearn.address && asset.yearn.address !== "") { + const yearnVaultContract = new web3.eth.Contract( + abis.yearnVaultABI, + asset.yearn.address + ); - [userVaultBalance, yearnPoolSymbol, yearnBalanceOf, poolYearnAllowance,] = await Promise.all([ + [ + userVaultBalance, + yearnPoolSymbol, + yearnBalanceOf, + poolYearnAllowance, + ] = await Promise.all([ yearnVaultContract.methods.balanceOf(account.address).call(), yearnVaultContract.methods.symbol().call(), yearnVaultContract.methods.balanceOf(account.address).call(), - _poolContract.methods.allowance(account.address, asset.yearn.address).call(), + _poolContract.methods + .allowance(account.address, asset.yearn.address) + .call(), ]); } - - return { balanceOf, poolBalances, @@ -1455,9 +1628,9 @@ class Store { curveRewardData, yearnPoolSymbol, swapAllowanceV2, - swapAllowanceV3 + swapAllowanceV3, }; - }), + }) ); const totalUserVotes = assetsBalances.reduce((curr, acc) => { @@ -1467,7 +1640,10 @@ class Store { for (let i = 0; i < assets.length; i++) { let userVotePercent = "0"; if (BigNumber(totalUserVotes).gt(0)) { - userVotePercent = BigNumber(assetsBalances[i].userGaugeVotes).times(100).div(totalUserVotes).toFixed(assets[i].decimals); + userVotePercent = BigNumber(assetsBalances[i].userGaugeVotes) + .times(100) + .div(totalUserVotes) + .toFixed(assets[i].decimals); } assets[i].balance = BigNumber(assetsBalances[i].balanceOf) @@ -1483,13 +1659,21 @@ class Store { assets[i].gauge.coin1 = assetsBalances[i].coin1; assets[i].gauge.poolSymbol = assetsBalances[i].poolSymbol; assets[i].yearn.poolSymbol = assetsBalances[i].yearnPoolSymbol; - assets[i].gauge.userPoolBalance = BigNumber(assetsBalances[i].userPoolBalance) + assets[i].gauge.userPoolBalance = BigNumber( + assetsBalances[i].userPoolBalance + ) .div(10 ** 18) .toFixed(18); - assets[i].gauge.userGaugeBalance = BigNumber(assetsBalances[i].userGaugeBalance) + assets[i].gauge.userGaugeBalance = BigNumber( + assetsBalances[i].userGaugeBalance + ) .div(10 ** 18) .toFixed(18); - assets[i].yearn.userVaultBalance = BigNumber(assetsBalances[i].userVaultBalance ? assetsBalances[i].userVaultBalance : 0) + assets[i].yearn.userVaultBalance = BigNumber( + assetsBalances[i].userVaultBalance + ? assetsBalances[i].userVaultBalance + : 0 + ) .div(10 ** 18) .toFixed(18); assets[i].gauge.earned = BigNumber(assetsBalances[i].userGaugeEarned) @@ -1498,7 +1682,9 @@ class Store { assets[i].gauge.virtualPrice = BigNumber(assetsBalances[i].virtualPrice) .div(10 ** 18) .toFixed(18); - assets[i].gauge.poolGaugeAllowance = BigNumber(assetsBalances[i].poolGaugeAllowance) + assets[i].gauge.poolGaugeAllowance = BigNumber( + assetsBalances[i].poolGaugeAllowance + ) .div(10 ** 18) .toFixed(18); @@ -1509,37 +1695,58 @@ class Store { assets[i].gauge.votes = BigNumber(assetsBalances[i].gaugeVotes) .div(10 ** assets[i].decimals) .toFixed(assets[i].decimals); - assets[i].gauge.votePercent = BigNumber(assetsBalances[i].gaugeVotes).times(100).div(totalGaugeVotes).toFixed(assets[i].decimals); + assets[i].gauge.votePercent = BigNumber(assetsBalances[i].gaugeVotes) + .times(100) + .div(totalGaugeVotes) + .toFixed(assets[i].decimals); - assets[i].gauge.rKP3REarned = BigNumber(assetsBalances[i].userRKP3REarned) + assets[i].gauge.rKP3REarned = BigNumber( + assetsBalances[i].userRKP3REarned + ) .div(10 ** 18) .toFixed(18); assets[i].price = BigNumber(assetsBalances[i].price) .div(10 ** (36 - assets[i].decimals)) .toFixed(18); - assets[i].convex.balance = BigNumber(assetsBalances[i].convexBalanceOf ? assetsBalances[i].convexBalanceOf : 0) + assets[i].convex.balance = BigNumber( + assetsBalances[i].convexBalanceOf + ? assetsBalances[i].convexBalanceOf + : 0 + ) .div(10 ** 18) .toFixed(18); - assets[i].convex.earnedCRV = BigNumber(assetsBalances[i].convexEarned ? assetsBalances[i].convexEarned : 0) + assets[i].convex.earnedCRV = BigNumber( + assetsBalances[i].convexEarned ? assetsBalances[i].convexEarned : 0 + ) .div(10 ** 18) .toFixed(18); // this is crv - const cliff = BigNumber(assetsBalances[i].convexTotalSupply).div(assetsBalances[i].convexReductionPerCliff).toFixed(18); - const reduction = BigNumber(assetsBalances[i].convexTotalCliffs).minus(cliff).toFixed(18); + const cliff = BigNumber(assetsBalances[i].convexTotalSupply) + .div(assetsBalances[i].convexReductionPerCliff) + .toFixed(18); + const reduction = BigNumber(assetsBalances[i].convexTotalCliffs) + .minus(cliff) + .toFixed(18); assets[i].convex.earnedCVX = BigNumber(assetsBalances[i].convexEarned) .times(reduction) .div(assetsBalances[i].convexTotalCliffs) .div(10 ** 18) .toFixed(18); // this is crv - assets[i].convex.earnedRKP3R = BigNumber(assetsBalances[i].convexRewardCallsResponse) + assets[i].convex.earnedRKP3R = BigNumber( + assetsBalances[i].convexRewardCallsResponse + ) .div(10 ** 18) .toFixed(18); - assets[i].convex.poolGaugeAllowance = BigNumber(assetsBalances[i].poolConvexAllowance) + assets[i].convex.poolGaugeAllowance = BigNumber( + assetsBalances[i].poolConvexAllowance + ) .div(10 ** 18) .toFixed(18); - assets[i].yearn.poolGaugeAllowance = BigNumber(assetsBalances[i].poolYearnAllowance) + assets[i].yearn.poolGaugeAllowance = BigNumber( + assetsBalances[i].poolYearnAllowance + ) .div(10 ** 18) .toFixed(18); @@ -1553,10 +1760,12 @@ class Store { assetsBalances[i].curveWorkingSupply, assetsBalances[i].virtualPrice, assetsBalances[i].price, - curvePrice, - ), + curvePrice + ) ).toFixed(18); - assets[i].gauge.apyBoosted = BigNumber(assets[i].gauge.apyBase).times(2.5).toFixed(18); + assets[i].gauge.apyBoosted = BigNumber(assets[i].gauge.apyBase) + .times(2.5) + .toFixed(18); let poolMeta = curveFiBaseAPY.filter((pool) => { return pool.poolAddress === assets[i].gauge.poolAddress; @@ -1578,9 +1787,18 @@ class Store { _getRewardInfo = async (web3, account) => { try { - const ibEURClaimContract = new web3.eth.Contract(abis.curveFeeDistributionABI, FF_IBEUR_CLAIMABLE_ADDRESS); - const kp3rClaimContract = new web3.eth.Contract(abis.curveFeeDistributionABI, FF_KP3R_CLAIMABLE_ADDRESS); - const stakingRewardsV3Contract = new web3.eth.Contract(abis.stakingRewardsV3ABI, FF_STAKING_REWARDS_V3_ADDRESS); + const ibEURClaimContract = new web3.eth.Contract( + abis.curveFeeDistributionABI, + FF_IBEUR_CLAIMABLE_ADDRESS + ); + const kp3rClaimContract = new web3.eth.Contract( + abis.curveFeeDistributionABI, + FF_KP3R_CLAIMABLE_ADDRESS + ); + const stakingRewardsV3Contract = new web3.eth.Contract( + abis.stakingRewardsV3ABI, + FF_STAKING_REWARDS_V3_ADDRESS + ); const [ibEURClaimable, kp3rClaimable] = await Promise.all([ ibEURClaimContract.methods.claimable(account.address).call(), @@ -1600,15 +1818,24 @@ class Store { this.setStore({ rewards }); this.emitter.emit(FIXED_FOREX_UPDATED); } catch (ex) { - console.log(ex); + console.error(ex); } }; _getOldGaugeInfo = async (web3, account) => { try { - const eurContract = new web3.eth.Contract(abis.gaugeABI, IBEUR_GAUGE_ADDRESS_OLD); - const krwContract = new web3.eth.Contract(abis.gaugeABI, IBKRW_GAUGE_ADDRESS_OLD); - const ibEURFaucetContract = new web3.eth.Contract(abis.gaugeABI, IBEUR_ETH_ADDRESS_OLD); + const eurContract = new web3.eth.Contract( + abis.gaugeABI, + IBEUR_GAUGE_ADDRESS_OLD + ); + const krwContract = new web3.eth.Contract( + abis.gaugeABI, + IBKRW_GAUGE_ADDRESS_OLD + ); + const ibEURFaucetContract = new web3.eth.Contract( + abis.gaugeABI, + IBEUR_ETH_ADDRESS_OLD + ); const [eurBalance, krwBalance, ibEURBalance] = await Promise.all([ eurContract.methods.balanceOf(account.address).call(), @@ -1649,45 +1876,71 @@ class Store { }); this.emitter.emit(FIXED_FOREX_UPDATED); } catch (ex) { - console.log(ex); + console.error(ex); } }; _getUniV3Info = async (web3, account) => { try { - const uniswapNFTPositionsManagerContract = new web3.eth.Contract(abis.uniswapNFTPositionsManagerABI, FF_UNSIWAP_POSITIONS_MANAGER_ADDRESS) - const balanceOf = await uniswapNFTPositionsManagerContract.methods.balanceOf(account.address).call() - const arr = [...Array(parseInt(balanceOf)).keys()] - - const tokenIDs = await Promise.all(arr.map((idx) => { - return uniswapNFTPositionsManagerContract.methods.tokenOfOwnerByIndex(account.address, idx).call() - })); - - const tokenPositions = await Promise.all(tokenIDs.map((idx) => { - return uniswapNFTPositionsManagerContract.methods.positions(idx).call() - })) - - const validPositions = await Promise.all(tokenPositions.filter((pos, idx) => { - const isActive = pos.token0 === '0x1cEB5cB57C4D4E2b2433641b95Dd330A33185A44' && pos.token1 === '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2' && BigNumber(pos.liquidity).gt(0) - pos.tokenID = tokenIDs[idx] - return isActive - }).map(async (pos) => { - pos.address = "0x11B7a6bc0259ed6Cf9DB8F499988F9eCc7167bf5"; - pos.balance = BigNumber(pos.liquidity).div(10**18).toFixed(18) - pos.feePercent = BigNumber(pos.fee).div(10000).toFixed(4) - - const approved = await uniswapNFTPositionsManagerContract.methods.getApproved(pos.tokenID).call() - if(approved.toLowerCase() === FF_STAKING_REWARDS_V3_ADDRESS.toLowerCase()) { - pos.stakingApproved = true - } else { - pos.stakingApproved = false - } + const uniswapNFTPositionsManagerContract = new web3.eth.Contract( + abis.uniswapNFTPositionsManagerABI, + FF_UNSIWAP_POSITIONS_MANAGER_ADDRESS + ); + const balanceOf = await uniswapNFTPositionsManagerContract.methods + .balanceOf(account.address) + .call(); + const arr = [...Array(parseInt(balanceOf)).keys()]; + + const tokenIDs = await Promise.all( + arr.map((idx) => { + return uniswapNFTPositionsManagerContract.methods + .tokenOfOwnerByIndex(account.address, idx) + .call(); + }) + ); + + const tokenPositions = await Promise.all( + tokenIDs.map((idx) => { + return uniswapNFTPositionsManagerContract.methods + .positions(idx) + .call(); + }) + ); + + const validPositions = await Promise.all( + tokenPositions + .filter((pos, idx) => { + const isActive = + pos.token0 === "0x1cEB5cB57C4D4E2b2433641b95Dd330A33185A44" && + pos.token1 === "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" && + BigNumber(pos.liquidity).gt(0); + pos.tokenID = tokenIDs[idx]; + return isActive; + }) + .map(async (pos) => { + pos.address = "0x11B7a6bc0259ed6Cf9DB8F499988F9eCc7167bf5"; + pos.balance = BigNumber(pos.liquidity) + .div(10 ** 18) + .toFixed(18); + pos.feePercent = BigNumber(pos.fee).div(10000).toFixed(4); + + const approved = await uniswapNFTPositionsManagerContract.methods + .getApproved(pos.tokenID) + .call(); + if ( + approved.toLowerCase() === + FF_STAKING_REWARDS_V3_ADDRESS.toLowerCase() + ) { + pos.stakingApproved = true; + } else { + pos.stakingApproved = false; + } const prices = await this._getPoolPriceInfo(web3, account, pos); pos.prices = prices; return pos; - }), + }) ); this.setStore({ @@ -1695,14 +1948,20 @@ class Store { }); this.emitter.emit(FIXED_FOREX_UPDATED); } catch (ex) { - console.log(ex); + console.error(ex); } }; _getStakingV3Rewards = async (web3, account) => { try { - const stakingRewardsAddress = new web3.eth.Contract(abis.stakingRewardsV3ABI, FF_STAKING_REWARDS_V3_ADDRESS); - const uniswapNFTPositionsManagerContract = new web3.eth.Contract(abis.uniswapNFTPositionsManagerABI, FF_UNSIWAP_POSITIONS_MANAGER_ADDRESS); + const stakingRewardsAddress = new web3.eth.Contract( + abis.stakingRewardsV3ABI, + FF_STAKING_REWARDS_V3_ADDRESS + ); + const uniswapNFTPositionsManagerContract = new web3.eth.Contract( + abis.uniswapNFTPositionsManagerABI, + FF_UNSIWAP_POSITIONS_MANAGER_ADDRESS + ); // const [ rewardPerLiquidity, getRewardForDuration, totalLiquidity ] = await Promise.all([ // stakingRewardsAddress.methods.rewardPerLiquidity().call(), @@ -1717,18 +1976,22 @@ class Store { // // console.log(apr) - const tokenIDs = await stakingRewardsAddress.methods.getTokenIds(account.address).call(); + const tokenIDs = await stakingRewardsAddress.methods + .getTokenIds(account.address) + .call(); const tokenPositions = await Promise.all( tokenIDs.map((idx) => { - return uniswapNFTPositionsManagerContract.methods.positions(idx).call(); - }), + return uniswapNFTPositionsManagerContract.methods + .positions(idx) + .call(); + }) ); const earneds = await Promise.all( tokenIDs.map((idx) => { return stakingRewardsAddress.methods.earned(idx).call(); - }), + }) ); const stakingV3Positions = await Promise.all( @@ -1746,7 +2009,7 @@ class Store { const prices = await this._getPoolPriceInfo(web3, account, pos); pos.prices = prices; return pos; - }), + }) ); this.setStore({ @@ -1755,27 +2018,41 @@ class Store { this.emitter.emit(FIXED_FOREX_UPDATED); } catch (ex) { - console.log(ex); + console.error(ex); } }; _getPoolPriceInfo = async (web3, account, pos) => { - const poolContract = new web3.eth.Contract(abis.uniswapV3PoolABI, pos.address); - - const [factory, token0, token1, fee, tickSpacing, maxLiquidityPerTick] = await Promise.all([ - poolContract.methods.factory().call(), - poolContract.methods.token0().call(), - poolContract.methods.token1().call(), - poolContract.methods.fee().call(), - poolContract.methods.tickSpacing().call(), - poolContract.methods.maxLiquidityPerTick().call(), - ]); + const poolContract = new web3.eth.Contract( + abis.uniswapV3PoolABI, + pos.address + ); + + const [factory, token0, token1, fee, tickSpacing, maxLiquidityPerTick] = + await Promise.all([ + poolContract.methods.factory().call(), + poolContract.methods.token0().call(), + poolContract.methods.token1().call(), + poolContract.methods.fee().call(), + poolContract.methods.tickSpacing().call(), + poolContract.methods.maxLiquidityPerTick().call(), + ]); - const [liquidity, slot] = await Promise.all([poolContract.methods.liquidity().call(), poolContract.methods.slot0().call()]); + const [liquidity, slot] = await Promise.all([ + poolContract.methods.liquidity().call(), + poolContract.methods.slot0().call(), + ]); const TokenA = new Token(3, token0, 18, "KP3R", "Keep3rV1"); const TokenB = new Token(3, token1, 18, "WETH", "Wrapped Ether"); - const poolExample = new Pool(TokenA, TokenB, parseInt(fee), slot[0].toString(), liquidity.toString(), parseInt(slot[1])); + const poolExample = new Pool( + TokenA, + TokenB, + parseInt(fee), + slot[0].toString(), + liquidity.toString(), + parseInt(slot[1]) + ); const r = tickToPrice(TokenA, TokenB, poolExample.tickCurrent); const l = tickToPrice(TokenA, TokenB, parseInt(pos.tickUpper)); @@ -1794,87 +2071,127 @@ class Store { _getSwapFromBalances = async (web3, account) => { try { - const swapFromAssets = this.getStore('swapFromAssets') - const assetsBalances = await Promise.all(swapFromAssets.map(async (asset) => { - const assetContract = new web3.eth.Contract(abis.erc20ABI, asset.address) - - const [ balanceOf, allowance, allowanceV2, allowanceV3 ] = await Promise.all([ - assetContract.methods.balanceOf(account.address).call(), - assetContract.methods.allowance(account.address, FF_IBAMM_ADDRESS).call(), - assetContract.methods.allowance(account.address, FF_IBAMM_V2_ADDRESS).call(), - assetContract.methods.allowance(account.address, FF_IBAMM_V3_ADDRESS).call(), - ]); - - return { - balanceOf, - allowance, - allowanceV2, - allowanceV3, - } - })) + const swapFromAssets = this.getStore("swapFromAssets"); + const assetsBalances = await Promise.all( + swapFromAssets.map(async (asset) => { + const assetContract = new web3.eth.Contract( + abis.erc20ABI, + asset.address + ); + + const [balanceOf, allowance, allowanceV2, allowanceV3] = + await Promise.all([ + assetContract.methods.balanceOf(account.address).call(), + assetContract.methods + .allowance(account.address, FF_IBAMM_ADDRESS) + .call(), + assetContract.methods + .allowance(account.address, FF_IBAMM_V2_ADDRESS) + .call(), + assetContract.methods + .allowance(account.address, FF_IBAMM_V3_ADDRESS) + .call(), + ]); + + return { + balanceOf, + allowance, + allowanceV2, + allowanceV3, + }; + }) + ); - for(let i = 0; i < assetsBalances.length; i++) { - swapFromAssets[i].balance = BigNumber(assetsBalances[i].balanceOf).div(10**swapFromAssets[i].decimals).toFixed(swapFromAssets[i].decimals) - swapFromAssets[i].allowance = BigNumber(assetsBalances[i].allowance).div(10**swapFromAssets[i].decimals).toFixed(swapFromAssets[i].decimals) - swapFromAssets[i].allowanceV2 = BigNumber(assetsBalances[i].allowanceV2).div(10**swapFromAssets[i].decimals).toFixed(swapFromAssets[i].decimals) - swapFromAssets[i].allowanceV3 = BigNumber(assetsBalances[i].allowanceV3).div(10**swapFromAssets[i].decimals).toFixed(swapFromAssets[i].decimals) + for (let i = 0; i < assetsBalances.length; i++) { + swapFromAssets[i].balance = BigNumber(assetsBalances[i].balanceOf) + .div(10 ** swapFromAssets[i].decimals) + .toFixed(swapFromAssets[i].decimals); + swapFromAssets[i].allowance = BigNumber(assetsBalances[i].allowance) + .div(10 ** swapFromAssets[i].decimals) + .toFixed(swapFromAssets[i].decimals); + swapFromAssets[i].allowanceV2 = BigNumber(assetsBalances[i].allowanceV2) + .div(10 ** swapFromAssets[i].decimals) + .toFixed(swapFromAssets[i].decimals); + swapFromAssets[i].allowanceV3 = BigNumber(assetsBalances[i].allowanceV3) + .div(10 ** swapFromAssets[i].decimals) + .toFixed(swapFromAssets[i].decimals); } this.setStore({ - swapFromAssets: swapFromAssets - }) + swapFromAssets: swapFromAssets, + }); this.emitter.emit(FIXED_FOREX_UPDATED); - } catch(ex) { - console.log(ex) + } catch (ex) { + console.log(ex); } }; _getBreaker = async (web3, account) => { try { - const ibAMMContract = new web3.eth.Contract(abis.ibAMMABI, FF_IBAMM_ADDRESS); - const breaker = await ibAMMContract.methods.breaker().call() + const ibAMMContract = new web3.eth.Contract( + abis.ibAMMABI, + FF_IBAMM_ADDRESS + ); + const breaker = await ibAMMContract.methods.breaker().call(); this.setStore({ - breaker - }) + breaker, + }); this.emitter.emit(FIXED_FOREX_UPDATED); - } catch(ex) { - - } - } + } catch (ex) {} + }; _getVestingInfo = async (web3, account, veIBFF) => { try { - - const veIBFFContract = new web3.eth.Contract(abis.veIBFFABI, FF_VEKP3R_ADDRESS) - const lockedInfo = await veIBFFContract.methods.locked(account.address).call() - const totalSupply = await veIBFFContract.methods.totalSupply().call() - const balanceOf = await veIBFFContract.methods.balanceOf(account.address).call() + const veIBFFContract = new web3.eth.Contract( + abis.veIBFFABI, + FF_VEKP3R_ADDRESS + ); + const lockedInfo = await veIBFFContract.methods + .locked(account.address) + .call(); + const totalSupply = await veIBFFContract.methods.totalSupply().call(); + const balanceOf = await veIBFFContract.methods + .balanceOf(account.address) + .call(); // const fourYears = 126144000 // 60 * 60 * 24 * 365 * 4 // const now = Math.floor(Date.now() / 1000) // const maxLock = BigNumber(now).plus(fourYears).toNumber() // const percentOfFourYearsLocked = 1-BigNumber(maxLock).minus(lockedInfo.end).div(fourYears).toFixed(veIBFF.decimals) - const locked = BigNumber(lockedInfo.amount).div(10**veIBFF.decimals).toFixed(veIBFF.decimals) + const locked = BigNumber(lockedInfo.amount) + .div(10 ** veIBFF.decimals) + .toFixed(veIBFF.decimals); return { locked: locked, lockEnds: lockedInfo.end, - lockValue: BigNumber(balanceOf).div(10**veIBFF.decimals).toFixed(veIBFF.decimals), - votePower: BigNumber(balanceOf).div(10**veIBFF.decimals).toFixed(veIBFF.decimals), - totalSupply: BigNumber(totalSupply).div(10**veIBFF.decimals).toFixed(veIBFF.decimals), - } - } catch(ex) { - console.log(ex) - return null + lockValue: BigNumber(balanceOf) + .div(10 ** veIBFF.decimals) + .toFixed(veIBFF.decimals), + votePower: BigNumber(balanceOf) + .div(10 ** veIBFF.decimals) + .toFixed(veIBFF.decimals), + totalSupply: BigNumber(totalSupply) + .div(10 ** veIBFF.decimals) + .toFixed(veIBFF.decimals), + }; + } catch (ex) { + console.log(ex); + return null; } }; _getVestingInfoOld = async (web3, account, veIBFF) => { try { - const veIBFFContract = new web3.eth.Contract(abis.veIBFFABI, VEIBFF_ADDRESS); - const lockedInfo = await veIBFFContract.methods.locked(account.address).call(); + const veIBFFContract = new web3.eth.Contract( + abis.veIBFFABI, + VEIBFF_ADDRESS + ); + const lockedInfo = await veIBFFContract.methods + .locked(account.address) + .call(); return { locked: BigNumber(lockedInfo.amount) @@ -1886,14 +2203,16 @@ class Store { .toFixed(veIBFF.decimals), }; } catch (ex) { - console.log(ex); + console.error(ex); return null; } }; _getApprovalAmount = async (web3, asset, owner, spender) => { const erc20Contract = new web3.eth.Contract(abis.erc20ABI, asset.address); - const allowance = await erc20Contract.methods.allowance(owner, spender).call(); + const allowance = await erc20Contract.methods + .allowance(owner, spender) + .call(); return BigNumber(allowance) .div(10 ** asset.decimals) @@ -1901,7 +2220,10 @@ class Store { }; _getFaucetStakedAmount = async (web3, asset, owner) => { - const faucetContract = new web3.eth.Contract(abis.faucetABI, FF_FAUCET_ADDRESS); + const faucetContract = new web3.eth.Contract( + abis.faucetABI, + FF_FAUCET_ADDRESS + ); const balanceOf = await faucetContract.methods.balanceOf(owner).call(); return BigNumber(balanceOf) @@ -1935,12 +2257,24 @@ class Store { _callClaimVestingReward = async (web3, account, gasSpeed, callback) => { try { - const claimContract = new web3.eth.Contract(abis.curveFeeDistributionABI, FF_KP3R_CLAIMABLE_ADDRESS); + const claimContract = new web3.eth.Contract( + abis.curveFeeDistributionABI, + FF_KP3R_CLAIMABLE_ADDRESS + ); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, claimContract, "claim", [], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + claimContract, + "claim", + [], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -1971,12 +2305,24 @@ class Store { _callClaimStakingReward = async (web3, account, gasSpeed, callback) => { try { - const faucetContract = new web3.eth.Contract(abis.faucetABI, FF_FAUCET_ADDRESS); + const faucetContract = new web3.eth.Contract( + abis.faucetABI, + FF_FAUCET_ADDRESS + ); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, faucetContract, "getReward", [], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + faucetContract, + "getReward", + [], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -2007,12 +2353,24 @@ class Store { _callClaimDistributionReward = async (web3, account, gasSpeed, callback) => { try { - const claimContract = new web3.eth.Contract(abis.curveFeeDistributionABI, FF_IBEUR_CLAIMABLE_ADDRESS); + const claimContract = new web3.eth.Contract( + abis.curveFeeDistributionABI, + FF_IBEUR_CLAIMABLE_ADDRESS + ); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, claimContract, "claim", [], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + claimContract, + "claim", + [], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -2043,12 +2401,24 @@ class Store { _callClaimCurveReward = async (web3, account, asset, gasSpeed, callback) => { try { - const minterContract = new web3.eth.Contract(abis.tokenMinterABI, FF_CURVE_TOKEN_MINTER_ADDRESS); + const minterContract = new web3.eth.Contract( + abis.tokenMinterABI, + FF_CURVE_TOKEN_MINTER_ADDRESS + ); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, minterContract, "mint", [asset.gauge.address], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + minterContract, + "mint", + [asset.gauge.address], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -2068,23 +2438,47 @@ class Store { const { gasSpeed, asset } = payload.content; - this._callClaimCurveKP3RReward(web3, account, asset, gasSpeed, (err, res) => { - if (err) { - return this.emitter.emit(ERROR, err); - } + this._callClaimCurveKP3RReward( + web3, + account, + asset, + gasSpeed, + (err, res) => { + if (err) { + return this.emitter.emit(ERROR, err); + } - return this.emitter.emit(FIXED_FOREX_STAKING_REWARD_CLAIMED, res); - }); + return this.emitter.emit(FIXED_FOREX_STAKING_REWARD_CLAIMED, res); + } + ); }; - _callClaimCurveKP3RReward = async (web3, account, asset, gasSpeed, callback) => { + _callClaimCurveKP3RReward = async ( + web3, + account, + asset, + gasSpeed, + callback + ) => { try { - const gaugeContract = new web3.eth.Contract(abis.gaugeABI, asset.gauge.address); + const gaugeContract = new web3.eth.Contract( + abis.gaugeABI, + asset.gauge.address + ); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, gaugeContract, "claim_rewards", [], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); - } catch (ex) { - console.log(ex); + this._callContractWait( + web3, + gaugeContract, + "claim_rewards", + [], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); + } catch (ex) { + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -2115,12 +2509,24 @@ class Store { _callClaimConvexReward = async (web3, account, asset, gasSpeed, callback) => { try { - const minterContract = new web3.eth.Contract(abis.convexBaseRewardPoolABI, asset.convex.address); + const minterContract = new web3.eth.Contract( + abis.convexBaseRewardPoolABI, + asset.convex.address + ); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, minterContract, "getReward", [], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + minterContract, + "getReward", + [], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -2151,7 +2557,10 @@ class Store { _callDepositFaucet = async (web3, account, amount, gasSpeed, callback) => { try { - let faucetContract = new web3.eth.Contract(abis.faucetABI, FF_FAUCET_ADDRESS); + let faucetContract = new web3.eth.Contract( + abis.faucetABI, + FF_FAUCET_ADDRESS + ); const sendAmount = BigNumber(amount === "" ? 0 : amount) .times(10 ** 18) @@ -2159,9 +2568,18 @@ class Store { const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, faucetContract, "deposit", [sendAmount], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + faucetContract, + "deposit", + [sendAmount], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -2191,9 +2609,21 @@ class Store { }; _callApproveStakeSLP = async (web3, account, gasSpeed, callback) => { - const slpContract = new web3.eth.Contract(abis.sushiLPABI, IBEUR_ETH_ADDRESS); + const slpContract = new web3.eth.Contract( + abis.sushiLPABI, + IBEUR_ETH_ADDRESS + ); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, slpContract, "approve", [FF_FAUCET_ADDRESS, MAX_UINT256], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + slpContract, + "approve", + [FF_FAUCET_ADDRESS, MAX_UINT256], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); }; unstakeSLP = async (payload) => { @@ -2222,7 +2652,10 @@ class Store { _callWithdrawFaucet = async (web3, account, amount, gasSpeed, callback) => { try { - let faucetContract = new web3.eth.Contract(abis.faucetABI, FF_FAUCET_ADDRESS); + let faucetContract = new web3.eth.Contract( + abis.faucetABI, + FF_FAUCET_ADDRESS + ); const sendAmount = BigNumber(amount === "" ? 0 : amount) .times(10 ** 18) @@ -2230,9 +2663,18 @@ class Store { const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, faucetContract, "withdraw", [sendAmount], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + faucetContract, + "withdraw", + [sendAmount], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -2252,18 +2694,35 @@ class Store { const { amount, unlockTime, gasSpeed } = payload.content; - this._callCreateLock(web3, account, amount, unlockTime, gasSpeed, (err, res) => { - if (err) { - return this.emitter.emit(ERROR, err); - } + this._callCreateLock( + web3, + account, + amount, + unlockTime, + gasSpeed, + (err, res) => { + if (err) { + return this.emitter.emit(ERROR, err); + } - return this.emitter.emit(FIXED_FOREX_VESTED, res); - }); + return this.emitter.emit(FIXED_FOREX_VESTED, res); + } + ); }; - _callCreateLock = async (web3, account, amount, unlockTime, gasSpeed, callback) => { + _callCreateLock = async ( + web3, + account, + amount, + unlockTime, + gasSpeed, + callback + ) => { try { - let veBIFFContract = new web3.eth.Contract(abis.veIBFFABI, FF_VEKP3R_ADDRESS); + let veBIFFContract = new web3.eth.Contract( + abis.veIBFFABI, + FF_VEKP3R_ADDRESS + ); const sendAmount = BigNumber(amount === "" ? 0 : amount) .times(10 ** 18) @@ -2271,9 +2730,18 @@ class Store { const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, veBIFFContract, "create_lock", [sendAmount, unlockTime], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + veBIFFContract, + "create_lock", + [sendAmount, unlockTime], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -2305,7 +2773,16 @@ class Store { _callApproveVest = async (web3, account, gasSpeed, callback) => { const ibffContract = new web3.eth.Contract(abis.erc20ABI, FF_KP3R_ADDRESS); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, ibffContract, "approve", [FF_VEKP3R_ADDRESS, MAX_UINT256], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + ibffContract, + "approve", + [FF_VEKP3R_ADDRESS, MAX_UINT256], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); }; vestAmount = async (payload) => { @@ -2334,7 +2811,10 @@ class Store { _callIncreaseAmount = async (web3, account, amount, gasSpeed, callback) => { try { - let veBIFFContract = new web3.eth.Contract(abis.veIBFFABI, FF_VEKP3R_ADDRESS); + let veBIFFContract = new web3.eth.Contract( + abis.veIBFFABI, + FF_VEKP3R_ADDRESS + ); const sendAmount = BigNumber(amount === "" ? 0 : amount) .times(10 ** 18) @@ -2342,9 +2822,18 @@ class Store { const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, veBIFFContract, "increase_amount", [sendAmount], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + veBIFFContract, + "increase_amount", + [sendAmount], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -2364,24 +2853,48 @@ class Store { const { unlockTime, gasSpeed } = payload.content; - this._callIncreaseUnlockTime(web3, account, unlockTime, gasSpeed, (err, res) => { - if (err) { - return this.emitter.emit(ERROR, err); - } + this._callIncreaseUnlockTime( + web3, + account, + unlockTime, + gasSpeed, + (err, res) => { + if (err) { + return this.emitter.emit(ERROR, err); + } - return this.emitter.emit(FIXED_FOREX_DURATION_VESTED, res); - }); + return this.emitter.emit(FIXED_FOREX_DURATION_VESTED, res); + } + ); }; - _callIncreaseUnlockTime = async (web3, account, unlockTime, gasSpeed, callback) => { + _callIncreaseUnlockTime = async ( + web3, + account, + unlockTime, + gasSpeed, + callback + ) => { try { - let veBIFFContract = new web3.eth.Contract(abis.veIBFFABI, FF_VEKP3R_ADDRESS); + let veBIFFContract = new web3.eth.Contract( + abis.veIBFFABI, + FF_VEKP3R_ADDRESS + ); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, veBIFFContract, "increase_unlock_time", [unlockTime], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + veBIFFContract, + "increase_unlock_time", + [unlockTime], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -2412,12 +2925,24 @@ class Store { _callWithdrawLock = async (web3, account, gasSpeed, callback) => { try { - let veBIFFContract = new web3.eth.Contract(abis.veIBFFABI, FF_VEKP3R_ADDRESS); + let veBIFFContract = new web3.eth.Contract( + abis.veIBFFABI, + FF_VEKP3R_ADDRESS + ); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, veBIFFContract, "withdraw", [], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + veBIFFContract, + "withdraw", + [], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -2448,7 +2973,10 @@ class Store { _callVote = async (web3, account, votes, gasSpeed, callback) => { try { - let gaugeProxyContract = new web3.eth.Contract(abis.gaugeProxyABI, GAUGE_PROXY_ADDRESS); + let gaugeProxyContract = new web3.eth.Contract( + abis.gaugeProxyABI, + GAUGE_PROXY_ADDRESS + ); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); @@ -2463,9 +2991,18 @@ class Store { console.log(tokens); console.log(voteCounts); - this._callContractWait(web3, gaugeProxyContract, "vote", [tokens, voteCounts], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + gaugeProxyContract, + "vote", + [tokens, voteCounts], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -2485,19 +3022,42 @@ class Store { const { asset, coin, gasSpeed } = payload.content; - this._callApproveDepositCurve(web3, account, asset, coin, gasSpeed, (err, res) => { - if (err) { - return this.emitter.emit(ERROR, err); - } + this._callApproveDepositCurve( + web3, + account, + asset, + coin, + gasSpeed, + (err, res) => { + if (err) { + return this.emitter.emit(ERROR, err); + } - return this.emitter.emit(FIXED_FOREX_DEPOSIT_CURVE_APPROVED, res); - }); + return this.emitter.emit(FIXED_FOREX_DEPOSIT_CURVE_APPROVED, res); + } + ); }; - _callApproveDepositCurve = async (web3, account, asset, coin, gasSpeed, callback) => { + _callApproveDepositCurve = async ( + web3, + account, + asset, + coin, + gasSpeed, + callback + ) => { const erc20Contract = new web3.eth.Contract(abis.erc20ABI, coin.address); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, erc20Contract, "approve", [asset.gauge.poolAddress, MAX_UINT256], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + erc20Contract, + "approve", + [asset.gauge.poolAddress, MAX_UINT256], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); }; depositCurve = async (payload) => { @@ -2515,18 +3075,37 @@ class Store { const { asset, amount0, amount1, gasSpeed } = payload.content; - this._callAddLiquidity(web3, account, asset, amount0, amount1, gasSpeed, (err, res) => { - if (err) { - return this.emitter.emit(ERROR, err); - } + this._callAddLiquidity( + web3, + account, + asset, + amount0, + amount1, + gasSpeed, + (err, res) => { + if (err) { + return this.emitter.emit(ERROR, err); + } - return this.emitter.emit(FIXED_FOREX_CURVE_DEPOSITED, res); - }); + return this.emitter.emit(FIXED_FOREX_CURVE_DEPOSITED, res); + } + ); }; - _callAddLiquidity = async (web3, account, asset, amount0, amount1, gasSpeed, callback) => { + _callAddLiquidity = async ( + web3, + account, + asset, + amount0, + amount1, + gasSpeed, + callback + ) => { try { - let poolContract = new web3.eth.Contract(abis.poolABI, asset.gauge.poolAddress); + let poolContract = new web3.eth.Contract( + abis.poolABI, + asset.gauge.poolAddress + ); const sendAmount0 = BigNumber(amount0 === "" ? 0 : amount0) .times(10 ** asset.gauge.coin0.decimals) @@ -2537,20 +3116,25 @@ class Store { .toFixed(0); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - const tokenAmount = await poolContract.methods.calc_token_amount([sendAmount0, sendAmount1], true).call(); + const tokenAmount = await poolContract.methods + .calc_token_amount([sendAmount0, sendAmount1], true) + .call(); this._callContractWait( web3, poolContract, "add_liquidity", - [[sendAmount0, sendAmount1], BigNumber(tokenAmount).times(0.95).toFixed(0)], + [ + [sendAmount0, sendAmount1], + BigNumber(tokenAmount).times(0.95).toFixed(0), + ], account, gasPrice, GET_FIXED_FOREX_BALANCES, - callback, + callback ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -2568,22 +3152,51 @@ class Store { //maybe throw an error } - const { asset, withdrawAmount, withdrawAmount0, withdrawAmount1, gasSpeed } = payload.content; + const { + asset, + withdrawAmount, + withdrawAmount0, + withdrawAmount1, + gasSpeed, + } = payload.content; - this._callRemoveLiquidity(web3, account, asset, withdrawAmount, withdrawAmount0, withdrawAmount1, gasSpeed, (err, res) => { - if (err) { - return this.emitter.emit(ERROR, err); - } + this._callRemoveLiquidity( + web3, + account, + asset, + withdrawAmount, + withdrawAmount0, + withdrawAmount1, + gasSpeed, + (err, res) => { + if (err) { + return this.emitter.emit(ERROR, err); + } - return this.emitter.emit(FIXED_FOREX_CURVE_DEPOSITED, res); - }); + return this.emitter.emit(FIXED_FOREX_CURVE_DEPOSITED, res); + } + ); }; - _callRemoveLiquidity = async (web3, account, asset, withdrawAmount, amount0, amount1, gasSpeed, callback) => { + _callRemoveLiquidity = async ( + web3, + account, + asset, + withdrawAmount, + amount0, + amount1, + gasSpeed, + callback + ) => { try { - let poolContract = new web3.eth.Contract(abis.poolABI, asset.gauge.poolAddress); + let poolContract = new web3.eth.Contract( + abis.poolABI, + asset.gauge.poolAddress + ); - const sendWithdrawAmount = BigNumber(withdrawAmount === "" ? 0 : withdrawAmount) + const sendWithdrawAmount = BigNumber( + withdrawAmount === "" ? 0 : withdrawAmount + ) .times(10 ** 18) // TODO get decimals from coins .toFixed(0); @@ -2607,10 +3220,10 @@ class Store { account, gasPrice, GET_FIXED_FOREX_BALANCES, - callback, + callback ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -2638,10 +3251,15 @@ class Store { .times(10 ** asset.gauge.coin1.decimals) .toFixed(0); - const poolContract = new web3.eth.Contract(abis.poolABI, asset.gauge.poolAddress); + const poolContract = new web3.eth.Contract( + abis.poolABI, + asset.gauge.poolAddress + ); const [receiveAmount, virtualPrice] = await Promise.all([ - poolContract.methods.calc_token_amount([sendAmount0, sendAmount1], true).call(), + poolContract.methods + .calc_token_amount([sendAmount0, sendAmount1], true) + .call(), poolContract.methods.get_virtual_price().call(), ]); @@ -2658,7 +3276,10 @@ class Store { slippage = virtualValue / realValue - 1; } - this.emitter.emit(FIXED_FOREX_SLIPPAGE_INFO_RETURNED, typeof slippage !== "undefined" ? slippage * 100 : slippage); + this.emitter.emit( + FIXED_FOREX_SLIPPAGE_INFO_RETURNED, + typeof slippage !== "undefined" ? slippage * 100 : slippage + ); }; approveStakeCurve = async (payload) => { @@ -2686,9 +3307,21 @@ class Store { }; _callApproveStakeCurve = async (web3, account, asset, gasSpeed, callback) => { - const erc20Contract = new web3.eth.Contract(abis.erc20ABI, asset.gauge.poolAddress); + const erc20Contract = new web3.eth.Contract( + abis.erc20ABI, + asset.gauge.poolAddress + ); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, erc20Contract, "approve", [asset.gauge.address, MAX_UINT256], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + erc20Contract, + "approve", + [asset.gauge.address, MAX_UINT256], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); }; stakeCurve = async (payload) => { @@ -2706,18 +3339,35 @@ class Store { const { asset, amount, gasSpeed } = payload.content; - this._callDepositGauge(web3, account, asset, amount, gasSpeed, (err, res) => { - if (err) { - return this.emitter.emit(ERROR, err); - } + this._callDepositGauge( + web3, + account, + asset, + amount, + gasSpeed, + (err, res) => { + if (err) { + return this.emitter.emit(ERROR, err); + } - return this.emitter.emit(FIXED_FOREX_CURVE_STAKED, res); - }); + return this.emitter.emit(FIXED_FOREX_CURVE_STAKED, res); + } + ); }; - _callDepositGauge = async (web3, account, asset, amount, gasSpeed, callback) => { + _callDepositGauge = async ( + web3, + account, + asset, + amount, + gasSpeed, + callback + ) => { try { - let gaugeContract = new web3.eth.Contract(abis.gaugeABI, asset.gauge.address); + let gaugeContract = new web3.eth.Contract( + abis.gaugeABI, + asset.gauge.address + ); const sendAmount = BigNumber(amount === "" ? 0 : amount) .times(10 ** 18) @@ -2725,9 +3375,18 @@ class Store { const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, gaugeContract, "deposit", [sendAmount], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + gaugeContract, + "deposit", + [sendAmount], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -2747,28 +3406,56 @@ class Store { const { asset, withdrawAmount, gasSpeed } = payload.content; - this._callWithdrawGauge(web3, account, asset, withdrawAmount, gasSpeed, (err, res) => { - if (err) { - return this.emitter.emit(ERROR, err); - } + this._callWithdrawGauge( + web3, + account, + asset, + withdrawAmount, + gasSpeed, + (err, res) => { + if (err) { + return this.emitter.emit(ERROR, err); + } - return this.emitter.emit(FIXED_FOREX_CURVE_UNSTAKED, res); - }); + return this.emitter.emit(FIXED_FOREX_CURVE_UNSTAKED, res); + } + ); }; - _callWithdrawGauge = async (web3, account, asset, withdrawAmount, gasSpeed, callback) => { + _callWithdrawGauge = async ( + web3, + account, + asset, + withdrawAmount, + gasSpeed, + callback + ) => { try { - let gaugeContract = new web3.eth.Contract(abis.gaugeABI, asset.gauge.address); + let gaugeContract = new web3.eth.Contract( + abis.gaugeABI, + asset.gauge.address + ); - const sendWithdrawAmount = BigNumber(withdrawAmount === "" ? 0 : withdrawAmount) + const sendWithdrawAmount = BigNumber( + withdrawAmount === "" ? 0 : withdrawAmount + ) .times(10 ** 18) .toFixed(0); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, gaugeContract, "withdraw", [sendWithdrawAmount], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + gaugeContract, + "withdraw", + [sendWithdrawAmount], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -2798,9 +3485,21 @@ class Store { }; _callApproveStakeYearn = async (web3, account, asset, gasSpeed, callback) => { - const erc20Contract = new web3.eth.Contract(abis.erc20ABI, asset.gauge.poolAddress); + const erc20Contract = new web3.eth.Contract( + abis.erc20ABI, + asset.gauge.poolAddress + ); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, erc20Contract, "approve", [asset.yearn.address, MAX_UINT256], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + erc20Contract, + "approve", + [asset.yearn.address, MAX_UINT256], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); }; stakeYearn = async (payload) => { @@ -2818,18 +3517,35 @@ class Store { const { asset, amount, gasSpeed } = payload.content; - this._callDepositYearn(web3, account, asset, amount, gasSpeed, (err, res) => { - if (err) { - return this.emitter.emit(ERROR, err); - } + this._callDepositYearn( + web3, + account, + asset, + amount, + gasSpeed, + (err, res) => { + if (err) { + return this.emitter.emit(ERROR, err); + } - return this.emitter.emit(FIXED_FOREX_YEARN_STAKED, res); - }); + return this.emitter.emit(FIXED_FOREX_YEARN_STAKED, res); + } + ); }; - _callDepositYearn = async (web3, account, asset, amount, gasSpeed, callback) => { + _callDepositYearn = async ( + web3, + account, + asset, + amount, + gasSpeed, + callback + ) => { try { - let gaugeContract = new web3.eth.Contract(abis.yearnVaultABI, asset.yearn.address); + let gaugeContract = new web3.eth.Contract( + abis.yearnVaultABI, + asset.yearn.address + ); const sendAmount = BigNumber(amount === "" ? 0 : amount) .times(10 ** 18) @@ -2837,9 +3553,18 @@ class Store { const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, gaugeContract, "deposit", [sendAmount], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + gaugeContract, + "deposit", + [sendAmount], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -2859,28 +3584,56 @@ class Store { const { asset, withdrawAmount, gasSpeed } = payload.content; - this._callWithdrawYearn(web3, account, asset, withdrawAmount, gasSpeed, (err, res) => { - if (err) { - return this.emitter.emit(ERROR, err); - } + this._callWithdrawYearn( + web3, + account, + asset, + withdrawAmount, + gasSpeed, + (err, res) => { + if (err) { + return this.emitter.emit(ERROR, err); + } - return this.emitter.emit(FIXED_FOREX_YEARN_UNSTAKED, res); - }); + return this.emitter.emit(FIXED_FOREX_YEARN_UNSTAKED, res); + } + ); }; - _callWithdrawYearn = async (web3, account, asset, withdrawAmount, gasSpeed, callback) => { + _callWithdrawYearn = async ( + web3, + account, + asset, + withdrawAmount, + gasSpeed, + callback + ) => { try { - let gaugeContract = new web3.eth.Contract(abis.yearnVaultABI, asset.yearn.address); + let gaugeContract = new web3.eth.Contract( + abis.yearnVaultABI, + asset.yearn.address + ); - const sendWithdrawAmount = BigNumber(withdrawAmount === "" ? 0 : withdrawAmount) + const sendWithdrawAmount = BigNumber( + withdrawAmount === "" ? 0 : withdrawAmount + ) .times(10 ** 18) .toFixed(0); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, gaugeContract, "withdraw", [sendWithdrawAmount], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + gaugeContract, + "withdraw", + [sendWithdrawAmount], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -2909,8 +3662,17 @@ class Store { }); }; - _callApproveStakeConvex = async (web3, account, asset, gasSpeed, callback) => { - const erc20Contract = new web3.eth.Contract(abis.erc20ABI, asset.gauge.poolAddress); + _callApproveStakeConvex = async ( + web3, + account, + asset, + gasSpeed, + callback + ) => { + const erc20Contract = new web3.eth.Contract( + abis.erc20ABI, + asset.gauge.poolAddress + ); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); this._callContractWait( web3, @@ -2920,7 +3682,7 @@ class Store { account, gasPrice, GET_FIXED_FOREX_BALANCES, - callback, + callback ); }; @@ -2939,18 +3701,35 @@ class Store { const { asset, amount, gasSpeed } = payload.content; - this._callDepositGaugeConvex(web3, account, asset, amount, gasSpeed, (err, res) => { - if (err) { - return this.emitter.emit(ERROR, err); - } + this._callDepositGaugeConvex( + web3, + account, + asset, + amount, + gasSpeed, + (err, res) => { + if (err) { + return this.emitter.emit(ERROR, err); + } - return this.emitter.emit(FIXED_FOREX_CURVE_STAKED, res); - }); + return this.emitter.emit(FIXED_FOREX_CURVE_STAKED, res); + } + ); }; - _callDepositGaugeConvex = async (web3, account, asset, amount, gasSpeed, callback) => { + _callDepositGaugeConvex = async ( + web3, + account, + asset, + amount, + gasSpeed, + callback + ) => { try { - let gaugeContract = new web3.eth.Contract(abis.convexBoosterABI, FF_CONVEX_POOL_MANAGEMENT_ADDRESS); + let gaugeContract = new web3.eth.Contract( + abis.convexBoosterABI, + FF_CONVEX_POOL_MANAGEMENT_ADDRESS + ); const sendAmount = BigNumber(amount === "" ? 0 : amount) .times(10 ** 18) @@ -2958,9 +3737,18 @@ class Store { const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, gaugeContract, "deposit", [asset.convex.pid, sendAmount, true], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + gaugeContract, + "deposit", + [asset.convex.pid, sendAmount, true], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -2980,28 +3768,56 @@ class Store { const { asset, withdrawAmount, gasSpeed } = payload.content; - this._callWithdrawGaugeConvex(web3, account, asset, withdrawAmount, gasSpeed, (err, res) => { - if (err) { - return this.emitter.emit(ERROR, err); - } + this._callWithdrawGaugeConvex( + web3, + account, + asset, + withdrawAmount, + gasSpeed, + (err, res) => { + if (err) { + return this.emitter.emit(ERROR, err); + } - return this.emitter.emit(FIXED_FOREX_CURVE_UNSTAKED, res); - }); + return this.emitter.emit(FIXED_FOREX_CURVE_UNSTAKED, res); + } + ); }; - _callWithdrawGaugeConvex = async (web3, account, asset, withdrawAmount, gasSpeed, callback) => { + _callWithdrawGaugeConvex = async ( + web3, + account, + asset, + withdrawAmount, + gasSpeed, + callback + ) => { try { - let gaugeContract = new web3.eth.Contract(abis.convexBaseRewardPoolABI, asset.convex.address); + let gaugeContract = new web3.eth.Contract( + abis.convexBaseRewardPoolABI, + asset.convex.address + ); - const sendWithdrawAmount = BigNumber(withdrawAmount === "" ? 0 : withdrawAmount) + const sendWithdrawAmount = BigNumber( + withdrawAmount === "" ? 0 : withdrawAmount + ) .times(10 ** 18) .toFixed(0); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, gaugeContract, "withdrawAndUnwrap", [sendWithdrawAmount, true], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + gaugeContract, + "withdrawAndUnwrap", + [sendWithdrawAmount, true], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -3039,35 +3855,31 @@ class Store { const { gasSpeed } = payload.content; - if (BigNumber(veIBFFOld.vestingInfo.lockEnds).eq(0) || BigNumber(veIBFFOld.vestingInfo.lockValue).eq(0)) { - return this.emitter.emit(ERROR, "No locked veIBFF or veIBFF lock has expired"); + if ( + BigNumber(veIBFFOld.vestingInfo.lockEnds).eq(0) || + BigNumber(veIBFFOld.vestingInfo.lockValue).eq(0) + ) { + return this.emitter.emit( + ERROR, + "No locked veIBFF or veIBFF lock has expired" + ); } - this._callApproveClaimVeClaim(web3, account, veIBFFOld, gasSpeed, (err, res) => { - if (err) { - return this.emitter.emit(ERROR, err); - } - - //check if a lock has already been created - if (BigNumber(veIBFF.vestingInfo.lockValue).gt(0) && BigNumber(veIBFF.vestingInfo.lockEnds).gt(0)) { - this._callClaimVeClaim(web3, account, gasSpeed, (err, res) => { - if (err) { - return this.emitter.emit(ERROR, err); - } - - return this.emitter.emit(FIXED_FOREX_VECLAIM_CLAIMED, res); - }); - } else { - let lockValue = "1"; - if (BigNumber(ibff.balance).lt(1)) { - lockValue = ibff.balance; + this._callApproveClaimVeClaim( + web3, + account, + veIBFFOld, + gasSpeed, + (err, res) => { + if (err) { + return this.emitter.emit(ERROR, err); } - this._callCreateLock(web3, account, lockValue, veIBFFOld.vestingInfo.lockEnds, gasSpeed, (err, res) => { - if (err) { - return this.emitter.emit(ERROR, err); - } - + //check if a lock has already been created + if ( + BigNumber(veIBFF.vestingInfo.lockValue).gt(0) && + BigNumber(veIBFF.vestingInfo.lockEnds).gt(0) + ) { this._callClaimVeClaim(web3, account, gasSpeed, (err, res) => { if (err) { return this.emitter.emit(ERROR, err); @@ -3075,12 +3887,44 @@ class Store { return this.emitter.emit(FIXED_FOREX_VECLAIM_CLAIMED, res); }); - }); + } else { + let lockValue = "1"; + if (BigNumber(ibff.balance).lt(1)) { + lockValue = ibff.balance; + } + + this._callCreateLock( + web3, + account, + lockValue, + veIBFFOld.vestingInfo.lockEnds, + gasSpeed, + (err, res) => { + if (err) { + return this.emitter.emit(ERROR, err); + } + + this._callClaimVeClaim(web3, account, gasSpeed, (err, res) => { + if (err) { + return this.emitter.emit(ERROR, err); + } + + return this.emitter.emit(FIXED_FOREX_VECLAIM_CLAIMED, res); + }); + } + ); + } } - }); + ); }; - _callApproveClaimVeClaim = async (web3, account, veIBFFOld, gasSpeed, callback) => { + _callApproveClaimVeClaim = async ( + web3, + account, + veIBFFOld, + gasSpeed, + callback + ) => { const kp3rContract = new web3.eth.Contract(abis.erc20ABI, FF_KP3R_ADDRESS); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); @@ -3091,11 +3935,20 @@ class Store { decimals: 18, }, account.address, - FF_VEKP3R_ADDRESS, + FF_VEKP3R_ADDRESS ); if (BigNumber(approvalAmount).lt(veIBFFOld.vestingInfo.lockValue)) { - this._callContractWait(web3, kp3rContract, "approve", [FF_VEKP3R_ADDRESS, MAX_UINT256], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + kp3rContract, + "approve", + [FF_VEKP3R_ADDRESS, MAX_UINT256], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } else { callback(); } @@ -3103,12 +3956,24 @@ class Store { _callClaimVeClaim = async (web3, account, gasSpeed, callback) => { try { - let veClaimContract = new web3.eth.Contract(abis.veClaimABI, FF_VECLAIM_ADDRESS); + let veClaimContract = new web3.eth.Contract( + abis.veClaimABI, + FF_VECLAIM_ADDRESS + ); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, veClaimContract, "claim", [], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + veClaimContract, + "claim", + [], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -3138,39 +4003,58 @@ class Store { }); const claimableFeeClaim = claimable.filter((gauge) => { - return gauge.type === "Fixed Forex" && gauge.description === "Fee Claim"; + return ( + gauge.type === "Fixed Forex" && gauge.description === "Fee Claim" + ); }); const claimableVestingReward = claimable.filter((gauge) => { - return gauge.type === "Fixed Forex" && gauge.description === "Vesting Rewards"; + return ( + gauge.type === "Fixed Forex" && + gauge.description === "Vesting Rewards" + ); }); const claimableRKP3RReward = claimable.filter((gauge) => { - return gauge.type === "Fixed Forex" && gauge.description === "Redeemable KP3R"; + return ( + gauge.type === "Fixed Forex" && + gauge.description === "Redeemable KP3R" + ); }); const promises = []; if (claimableGauges.length > 0) { const r = new Promise((resolve, reject) => { - this._callMintMany(web3, account, claimableGauges, gasSpeed, (err, res) => { - if (err) { - reject(err); + this._callMintMany( + web3, + account, + claimableGauges, + gasSpeed, + (err, res) => { + if (err) { + reject(err); + } + resolve(res); } - resolve(res); - }); + ); }); promises.push(r); } if (claimableFeeClaim.length > 0) { const re = new Promise((resolve, reject) => { - this._callClaimDistributionReward(web3, account, gasSpeed, (err, res) => { - if (err) { - reject(err); + this._callClaimDistributionReward( + web3, + account, + gasSpeed, + (err, res) => { + if (err) { + reject(err); + } + resolve(res); } - resolve(res); - }); + ); }); promises.push(re); } @@ -3204,14 +4088,17 @@ class Store { this.emitter.emit(FIXED_FOREX_ALL_CLAIMED); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; _callMintMany = async (web3, account, gauges, gasSpeed, callback) => { try { - const minterContract = new web3.eth.Contract(abis.tokenMinterABI, FF_CURVE_TOKEN_MINTER_ADDRESS); + const minterContract = new web3.eth.Contract( + abis.tokenMinterABI, + FF_CURVE_TOKEN_MINTER_ADDRESS + ); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); const gaugesArray = gauges.map((gauge) => { @@ -3225,9 +4112,18 @@ class Store { console.log(gaugesArray); - this._callContractWait(web3, minterContract, "mint_many", [gaugesArray], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + minterContract, + "mint_many", + [gaugesArray], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -3258,12 +4154,25 @@ class Store { _callClaimRKP3R = async (web3, account, gasSpeed, callback) => { try { - const claimContract = new web3.eth.Contract(abis.rKP3RABI, FF_RKP3R_ADDRESS); + const claimContract = new web3.eth.Contract( + abis.rKP3RABI, + FF_RKP3R_ADDRESS + ); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, claimContract, "claim", [], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback, true); + this._callContractWait( + web3, + claimContract, + "claim", + [], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback, + true + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -3294,12 +4203,24 @@ class Store { _callRedeemOption = async (web3, account, option, gasSpeed, callback) => { try { - const claimContract = new web3.eth.Contract(abis.rKP3RABI, FF_RKP3R_ADDRESS); + const claimContract = new web3.eth.Contract( + abis.rKP3RABI, + FF_RKP3R_ADDRESS + ); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, claimContract, "redeem", [option.id], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + claimContract, + "redeem", + [option.id], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -3331,7 +4252,16 @@ class Store { _callApproveRedeemOption = async (web3, account, gasSpeed, callback) => { const usdcContract = new web3.eth.Contract(abis.erc20ABI, USDC_ADDRESS); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, usdcContract, "approve", [FF_RKP3R_ADDRESS, MAX_UINT256], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + usdcContract, + "approve", + [FF_RKP3R_ADDRESS, MAX_UINT256], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); }; withdrawOld = async (payload) => { @@ -3358,24 +4288,42 @@ class Store { return this.emitter.emit(FIXED_FOREX_OLD_WITHDRAWN, res); }); } else { - this._callWithdrawFaucet(web3, account, asset.balance, gasSpeed, (err, res) => { - if (err) { - return this.emitter.emit(ERROR, err); - } + this._callWithdrawFaucet( + web3, + account, + asset.balance, + gasSpeed, + (err, res) => { + if (err) { + return this.emitter.emit(ERROR, err); + } - return this.emitter.emit(FIXED_FOREX_OLD_WITHDRAWN, res); - }); + return this.emitter.emit(FIXED_FOREX_OLD_WITHDRAWN, res); + } + ); } }; _callExitGauge = async (web3, account, asset, gasSpeed, callback) => { try { - let gaugeContract = new web3.eth.Contract(abis.oldGaugeABI, asset.address); + let gaugeContract = new web3.eth.Contract( + abis.oldGaugeABI, + asset.address + ); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, gaugeContract, "withdraw", [], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + gaugeContract, + "withdraw", + [], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -3395,18 +4343,33 @@ class Store { const { tokenID, gasSpeed } = payload.content; - this._callApproveDepositUni(web3, account, tokenID, gasSpeed, (err, res) => { - if (err) { - return this.emitter.emit(ERROR, err); - } + this._callApproveDepositUni( + web3, + account, + tokenID, + gasSpeed, + (err, res) => { + if (err) { + return this.emitter.emit(ERROR, err); + } - return this.emitter.emit(FIXED_FOREX_UNI_DEPOSITED, res); - }); + return this.emitter.emit(FIXED_FOREX_UNI_DEPOSITED, res); + } + ); }; - _callApproveDepositUni = async (web3, account, tokenID, gasSpeed, callback) => { + _callApproveDepositUni = async ( + web3, + account, + tokenID, + gasSpeed, + callback + ) => { try { - let uniswapNFTPositionsManagerContract = new web3.eth.Contract(abis.uniswapNFTPositionsManagerABI, FF_UNSIWAP_POSITIONS_MANAGER_ADDRESS); + let uniswapNFTPositionsManagerContract = new web3.eth.Contract( + abis.uniswapNFTPositionsManagerABI, + FF_UNSIWAP_POSITIONS_MANAGER_ADDRESS + ); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); this._callContractWait( @@ -3417,10 +4380,10 @@ class Store { account, gasPrice, GET_FIXED_FOREX_BALANCES, - callback, + callback ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -3451,12 +4414,24 @@ class Store { _callDepositUni = async (web3, account, tokenID, gasSpeed, callback) => { try { - let stakingContract = new web3.eth.Contract(abis.stakingRewardsV3ABI, FF_STAKING_REWARDS_V3_ADDRESS); + let stakingContract = new web3.eth.Contract( + abis.stakingRewardsV3ABI, + FF_STAKING_REWARDS_V3_ADDRESS + ); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, stakingContract, "deposit", [tokenID], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + stakingContract, + "deposit", + [tokenID], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -3487,12 +4462,24 @@ class Store { _callWithdrawUni = async (web3, account, tokenID, gasSpeed, callback) => { try { - let stakingContract = new web3.eth.Contract(abis.stakingRewardsV3ABI, FF_STAKING_REWARDS_V3_ADDRESS); + let stakingContract = new web3.eth.Contract( + abis.stakingRewardsV3ABI, + FF_STAKING_REWARDS_V3_ADDRESS + ); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, stakingContract, "withdraw", [tokenID], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + stakingContract, + "withdraw", + [tokenID], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -3523,12 +4510,24 @@ class Store { _callGetRewards = async (web3, account, tokenID, gasSpeed, callback) => { try { - let stakingContract = new web3.eth.Contract(abis.stakingRewardsV3ABI, FF_STAKING_REWARDS_V3_ADDRESS); + let stakingContract = new web3.eth.Contract( + abis.stakingRewardsV3ABI, + FF_STAKING_REWARDS_V3_ADDRESS + ); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, stakingContract, "getReward", [tokenID], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + stakingContract, + "getReward", + [tokenID], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -3559,12 +4558,24 @@ class Store { _callGetAllRewards = async (web3, account, gasSpeed, callback) => { try { - let stakingContract = new web3.eth.Contract(abis.stakingRewardsV3ABI, FF_STAKING_REWARDS_V3_ADDRESS); + let stakingContract = new web3.eth.Contract( + abis.stakingRewardsV3ABI, + FF_STAKING_REWARDS_V3_ADDRESS + ); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContractWait(web3, stakingContract, "getRewards", [], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + stakingContract, + "getRewards", + [], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; @@ -3579,46 +4590,61 @@ class Store { const { fromAsset, toAsset, amount, gasSpeed } = payload.content; try { - const sendAmount = BigNumber(amount === '' ? 0 : amount) + const sendAmount = BigNumber(amount === "" ? 0 : amount) .times(10 ** 18) .toFixed(0); - let ibAMMContract = null - let quoteRes = null - - if(fromAsset.symbol === 'sUSD' || (fromAsset.symbol === 'ibEUR' && toAsset.symbol === 'sUSD')) { - ibAMMContract = new web3.eth.Contract(abis.ibAMMV2ABI, FF_IBAMM_V2_ADDRESS); - if(fromAsset.symbol === 'sUSD') { - quoteRes = await ibAMMContract.methods.quote_out(sendAmount).call() + let ibAMMContract = null; + let quoteRes = null; + + if ( + fromAsset.symbol === "sUSD" || + (fromAsset.symbol === "ibEUR" && toAsset.symbol === "sUSD") + ) { + ibAMMContract = new web3.eth.Contract( + abis.ibAMMV2ABI, + FF_IBAMM_V2_ADDRESS + ); + if (fromAsset.symbol === "sUSD") { + quoteRes = await ibAMMContract.methods.quote_out(sendAmount).call(); } else { - quoteRes = await ibAMMContract.methods.quote_in(sendAmount).call() + quoteRes = await ibAMMContract.methods.quote_in(sendAmount).call(); } } else { - ibAMMContract = new web3.eth.Contract(abis.ibAMMV3ABI, FF_IBAMM_V3_ADDRESS); - if(fromAsset.symbol === 'DAI') { - quoteRes = await ibAMMContract.methods.buy_quote(toAsset.address, sendAmount).call() + ibAMMContract = new web3.eth.Contract( + abis.ibAMMV3ABI, + FF_IBAMM_V3_ADDRESS + ); + if (fromAsset.symbol === "DAI") { + quoteRes = await ibAMMContract.methods + .buy_quote(toAsset.address, sendAmount) + .call(); } else { - quoteRes = await ibAMMContract.methods.sell_quote(fromAsset.address, sendAmount).call() + quoteRes = await ibAMMContract.methods + .sell_quote(fromAsset.address, sendAmount) + .call(); } } - const returnValue = BigNumber(quoteRes).div(10**toAsset.decimals).toFixed(toAsset.decimals) + const returnValue = BigNumber(quoteRes) + .div(10 ** toAsset.decimals) + .toFixed(toAsset.decimals); const retVal = { toAsset: toAsset, fromAmount: amount, - toAmount: returnValue - } + toAmount: returnValue, + }; return this.emitter.emit(FIXED_FOREX_QUOTE_SWAP_RETURNED, retVal); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } - } + }; approveSwap = async (payload) => { - const account = stores.accountStore.getStore('account'); + const account = stores.accountStore.getStore("account"); if (!account) { return false; //maybe throw an error @@ -3632,29 +4658,55 @@ class Store { const { fromAsset, gasSpeed, toAsset } = payload.content; - this._callApproveSwap(web3, account, fromAsset, toAsset, gasSpeed, (err, res) => { - if (err) { - return this.emitter.emit(ERROR, err); - } + this._callApproveSwap( + web3, + account, + fromAsset, + toAsset, + gasSpeed, + (err, res) => { + if (err) { + return this.emitter.emit(ERROR, err); + } - return this.emitter.emit(FIXED_FOREX_SWAP_APPROVED, res); - }); - } + return this.emitter.emit(FIXED_FOREX_SWAP_APPROVED, res); + } + ); + }; - _callApproveSwap = async (web3, account, asset, toAsset, gasSpeed, callback) => { + _callApproveSwap = async ( + web3, + account, + asset, + toAsset, + gasSpeed, + callback + ) => { const erc20Contract = new web3.eth.Contract(abis.erc20ABI, asset.address); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - let contract = FF_IBAMM_V3_ADDRESS - if(asset.symbol === 'sUSD' || (asset.symbol === 'ibEUR' && toAsset.symbol === 'sUSD')) { - contract = FF_IBAMM_V2_ADDRESS + let contract = FF_IBAMM_V3_ADDRESS; + if ( + asset.symbol === "sUSD" || + (asset.symbol === "ibEUR" && toAsset.symbol === "sUSD") + ) { + contract = FF_IBAMM_V2_ADDRESS; } - this._callContractWait(web3, erc20Contract, 'approve', [contract, MAX_UINT256], account, gasPrice, GET_FIXED_FOREX_BALANCES, callback); + this._callContractWait( + web3, + erc20Contract, + "approve", + [contract, MAX_UINT256], + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback + ); }; - swap = async(payload) => { - const account = stores.accountStore.getStore('account'); + swap = async (payload) => { + const account = stores.accountStore.getStore("account"); if (!account) { return false; //maybe throw an error @@ -3666,61 +4718,112 @@ class Store { //maybe throw an error } - const { fromAsset, toAsset, fromAmount, toAmount, gasSpeed } = payload.content; + const { fromAsset, toAsset, fromAmount, toAmount, gasSpeed } = + payload.content; - this._callSwap(web3, account, fromAsset, toAsset, fromAmount, toAmount, gasSpeed, (err, res) => { - if (err) { - return this.emitter.emit(ERROR, err); - } + this._callSwap( + web3, + account, + fromAsset, + toAsset, + fromAmount, + toAmount, + gasSpeed, + (err, res) => { + if (err) { + return this.emitter.emit(ERROR, err); + } - return this.emitter.emit(FIXED_FOREX_SWAP_RETURNED, res); - }); - } + return this.emitter.emit(FIXED_FOREX_SWAP_RETURNED, res); + } + ); + }; - _callSwap = async (web3, account, fromAsset, toAsset, fromAmount, toAmount, gasSpeed, callback) => { + _callSwap = async ( + web3, + account, + fromAsset, + toAsset, + fromAmount, + toAmount, + gasSpeed, + callback + ) => { try { const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - const sendAmount = BigNumber(fromAmount === '' ? 0 : fromAmount) + const sendAmount = BigNumber(fromAmount === "" ? 0 : fromAmount) .times(10 ** 18) .toFixed(0); - const minOut = BigNumber(toAmount).times(10 ** 18).times(0.97).toFixed(0) - - let ibAMMContract = null - let call = '' - let params = [] + const minOut = BigNumber(toAmount) + .times(10 ** 18) + .times(0.97) + .toFixed(0); - if(fromAsset.symbol === 'sUSD' || (fromAsset.symbol === 'ibEUR' && toAsset.symbol === 'sUSD')) { - ibAMMContract = new web3.eth.Contract(abis.ibAMMV2ABI, FF_IBAMM_V2_ADDRESS); - if(fromAsset.symbol === 'sUSD') { - call = 'swap_out' + let ibAMMContract = null; + let call = ""; + let params = []; + + if ( + fromAsset.symbol === "sUSD" || + (fromAsset.symbol === "ibEUR" && toAsset.symbol === "sUSD") + ) { + ibAMMContract = new web3.eth.Contract( + abis.ibAMMV2ABI, + FF_IBAMM_V2_ADDRESS + ); + if (fromAsset.symbol === "sUSD") { + call = "swap_out"; } else { - call = 'swap_in' + call = "swap_in"; } - params = [sendAmount, minOut] + params = [sendAmount, minOut]; } else { - ibAMMContract = new web3.eth.Contract(abis.ibAMMV3ABI, FF_IBAMM_V3_ADDRESS); - if(fromAsset.symbol === 'DAI') { - call = 'buy' - params = [toAsset.address, sendAmount, minOut] + ibAMMContract = new web3.eth.Contract( + abis.ibAMMV3ABI, + FF_IBAMM_V3_ADDRESS + ); + if (fromAsset.symbol === "DAI") { + call = "buy"; + params = [toAsset.address, sendAmount, minOut]; } else { - call = 'sell' - params = [fromAsset.address, sendAmount, minOut] + call = "sell"; + params = [fromAsset.address, sendAmount, minOut]; } } - console.log(ibAMMContract) - console.log(call) - console.log(params) + console.log(ibAMMContract); + console.log(call); + console.log(params); - this._callContractWait(web3, ibAMMContract, call, params, account, gasPrice, GET_FIXED_FOREX_BALANCES, callback, true); + this._callContractWait( + web3, + ibAMMContract, + call, + params, + account, + gasPrice, + GET_FIXED_FOREX_BALANCES, + callback, + true + ); } catch (ex) { - console.log(ex); + console.error(ex); return this.emitter.emit(ERROR, ex); } }; - _callContractWait = (web3, contract, method, params, account, gasPrice, dispatchEvent, callback, paddGasCost) => { + _callContractWait = ( + web3, + contract, + method, + params, + account, + gasPrice, + dispatchEvent, + callback, + paddGasCost + ) => { //estimate gas const gasCost = contract.methods[method](...params) .estimateGas({ from: account.address }) diff --git a/stores/lendStore.js b/stores/lendStore.js index 5e2a44c..91cefd2 100644 --- a/stores/lendStore.js +++ b/stores/lendStore.js @@ -1,4 +1,4 @@ -import async from 'async'; +import async from "async"; import { MAX_UINT256, COMPTROLLER_ADDRESS, @@ -26,17 +26,14 @@ import { DISABLE_COLLATERAL_LEND, DISABLE_COLLATERAL_LEND_RETURNED, IRON_BANK_REGISTRY_ADAPTER, -} from './constants'; +} from "./constants"; -import * as moment from 'moment'; +import stores from "./"; +import lendJSON from "./configurations/lend"; +import abis from "./abis"; +import { bnDec } from "../utils"; -import stores from './'; -import lendJSON from './configurations/lend'; -import abis from './abis'; -import { bnDec } from '../utils'; - -import BigNumber from 'bignumber.js'; -const fetch = require('node-fetch'); +import BigNumber from "bignumber.js"; class Store { constructor(dispatcher, emitter) { @@ -87,7 +84,7 @@ class Store { default: { } } - }.bind(this), + }.bind(this) ); } @@ -111,20 +108,28 @@ class Store { const blocksPeryear = 2425846; const defaultValues = lendJSON; - const account = await stores.accountStore.getStore('account'); + const account = await stores.accountStore.getStore("account"); if (!account) { return null; } - const IronBankRegistryAdapter = new web3.eth.Contract(abis.ironBankRegistryAdapterABI, IRON_BANK_REGISTRY_ADAPTER); - const adapterPositionOf = await IronBankRegistryAdapter.methods.adapterPositionOf(account.address).call(); + const IronBankRegistryAdapter = new web3.eth.Contract( + abis.ironBankRegistryAdapterABI, + IRON_BANK_REGISTRY_ADAPTER + ); + const adapterPositionOf = await IronBankRegistryAdapter.methods + .adapterPositionOf(account.address) + .call(); this.setStore({ position: adapterPositionOf }); async.map( allMarkets, async (market, callback) => { try { - const marketContract = new web3.eth.Contract(abis.cERC20DelegatorABI, market); + const marketContract = new web3.eth.Contract( + abis.cERC20DelegatorABI, + market + ); //set static values to avoid doing tons more calls. let defaultMarket = defaultValues.filter((val) => { @@ -138,15 +143,15 @@ class Store { } let erc20Contract = null; - let vaultSymbol = ''; + let vaultSymbol = ""; let vaultDecimals = 0; - let vaultName = ''; - let vaultIcon = ''; - let erc20address = ''; - let symbol = ''; + let vaultName = ""; + let vaultIcon = ""; + let erc20address = ""; + let symbol = ""; let decimals = 0; - let name = ''; - let icon = ''; + let name = ""; + let icon = ""; if (defaultMarket !== null) { vaultSymbol = defaultMarket.symbol; @@ -160,29 +165,31 @@ class Store { name = defaultMarket.tokenMetadata.displayName; icon = defaultMarket.tokenMetadata.icon; } else { - let localCalls1 = await Promise.all([ marketContract.methods.decimals().call(), marketContract.methods.symbol().call(), marketContract.methods.name().call(), - marketContract.methods.underlying().call() + marketContract.methods.underlying().call(), ]); - erc20Contract = new web3.eth.Contract(abis.erc20ABI, localCalls1[3]); + erc20Contract = new web3.eth.Contract( + abis.erc20ABI, + localCalls1[3] + ); let localCalls2 = await Promise.all([ erc20Contract.methods.symbol().call(), erc20Contract.methods.decimals().call(), - erc20Contract.methods.name().call() + erc20Contract.methods.name().call(), ]); - vaultDecimals = localCalls1[0] - vaultSymbol = localCalls1[1] - vaultName = localCalls1[2] - erc20address = localCalls1[3] - symbol = localCalls2[0] - decimals = parseInt(localCalls2[1]) - name = localCalls2[2] + vaultDecimals = localCalls1[0]; + vaultSymbol = localCalls1[1]; + vaultName = localCalls1[2]; + erc20address = localCalls1[3]; + symbol = localCalls2[0]; + decimals = parseInt(localCalls2[1]); + name = localCalls2[2]; vaultIcon = `https://raw.githubusercontent.com/yearn/yearn-assets/master/icons/multichain-tokens/1/${erc20address}/logo-128.png`; icon = `https://raw.githubusercontent.com/yearn/yearn-assets/master/icons/multichain-tokens/1/${erc20address}/logo-128.png`; } @@ -209,8 +216,7 @@ class Store { return lendingAsset; } } catch (ex) { - console.log(ex); - console.log(market); + console.log(ex, market); if (callback) { callback(ex); @@ -233,16 +239,19 @@ class Store { this.emitter.emit(LENDING_CONFIGURED); this.dispatcher.dispatch({ type: GET_LENDING_BALANCES }); - }, + } ); }; _getAllMarkets = async (web3) => { try { - const comptrollerContract = new web3.eth.Contract(abis.comptrollerABI, COMPTROLLER_ADDRESS); + const comptrollerContract = new web3.eth.Contract( + abis.comptrollerABI, + COMPTROLLER_ADDRESS + ); let allMarkets = await comptrollerContract.methods.getAllMarkets().call(); let newMarkets = allMarkets.filter((market) => { - return market !== '0x4e3a36A633f63aee0aB57b5054EC78867CB3C0b8'; + return market !== "0x4e3a36A633f63aee0aB57b5054EC78867CB3C0b8"; }); return newMarkets; } catch (ex) { @@ -253,8 +262,13 @@ class Store { _getAssetsIn = async (web3, account) => { try { - const comptrollerContract = new web3.eth.Contract(abis.comptrollerABI, COMPTROLLER_ADDRESS); - const assetsIn = await comptrollerContract.methods.getAssetsIn(account.address).call(); + const comptrollerContract = new web3.eth.Contract( + abis.comptrollerABI, + COMPTROLLER_ADDRESS + ); + const assetsIn = await comptrollerContract.methods + .getAssetsIn(account.address) + .call(); return assetsIn; } catch (ex) { console.log(ex); @@ -263,12 +277,12 @@ class Store { }; getLendingBalances = async (payload) => { - const lendingAssets = this.getStore('lendingAssets'); + const lendingAssets = this.getStore("lendingAssets"); if (!lendingAssets) { return null; } - const account = stores.accountStore.getStore('account'); + const account = stores.accountStore.getStore("account"); const web3 = await stores.accountStore.getWeb3Provider(); if (!web3) { @@ -281,16 +295,32 @@ class Store { } const blocksPeryear = 2102400; - const creamPriceOracleContract = new web3.eth.Contract(abis.creamPriceOracleABI, CREAM_PRICE_ORACLE_ADDRESS); - const comptrollerContract = new web3.eth.Contract(abis.comptrollerABI, COMPTROLLER_ADDRESS); + const creamPriceOracleContract = new web3.eth.Contract( + abis.creamPriceOracleABI, + CREAM_PRICE_ORACLE_ADDRESS + ); + const comptrollerContract = new web3.eth.Contract( + abis.comptrollerABI, + COMPTROLLER_ADDRESS + ); async.map( lendingAssets, async (asset, callback) => { // console.log(asset) try { - const marketContract = new web3.eth.Contract(abis.cERC20DelegatorABI, asset.address); - - let [mar, exchangeRate, cash, borrowRatePerBlock, supplyRatePerBlock, totalBorrows] = await Promise.all([ + const marketContract = new web3.eth.Contract( + abis.cERC20DelegatorABI, + asset.address + ); + + let [ + mar, + exchangeRate, + cash, + borrowRatePerBlock, + supplyRatePerBlock, + totalBorrows, + ] = await Promise.all([ comptrollerContract.methods.markets(asset.address).call(), marketContract.methods.exchangeRateStored().call(), marketContract.methods.getCash().call(), @@ -299,30 +329,61 @@ class Store { marketContract.methods.totalBorrows().call(), ]); - const exchangeRateReal = BigNumber(exchangeRate).div(bnDec(asset.tokenMetadata.decimals)).toFixed(asset.tokenMetadata.decimals, BigNumber.ROUND_DOWN); - cash = new BigNumber(cash).div(bnDec(asset.tokenMetadata.decimals)).toFixed(asset.tokenMetadata.decimals, BigNumber.ROUND_DOWN); + const exchangeRateReal = BigNumber(exchangeRate) + .div(bnDec(asset.tokenMetadata.decimals)) + .toFixed(asset.tokenMetadata.decimals, BigNumber.ROUND_DOWN); + cash = new BigNumber(cash) + .div(bnDec(asset.tokenMetadata.decimals)) + .toFixed(asset.tokenMetadata.decimals, BigNumber.ROUND_DOWN); - const borrowRatePerYear = (((1+(borrowRatePerBlock/1e18)) ** blocksPeryear)-1)*100 - const supplyRatePerYear = (((1+(supplyRatePerBlock/1e18)) ** blocksPeryear)-1)*100 + const borrowRatePerYear = + ((1 + borrowRatePerBlock / 1e18) ** blocksPeryear - 1) * 100; + const supplyRatePerYear = + ((1 + supplyRatePerBlock / 1e18) ** blocksPeryear - 1) * 100; - totalBorrows = new BigNumber(totalBorrows).div(bnDec(asset.tokenMetadata.decimals)).toFixed(asset.tokenMetadata.decimals, BigNumber.ROUND_DOWN); + totalBorrows = new BigNumber(totalBorrows) + .div(bnDec(asset.tokenMetadata.decimals)) + .toFixed(asset.tokenMetadata.decimals, BigNumber.ROUND_DOWN); if (account && account.address) { - const erc20Contract = new web3.eth.Contract(abis.erc20ABI, asset.tokenMetadata.address); - - let [balance, allowance, supplyBalance, borrowBalance, dollarPerAsset] = await Promise.all([ + const erc20Contract = new web3.eth.Contract( + abis.erc20ABI, + asset.tokenMetadata.address + ); + + let [ + balance, + allowance, + supplyBalance, + borrowBalance, + dollarPerAsset, + ] = await Promise.all([ erc20Contract.methods.balanceOf(account.address).call(), - erc20Contract.methods.allowance(account.address, asset.address).call(), + erc20Contract.methods + .allowance(account.address, asset.address) + .call(), marketContract.methods.balanceOf(account.address).call(), - marketContract.methods.borrowBalanceStored(account.address).call(), - creamPriceOracleContract.methods.getUnderlyingPrice(asset.address).call(), + marketContract.methods + .borrowBalanceStored(account.address) + .call(), + creamPriceOracleContract.methods + .getUnderlyingPrice(asset.address) + .call(), marketContract.methods.totalBorrows().call(), ]); - balance = new BigNumber(balance).div(bnDec(asset.tokenMetadata.decimals)).toFixed(asset.tokenMetadata.decimals, BigNumber.ROUND_DOWN); - supplyBalance = new BigNumber(supplyBalance).times(exchangeRateReal).div(bnDec(18)).toFixed(asset.tokenMetadata.decimals, BigNumber.ROUND_DOWN); - borrowBalance = new BigNumber(borrowBalance).div(bnDec(asset.tokenMetadata.decimals)).toFixed(asset.tokenMetadata.decimals, BigNumber.ROUND_DOWN); - const dollarPerAssetReal = dollarPerAsset / 10 ** (36 - asset.tokenMetadata.decimals); + balance = new BigNumber(balance) + .div(bnDec(asset.tokenMetadata.decimals)) + .toFixed(asset.tokenMetadata.decimals, BigNumber.ROUND_DOWN); + supplyBalance = new BigNumber(supplyBalance) + .times(exchangeRateReal) + .div(bnDec(18)) + .toFixed(asset.tokenMetadata.decimals, BigNumber.ROUND_DOWN); + borrowBalance = new BigNumber(borrowBalance) + .div(bnDec(asset.tokenMetadata.decimals)) + .toFixed(asset.tokenMetadata.decimals, BigNumber.ROUND_DOWN); + const dollarPerAssetReal = + dollarPerAsset / 10 ** (36 - asset.tokenMetadata.decimals); asset.tokenMetadata.allowance = BigNumber(allowance) .div(bnDec(asset.tokenMetadata.decimals)) @@ -342,7 +403,9 @@ class Store { asset.totalBorrows = totalBorrows; asset.liquidity = cash; - asset.collateralPercent = BigNumber(mar.collateralFactorMantissa).div(10**16).toNumber(); + asset.collateralPercent = BigNumber(mar.collateralFactorMantissa) + .div(10 ** 16) + .toNumber(); asset.supplyAPY = supplyRatePerYear; asset.borrowAPY = borrowRatePerYear; @@ -355,8 +418,7 @@ class Store { return asset; } } catch (ex) { - console.log(asset); - console.log(ex); + console.error(ex, asset); if (callback) { callback(null, asset); @@ -371,31 +433,60 @@ class Store { } const lendingSupply = populatedLendingAssets.reduce((val, market) => { - return BigNumber(val).plus(market.supplyBalanceDolar).toNumber(); - }, 0); - - const lendingSupplyAPY = populatedLendingAssets.reduce((val, market) => { - const vvvv = BigNumber(market.supplyBalanceDolar).div(lendingSupply).times(market.supplyAPY).toNumber(); - return BigNumber(vvvv).plus(val).toNumber(); - }, 0); - - const lendingBorrowLimit = populatedLendingAssets.reduce((val, market) => { return BigNumber(val) - .plus(market.collateralEnabled ? BigNumber(market.supplyBalanceDolar).times(market.collateralPercent).div(100) : 0) + .plus(market?.supplyBalanceDolar || 0) .toNumber(); }, 0); + const lendingSupplyAPY = populatedLendingAssets.reduce( + (val, market) => { + const vvvv = BigNumber(market?.supplyBalanceDolar || 0) + .div(lendingSupply) + .times(market?.supplyAPY || 0) + .toNumber(); + return BigNumber(vvvv).plus(val).toNumber(); + }, + 0 + ); + + const lendingBorrowLimit = populatedLendingAssets.reduce( + (val, market) => { + return BigNumber(val) + .plus( + market?.collateralEnabled + ? BigNumber(market?.supplyBalanceDolar || 0) + .times(market?.collateralPercent || 0) + .div(100) + : 0 + ) + .toNumber(); + }, + 0 + ); + const lendingBorrow = populatedLendingAssets.reduce((val, market) => { - return BigNumber(val).plus(market.borrowBalanceDolar).toNumber(); + return BigNumber(val) + .plus(market?.borrowBalanceDolar || 0) + .toNumber(); }, 0); - const lendingBorrowAPY = populatedLendingAssets.reduce((val, market) => { - const vvvv = BigNumber(market.borrowBalanceDolar).div(lendingBorrow).times(market.borrowAPY).toNumber(); - return BigNumber(vvvv).plus(val).toNumber(); - }, 0); + const lendingBorrowAPY = populatedLendingAssets.reduce( + (val, market) => { + const vvvv = BigNumber(market?.borrowBalanceDolar || 0) + .div(lendingBorrow) + .times(market?.borrowAPY || 0) + .toNumber(); + return BigNumber(vvvv).plus(val).toNumber(); + }, + 0 + ); const ironBankTVL = populatedLendingAssets.reduce((val, market) => { - const vvvv = BigNumber(BigNumber(market.liquidity).plus(market.totalBorrows)).times(market.price).toNumber(); + const vvvv = BigNumber( + BigNumber(market?.liquidity || 0).plus(market?.totalBorrows || 0) + ) + .times(market?.price || 0) + .toNumber(); return BigNumber(vvvv).plus(val).toNumber(); }, 0); @@ -411,12 +502,12 @@ class Store { this.emitter.emit(LEND_UPDATED); return this.emitter.emit(LENDING_BALANCES_RETURNED); - }, + } ); }; approveLend = async (payload) => { - const account = stores.accountStore.getStore('account'); + const account = stores.accountStore.getStore("account"); if (!account) { return false; //maybe throw an error @@ -430,20 +521,37 @@ class Store { const { lendingAsset, amount, gasSpeed } = payload.content; - this._callApproveLend(web3, lendingAsset, account, amount, gasSpeed, (err, approveResult) => { - if (err) { - return this.emitter.emit(ERROR, err); - } + this._callApproveLend( + web3, + lendingAsset, + account, + amount, + gasSpeed, + (err, approveResult) => { + if (err) { + return this.emitter.emit(ERROR, err); + } - return this.emitter.emit(APPROVE_LEND_RETURNED, approveResult); - }); + return this.emitter.emit(APPROVE_LEND_RETURNED, approveResult); + } + ); }; - _callApproveLend = async (web3, lendingAsset, account, amount, gasSpeed, callback) => { - const tokenContract = new web3.eth.Contract(abis.erc20ABI, lendingAsset.tokenMetadata.address); + _callApproveLend = async ( + web3, + lendingAsset, + account, + amount, + gasSpeed, + callback + ) => { + const tokenContract = new web3.eth.Contract( + abis.erc20ABI, + lendingAsset.tokenMetadata.address + ); - let amountToSend = '0'; - if (amount === 'max') { + let amountToSend = "0"; + if (amount === "max") { amountToSend = MAX_UINT256; } else { amountToSend = BigNumber(amount) @@ -453,11 +561,20 @@ class Store { const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContract(web3, tokenContract, 'approve', [lendingAsset.address, amountToSend], account, gasPrice, GET_LENDING_BALANCES, callback); + this._callContract( + web3, + tokenContract, + "approve", + [lendingAsset.address, amountToSend], + account, + gasPrice, + GET_LENDING_BALANCES, + callback + ); }; depositLend = async (payload) => { - const account = stores.accountStore.getStore('account'); + const account = stores.accountStore.getStore("account"); if (!account) { return false; //maybe throw an error @@ -471,26 +588,54 @@ class Store { const { lendingAsset, amount, gasSpeed } = payload.content; - this._callDepositLend(web3, lendingAsset, account, amount, gasSpeed, (err, depositResult) => { - if (err) { - return this.emitter.emit(ERROR, err); - } + this._callDepositLend( + web3, + lendingAsset, + account, + amount, + gasSpeed, + (err, depositResult) => { + if (err) { + return this.emitter.emit(ERROR, err); + } - return this.emitter.emit(DEPOSIT_LEND_RETURNED, depositResult); - }); + return this.emitter.emit(DEPOSIT_LEND_RETURNED, depositResult); + } + ); }; - _callDepositLend = async (web3, lendingAsset, account, amount, gasSpeed, callback) => { - const lendingContract = new web3.eth.Contract(abis.cERC20DelegatorABI, lendingAsset.address); + _callDepositLend = async ( + web3, + lendingAsset, + account, + amount, + gasSpeed, + callback + ) => { + const lendingContract = new web3.eth.Contract( + abis.cERC20DelegatorABI, + lendingAsset.address + ); - const amountToSend = BigNumber(amount).times(bnDec(lendingAsset.tokenMetadata.decimals)).toFixed(0); + const amountToSend = BigNumber(amount) + .times(bnDec(lendingAsset.tokenMetadata.decimals)) + .toFixed(0); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContract(web3, lendingContract, 'mint', [amountToSend], account, gasPrice, GET_LENDING_BALANCES, callback); + this._callContract( + web3, + lendingContract, + "mint", + [amountToSend], + account, + gasPrice, + GET_LENDING_BALANCES, + callback + ); }; withdrawLend = async (payload) => { - const account = stores.accountStore.getStore('account'); + const account = stores.accountStore.getStore("account"); if (!account) { return false; //maybe throw an error @@ -504,26 +649,54 @@ class Store { const { lendingAsset, amount, gasSpeed } = payload.content; - this._callWithdrawLend(web3, lendingAsset, account, amount, gasSpeed, (err, depositResult) => { - if (err) { - return this.emitter.emit(ERROR, err); - } + this._callWithdrawLend( + web3, + lendingAsset, + account, + amount, + gasSpeed, + (err, depositResult) => { + if (err) { + return this.emitter.emit(ERROR, err); + } - return this.emitter.emit(WITHDRAW_LEND_RETURNED, depositResult); - }); + return this.emitter.emit(WITHDRAW_LEND_RETURNED, depositResult); + } + ); }; - _callWithdrawLend = async (web3, lendingAsset, account, amount, gasSpeed, callback) => { - const lendingContract = new web3.eth.Contract(abis.cERC20DelegatorABI, lendingAsset.address); + _callWithdrawLend = async ( + web3, + lendingAsset, + account, + amount, + gasSpeed, + callback + ) => { + const lendingContract = new web3.eth.Contract( + abis.cERC20DelegatorABI, + lendingAsset.address + ); - const amountToSend = BigNumber(amount).times(bnDec(lendingAsset.tokenMetadata.decimals)).toFixed(0); + const amountToSend = BigNumber(amount) + .times(bnDec(lendingAsset.tokenMetadata.decimals)) + .toFixed(0); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContract(web3, lendingContract, 'redeemUnderlying', [amountToSend], account, gasPrice, GET_LENDING_BALANCES, callback); + this._callContract( + web3, + lendingContract, + "redeemUnderlying", + [amountToSend], + account, + gasPrice, + GET_LENDING_BALANCES, + callback + ); }; borrowLend = async (payload) => { - const account = stores.accountStore.getStore('account'); + const account = stores.accountStore.getStore("account"); if (!account) { return false; //maybe throw an error @@ -537,26 +710,54 @@ class Store { const { lendingAsset, amount, gasSpeed } = payload.content; - this._callBorrowLend(web3, lendingAsset, account, amount, gasSpeed, (err, depositResult) => { - if (err) { - return this.emitter.emit(ERROR, err); - } + this._callBorrowLend( + web3, + lendingAsset, + account, + amount, + gasSpeed, + (err, depositResult) => { + if (err) { + return this.emitter.emit(ERROR, err); + } - return this.emitter.emit(BORROW_LEND_RETURNED, depositResult); - }); + return this.emitter.emit(BORROW_LEND_RETURNED, depositResult); + } + ); }; - _callBorrowLend = async (web3, lendingAsset, account, amount, gasSpeed, callback) => { - const lendingContract = new web3.eth.Contract(abis.cERC20DelegatorABI, lendingAsset.address); + _callBorrowLend = async ( + web3, + lendingAsset, + account, + amount, + gasSpeed, + callback + ) => { + const lendingContract = new web3.eth.Contract( + abis.cERC20DelegatorABI, + lendingAsset.address + ); - const amountToSend = BigNumber(amount).times(bnDec(lendingAsset.tokenMetadata.decimals)).toFixed(0); + const amountToSend = BigNumber(amount) + .times(bnDec(lendingAsset.tokenMetadata.decimals)) + .toFixed(0); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContract(web3, lendingContract, 'borrow', [amountToSend], account, gasPrice, GET_LENDING_BALANCES, callback); + this._callContract( + web3, + lendingContract, + "borrow", + [amountToSend], + account, + gasPrice, + GET_LENDING_BALANCES, + callback + ); }; repayLend = async (payload) => { - const account = stores.accountStore.getStore('account'); + const account = stores.accountStore.getStore("account"); if (!account) { return false; //maybe throw an error @@ -570,26 +771,54 @@ class Store { const { lendingAsset, amount, gasSpeed } = payload.content; - this._callRepayLend(web3, lendingAsset, account, amount, gasSpeed, (err, depositResult) => { - if (err) { - return this.emitter.emit(ERROR, err); - } + this._callRepayLend( + web3, + lendingAsset, + account, + amount, + gasSpeed, + (err, depositResult) => { + if (err) { + return this.emitter.emit(ERROR, err); + } - return this.emitter.emit(REPAY_LEND_RETURNED, depositResult); - }); + return this.emitter.emit(REPAY_LEND_RETURNED, depositResult); + } + ); }; - _callRepayLend = async (web3, lendingAsset, account, amount, gasSpeed, callback) => { - const lendingContract = new web3.eth.Contract(abis.cERC20DelegatorABI, lendingAsset.address); + _callRepayLend = async ( + web3, + lendingAsset, + account, + amount, + gasSpeed, + callback + ) => { + const lendingContract = new web3.eth.Contract( + abis.cERC20DelegatorABI, + lendingAsset.address + ); - const amountToSend = BigNumber(amount).times(bnDec(lendingAsset.tokenMetadata.decimals)).toFixed(0); + const amountToSend = BigNumber(amount) + .times(bnDec(lendingAsset.tokenMetadata.decimals)) + .toFixed(0); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContract(web3, lendingContract, 'repayBorrow', [amountToSend], account, gasPrice, GET_LENDING_BALANCES, callback); + this._callContract( + web3, + lendingContract, + "repayBorrow", + [amountToSend], + account, + gasPrice, + GET_LENDING_BALANCES, + callback + ); }; enableCollateralLend = async (payload) => { - const account = stores.accountStore.getStore('account'); + const account = stores.accountStore.getStore("account"); if (!account) { return false; //maybe throw an error @@ -603,24 +832,51 @@ class Store { const { lendingAsset, gasSpeed } = payload.content; - this._callEnableCollateral(web3, lendingAsset, account, gasSpeed, (err, depositResult) => { - if (err) { - return this.emitter.emit(ERROR, err); - } + this._callEnableCollateral( + web3, + lendingAsset, + account, + gasSpeed, + (err, depositResult) => { + if (err) { + return this.emitter.emit(ERROR, err); + } - return this.emitter.emit(ENABLE_COLLATERAL_LEND_RETURNED, depositResult); - }); + return this.emitter.emit( + ENABLE_COLLATERAL_LEND_RETURNED, + depositResult + ); + } + ); }; - _callEnableCollateral = async (web3, lendingAsset, account, gasSpeed, callback) => { - const comptrollerContract = new web3.eth.Contract(abis.comptrollerABI, COMPTROLLER_ADDRESS); + _callEnableCollateral = async ( + web3, + lendingAsset, + account, + gasSpeed, + callback + ) => { + const comptrollerContract = new web3.eth.Contract( + abis.comptrollerABI, + COMPTROLLER_ADDRESS + ); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContract(web3, comptrollerContract, 'enterMarkets', [[lendingAsset.address]], account, gasPrice, GET_LENDING_BALANCES, callback); + this._callContract( + web3, + comptrollerContract, + "enterMarkets", + [[lendingAsset.address]], + account, + gasPrice, + GET_LENDING_BALANCES, + callback + ); }; disableCollateralLend = async (payload) => { - const account = stores.accountStore.getStore('account'); + const account = stores.accountStore.getStore("account"); if (!account) { return false; //maybe throw an error @@ -634,68 +890,103 @@ class Store { const { lendingAsset, gasSpeed } = payload.content; - this._callDIsableCollateral(web3, lendingAsset, account, gasSpeed, (err, depositResult) => { - if (err) { - return this.emitter.emit(ERROR, err); - } + this._callDIsableCollateral( + web3, + lendingAsset, + account, + gasSpeed, + (err, depositResult) => { + if (err) { + return this.emitter.emit(ERROR, err); + } - return this.emitter.emit(DISABLE_COLLATERAL_LEND_RETURNED, depositResult); - }); + return this.emitter.emit( + DISABLE_COLLATERAL_LEND_RETURNED, + depositResult + ); + } + ); }; - _callDIsableCollateral = async (web3, lendingAsset, account, gasSpeed, callback) => { - const comptrollerContract = new web3.eth.Contract(abis.comptrollerABI, COMPTROLLER_ADDRESS); + _callDIsableCollateral = async ( + web3, + lendingAsset, + account, + gasSpeed, + callback + ) => { + const comptrollerContract = new web3.eth.Contract( + abis.comptrollerABI, + COMPTROLLER_ADDRESS + ); const gasPrice = await stores.accountStore.getGasPrice(gasSpeed); - this._callContract(web3, comptrollerContract, 'exitMarket', [lendingAsset.address], account, gasPrice, GET_LENDING_BALANCES, callback); + this._callContract( + web3, + comptrollerContract, + "exitMarket", + [lendingAsset.address], + account, + gasPrice, + GET_LENDING_BALANCES, + callback + ); }; - _callContract = (web3, contract, method, params, account, gasPrice, dispatchEvent, callback) => { - + _callContract = ( + web3, + contract, + method, + params, + account, + gasPrice, + dispatchEvent, + callback + ) => { //estimate gas - const gasCost = contract.methods[method](...params).estimateGas({ from: account.address }) - .then((gasAmount) => { - - const context = this; - contract.methods[method](...params) - .send({ - from: account.address, - // gasPrice: web3.utils.toWei(gasPrice, 'gwei'), - gas: gasAmount, - maxFeePerGas: web3.utils.toWei(gasPrice, 'gwei'), - maxPriorityFeePerGas: web3.utils.toWei('2', 'gwei') - }) - .on('transactionHash', function (hash) { - context.emitter.emit(TX_SUBMITTED, hash); - callback(null, hash); - }) - .on('confirmation', function (confirmationNumber, receipt) { - if (dispatchEvent && confirmationNumber === 1) { - context.dispatcher.dispatch({ type: dispatchEvent }); - } - }) - .on('error', function (error) { - if (!error.toString().includes('-32601')) { - if (error.message) { - return callback(error.message); + const gasCost = contract.methods[method](...params) + .estimateGas({ from: account.address }) + .then((gasAmount) => { + const context = this; + contract.methods[method](...params) + .send({ + from: account.address, + // gasPrice: web3.utils.toWei(gasPrice, 'gwei'), + gas: gasAmount, + maxFeePerGas: web3.utils.toWei(gasPrice, "gwei"), + maxPriorityFeePerGas: web3.utils.toWei("2", "gwei"), + }) + .on("transactionHash", function (hash) { + context.emitter.emit(TX_SUBMITTED, hash); + callback(null, hash); + }) + .on("confirmation", function (confirmationNumber, receipt) { + if (dispatchEvent && confirmationNumber === 1) { + context.dispatcher.dispatch({ type: dispatchEvent }); } - callback(error); - } - }) - .catch((error) => { - if (!error.toString().includes('-32601')) { - if (error.message) { - return callback(error.message); + }) + .on("error", function (error) { + if (!error.toString().includes("-32601")) { + if (error.message) { + return callback(error.message); + } + callback(error); } - callback(error); - } - }); - }) - .catch((ex) => { - console.log(ex) - callback(ex); - }) + }) + .catch((error) => { + if (!error.toString().includes("-32601")) { + if (error.message) { + return callback(error.message); + } + callback(error); + } + }); + }) + .catch((ex) => { + console.log(ex); + callback(ex); + }); }; }