-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* dont calc graph if there are no events * Subgraph: Add arbitrum * TVL Fix * TVL to uni & backlink dayData fields * add token symbol to config * add rewardsClaimedEvents to tenderizer * Subgraph: ID to protocol name in TenderSwap entity * Cleanup old DPY data * fix tokenID comparison * add local subgraph deployment tools * update docker-compose.tml * small changes to work with local hardhat network (#348) * Unstake and Withdraw UI (#343) * start impl * withdraw modal added * change calculations and update the UI a bit * fix bug with graph withdraw * change to using processUnstakes, graph changes, calc fixes * fix date * address pr comments and fix calculation done on the ui * prettier * refresh on tenderbalance change * make time remaining more granular, add unit tests (#351) * make time remaining more granular, add unit tests * remove code duplication * add unit tests to the ci * subgraph: node migration unstake/withdraw Co-authored-by: Reuben Rodrigues <[email protected]> Co-authored-by: kyriediculous <[email protected]>
- Loading branch information
1 parent
03efa0a
commit ac51ba7
Showing
40 changed files
with
3,490 additions
and
565 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module.exports = { | ||
preset: "ts-jest", | ||
transform: { "^.+\\.ts?$": "ts-jest" }, | ||
testEnvironment: "node", | ||
testRegex: "/test/.*\\.(test|spec)?\\.(ts|tsx)$", | ||
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"], | ||
automock: false, | ||
setupFiles: ["./setupJest.js"], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { theme } from "@tender/shared/src"; | ||
import { normalizeColor } from "grommet/utils"; | ||
import styled from "styled-components"; | ||
|
||
const brandColor = normalizeColor("brand", theme); | ||
export const BrandedALink = styled.a` | ||
color: ${brandColor}; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import { FC } from "react"; | ||
import { stakers } from "@tender/shared/src/index"; | ||
import { useIsCorrectChain } from "utils/useEnsureRinkebyConnect"; | ||
import { SwitchNetwork } from "components/account/SwitchNetwork"; | ||
import { ProtocolName } from "@tender/shared/src/data/stakers"; | ||
import { Box } from "grommet"; | ||
import { useEthers } from "@usedapp/core"; | ||
|
||
const ChangeChainWarning: FC<{ protocolName: ProtocolName }> = ({ children, protocolName }) => { | ||
const { account } = useEthers(); | ||
|
||
const requiredChain = stakers[protocolName].chainId; | ||
const isCorrectChain = useIsCorrectChain(requiredChain); | ||
|
||
return ( | ||
<> | ||
{!isCorrectChain && account ? ( | ||
<Box pad={{ vertical: "large" }}> | ||
<SwitchNetwork chainId={requiredChain} protocol={stakers[protocolName].title} /> | ||
</Box> | ||
) : ( | ||
<>{children}</> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default ChangeChainWarning; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
import { FC, MouseEventHandler, useState } from "react"; | ||
import { utils, BigNumberish } from "ethers"; | ||
import { | ||
Button, | ||
Box, | ||
Card, | ||
CardHeader, | ||
CardBody, | ||
CardFooter, | ||
Layer, | ||
Form, | ||
FormField, | ||
Image, | ||
TextInput, | ||
Text, | ||
Heading, | ||
} from "grommet"; | ||
|
||
import { FormClose } from "grommet-icons"; | ||
import { stakers } from "@tender/shared/src/index"; | ||
import { weiToEthWithDecimals } from "utils/amountFormat"; | ||
import { isLargerThanMax, isPositive, useBalanceValidation } from "utils/inputValidation"; | ||
import { AmountInputFooter } from "components/AmountInputFooter"; | ||
import { ProtocolName } from "@tender/shared/src/data/stakers"; | ||
import { useUnstake } from "utils/tenderDepositHooks"; | ||
import { BrandedALink } from "components/BrandedALink"; | ||
|
||
type Props = { | ||
show: boolean; | ||
tenderTokenBalance: BigNumberish; | ||
protocolName: ProtocolName; | ||
onDismiss: () => void; | ||
}; | ||
|
||
const UnstakeModal: FC<Props> = ({ show, tenderTokenBalance, protocolName, onDismiss }) => { | ||
const staker = stakers[protocolName]; | ||
const symbol = staker.symbol; | ||
const bwTenderLogo = `/${staker.bwTenderLogo}`; | ||
|
||
const [unstakeInput, setUnstakeInput] = useState(""); | ||
|
||
const { validationMessage } = useBalanceValidation(unstakeInput, tenderTokenBalance, symbol); | ||
|
||
const maxUnstake = () => { | ||
setUnstakeInput(utils.formatEther(tenderTokenBalance.toString())); | ||
}; | ||
|
||
const handleInputChange = (e: any) => { | ||
const val = e.target.value; | ||
if (val && !val.match(/^(\d+\.?\d*|\.\d+)$/)) return; | ||
setUnstakeInput(val); | ||
}; | ||
|
||
const { unstake } = useUnstake(protocolName); | ||
|
||
const handleUnstake: MouseEventHandler<HTMLElement> = async (e) => { | ||
e.preventDefault(); | ||
await unstake(utils.parseEther(unstakeInput || "0")); | ||
setUnstakeInput(""); | ||
onDismiss(); | ||
}; | ||
|
||
return ( | ||
<> | ||
{show && ( | ||
<Layer style={{ overflow: "auto" }} animation="fadeIn" onEsc={onDismiss} onClickOutside={onDismiss}> | ||
<Card | ||
flex={false} | ||
pad={{ vertical: "medium", horizontal: "xlarge" }} | ||
width="large" | ||
style={{ position: "relative" }} | ||
> | ||
<Button | ||
style={{ position: "absolute", top: 10, right: 10 }} | ||
plain | ||
icon={<FormClose />} | ||
onClick={onDismiss} | ||
/> | ||
<CardHeader justify="center" pad="none"> | ||
<Heading level={2} alignSelf="center"> | ||
{`Unstake t${symbol} for ${symbol}`} | ||
</Heading> | ||
</CardHeader> | ||
<CardBody> | ||
<Box pad={{ top: "medium", horizontal: "large" }} align="center"> | ||
<Form style={{ width: "100%" }}> | ||
<Box gap="medium"> | ||
<FormField label={`Unstake t${symbol}`}> | ||
<TextInput | ||
id="formUnstake" | ||
type="number" | ||
placeholder="0" | ||
value={unstakeInput} | ||
onChange={handleInputChange} | ||
required={true} | ||
style={{ textAlign: "right", padding: "20px 50px" }} | ||
icon={ | ||
<Box pad="xsmall" direction="row" align="center" gap="small"> | ||
<Image height="35" src={bwTenderLogo} /> | ||
<Text>{`t${symbol}`}</Text> | ||
</Box> | ||
} | ||
/> | ||
<Text color="red">{validationMessage}</Text> | ||
<AmountInputFooter | ||
label={`Balance: ${weiToEthWithDecimals(tenderTokenBalance, 6)} t${symbol}`} | ||
onClick={maxUnstake} | ||
/> | ||
</FormField> | ||
|
||
<Box> | ||
<Text> | ||
After unstaking, the tokens will have to go through an unbonding period. The exact withdrawing | ||
date depends on the <BrandedALink href={getWithdrawLink(protocolName)}>underlying</BrandedALink>{" "} | ||
protocol. | ||
</Text> | ||
</Box> | ||
</Box> | ||
</Form> | ||
</Box> | ||
</CardBody> | ||
<CardFooter justify="center" pad={{ vertical: "medium" }}> | ||
<Box style={{ width: "100%" }} pad={{ horizontal: "large" }} justify="center" gap="small"> | ||
<Button | ||
primary | ||
disabled={ | ||
!isPositive(unstakeInput) || | ||
isLargerThanMax(unstakeInput, tenderTokenBalance) || | ||
unstakeInput.toString() === "0" | ||
} | ||
onClick={handleUnstake} | ||
label={"Unstake"} | ||
/> | ||
</Box> | ||
</CardFooter> | ||
</Card> | ||
</Layer> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
export default UnstakeModal; | ||
|
||
const getWithdrawLink = (protocolName: ProtocolName): string => { | ||
switch (protocolName) { | ||
case "audius": | ||
return "https://docs.audius.org/token/staking#staking-on-audius"; | ||
case "graph": | ||
return "https://thegraph.com/docs/en/network/delegating/#the-delegation-tax"; | ||
case "livepeer": | ||
return "https://www.figment.io/resources/livepeer-staking-delegation-guide-2"; | ||
case "matic": | ||
return "https://polygon.technology/staking/"; | ||
} | ||
}; |
Oops, something went wrong.
ac51ba7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
tender-landing – ./packages/landing
www.tenderize.me
tender-landing-git-master-tenderize.vercel.app
tender-landing-tenderize.vercel.app
tenderize.me
tender-landing.vercel.app
ac51ba7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
tender-app – ./packages/app
tender-app-git-master-tenderize.vercel.app
app.tenderize.me
tender-app-tenderize.vercel.app