Skip to content

Commit

Permalink
Merge pull request #519 from primitivefinance/develop
Browse files Browse the repository at this point in the history
Unwind V1 Interface
  • Loading branch information
zachdt authored Sep 24, 2021
2 parents fd95b62 + 60dd378 commit 7f4327e
Show file tree
Hide file tree
Showing 11 changed files with 72 additions and 245 deletions.
13 changes: 4 additions & 9 deletions src/components/Layout/Layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,10 @@ const Layout: React.FC<PageProps> = (props) => {
<>
<TopBar loading={props.loading && active} />
<Banner>
<Link href="/reset">
<StyledA>
If you used Primitive between January and March 2021, you must reset
your approvals to prevent loss of funds. Click here to reset them!
</StyledA>
</Link>{' '}
<StyledA>
Primitive V1 is no longer supported by this interface. All deployed
options have expired. Please close your positions.
</StyledA>
</Banner>

<StyledPage>
Expand All @@ -68,9 +66,6 @@ const StyledA = styled.div`
cursor: pointer;
color: ${(props) => props.theme.color.white};
font-size: 14px;
&:hover {
color: ${(props) => props.theme.color.grey[400]};
}
`
interface StyledMainProps {
full?: boolean
Expand Down
4 changes: 2 additions & 2 deletions src/components/Liquidity/LiquidityTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,11 @@ const LiquidityTable: React.FC<OptionsTableProps> = (props) => {
})
.indexOf(true) !== -1

if (
/* if (
+new Date() / 1000 >= option.entity.expiryValue &&
!hasPosition
)
return null
return null */
return (
<LiquidityTableRow
key={option.entity.address}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,9 @@ const LiquidityTableRow: React.FC<LiquidityTableRowProps> = ({

{expiry ? (
<TableCell>
<span>{formatExpiry(expiry).utc.substr(4, 12)}</span>
<span className="expired">
{formatExpiry(expiry).utc.substr(4, 12)}
</span>
</TableCell>
) : (
<TableCell>-</TableCell>
Expand Down Expand Up @@ -405,64 +407,39 @@ const LiquidityTableRow: React.FC<LiquidityTableRowProps> = ({

{toggle && item.entity?.address === key ? (
<OrderTableRow>
<OrderContainer
row
justifyContent="space-between"
alignItems="flex-start"
>
<Choice>
<StyledTitle>
<LineItem
label={'Asset Balance'}
data={numeral(
parseEther(underlyingTokenBalance).gt(
parseUnits('1', 'gwei')
)
? underlyingTokenBalance
: '0'
).format('0.00')}
units={entity.isWethCall ? 'ETH' : asset}
/>
<Spacer />
<AddLiqButton />
</StyledTitle>
{orderType === Operation.ADD_LIQUIDITY ? (
<>
<Spacer size="sm" />
<Separator />
<AddLiquidity />
</>
) : null}
</Choice>

<Spacer />
<Choice>
<StyledTitle>
<LineItem
label={'Liquidity Balance'}
data={numeral(
formatEther(
calculateLiquidityValuePerShare().totalUnderlyingPerLp
)
).format('0.00a')}
units={entity.isWethCall ? 'ETH' : asset}
/>
<Spacer />
<RemoveLiqButton />
</StyledTitle>
{orderType === Operation.REMOVE_LIQUIDITY_CLOSE ? (
<>
<Spacer size="sm" />
<Separator />
<RemoveLiquidity />
</>
) : null}
</Choice>
</OrderContainer>
<Choice>
<StyledTitle>
<LineItem
label={'Liquidity Balance'}
data={numeral(
formatEther(
calculateLiquidityValuePerShare().totalUnderlyingPerLp
)
).format('0.00a')}
units={entity.isWethCall ? 'ETH' : asset}
/>
<Spacer />
<RemoveLiqButton />
</StyledTitle>
{orderType === Operation.REMOVE_LIQUIDITY_CLOSE ? (
<>
<Spacer size="sm" />
<Separator />
<RemoveLiquidity />
</>
) : null}
</Choice>
</OrderTableRow>
) : (
<></>
)}
<style>
{`
.expired {
color: red;
}
`}
</style>
</StyledDiv>
)
}
Expand All @@ -480,7 +457,7 @@ const StyledInnerTitle = styled.div`
`

const Choice = styled.div`
min-width: 33em;
width: 100%;
background-color: ${(props) => props.theme.color.black};
padding: 1em;
border-radius: 0.5em;
Expand All @@ -504,7 +481,7 @@ const StyledTitle = styled.div`
font-weight: 800;
display: flex;
letter-spacing: 0.5px;
width: 30em;
width: 100%;
justify-content: space-between;
`
const StyledDiv = styled.div`
Expand Down
7 changes: 0 additions & 7 deletions src/components/Market/MarketHeader/MarketHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,6 @@ const MarketHeader: React.FC<MarketHeaderProps> = ({ marketId, children }) => {
</StyledTitle>
</LitContainer>
<Spacer size="sm" />
{name === 'Wrapped ETH' ? (
<Banner round>
WETH markets now accept ETH for swaps and liquidity provision.
</Banner>
) : (
<></>
)}
<Reverse />
</StyledHeader>
)
Expand Down
4 changes: 2 additions & 2 deletions src/components/Market/OptionsTable/OptionsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -205,15 +205,15 @@ const OptionsTable: React.FC<OptionsTableProps> = (props) => {
) : (
<ScrollBody>
{options[type].map((option) => {
if (+new Date() / 1000 >= option.entity.expiryValue) return null
//if (+new Date() / 1000 >= option.entity.expiryValue) return null
const allGreeks: Greeks = calculateAllGreeks(option)
const tableColumns: TableColumns = formatTableColumns(option)
return (
<OptionsTableRow
key={option.entity.address}
onClick={() => {
setGreeks(!greeks)
updateItem(option, Operation.LONG)
updateItem(option, Operation.CLOSE_SHORT)
}}
href={`${baseUrl}/${option.entity.address}`}
columns={tableColumns}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,9 @@ const OptionsTableRow: React.FC<OptionsTableRowProps> = ({
)}
{expiry ? (
<TableCell>
<span>{formatExpiry(expiry).utc.substr(4, 12)}</span>
<Expiy>
<span>{formatExpiry(expiry).utc.substr(4, 12)}</span>
</Expiy>
</TableCell>
) : (
<TableCell>-</TableCell>
Expand Down Expand Up @@ -229,6 +231,10 @@ const OptionsTableRow: React.FC<OptionsTableRowProps> = ({
)
}

const Expiy = styled.span`
color: red;
`

const StyledT = styled.span`
border-width: 0 0 1px 0;
border-style: solid;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useCallback } from 'react'
import React, { useState, useCallback, useEffect } from 'react'
import styled from 'styled-components'

import Box from '@/components/Box'
Expand Down Expand Up @@ -256,54 +256,14 @@ const RemoveLiquidity: React.FC = () => {
calculateShortBurn,
])

useEffect(() => {
const liquidity = parseEther(lp).mul(Number(1000)).div(1000)
onOptionInput(liquidity.toString())
}, [lp])

return (
<LiquidityContainer>
<Spacer />
<LineItem
label={'Amount'}
data={Math.round(10 * (ratio / 10)) / 10 + '%'}
units={'%'}
></LineItem>
<Spacer size="sm" />
<Slider
min={1}
max={1000}
step={1}
value={ratio}
onChange={handleRatioChange}
/>
<Spacer size="sm" />
<Box row justifyContent="space-around">
<Button
variant="transparent"
text="25%"
onClick={() => {
handleRatio(250)
}}
/>
<Button
variant="transparent"
text="50%"
onClick={() => {
handleRatio(500)
}}
/>
<Button
variant="transparent"
text="75%"
onClick={() => {
handleRatio(750)
}}
/>
<Button
variant="transparent"
text="100%"
onClick={() => {
handleRatio(1000)
}}
/>
</Box>
<Spacer size="sm" />
<LineItem
label="Burn"
data={`${numeral(formatEther(calculateLPBurn())).format('0.00')}`}
Expand Down Expand Up @@ -400,6 +360,6 @@ const RemoveLiquidity: React.FC = () => {
}

const LiquidityContainer = styled.div`
width: 34em;
width: 100%;
`
export default RemoveLiquidity
Loading

1 comment on commit 7f4327e

@vercel
Copy link

@vercel vercel bot commented on 7f4327e Sep 24, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.