Skip to content

Commit

Permalink
Merge pull request #427 from primitivefinance/develop
Browse files Browse the repository at this point in the history
Nightly Build to Production
  • Loading branch information
Alexangelj authored Jan 11, 2021
2 parents f95eed3 + 68cc750 commit 2c4ea1c
Show file tree
Hide file tree
Showing 19 changed files with 346 additions and 101 deletions.
21 changes: 16 additions & 5 deletions src/components/Disclaimer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ const Disclaimer: React.FC = () => {
return (
<Backdrop>
<StyledCard>
<StyledDis>Primitive Security Disclosure</StyledDis>
<StyledDis>Primitive Disclosure</StyledDis>
<Body>
The Primitive Interface is an open source web application. Please use
the Primitive Interface and Primitive Protocol at your own risk.
The Primitive Interface is an open source and free web application.
Please use the Primitive Interface and Primitive Protocol at your own
risk.
</Body>
<Body>
Visit the{' '}
Expand All @@ -30,6 +31,15 @@ const Disclaimer: React.FC = () => {
</StyledLink>{' '}
page for more information.
</Body>
<Body>
Visit the{' '}
<StyledLink href={'/faq'}>
<LinkInt>
FAQ <LaunchIcon style={{ fontSize: '12px' }} />{' '}
</LinkInt>
</StyledLink>{' '}
page for contract specification information.
</Body>
<Button full onClick={handleConfirm}>
I Accept
</Button>
Expand All @@ -40,14 +50,15 @@ const Disclaimer: React.FC = () => {

const LinkInt = styled.span`
text-decoration: none;
&: hover {
&:hover {
color: ${(props) => props.theme.color.grey[400]};
cursor: pointer;
}
`
const StyledLink = styled(Link)``

const Body = styled.h4`
color ${(props) => props.theme.color.grey[400]};
color: ${(props) => props.theme.color.grey[400]};
`
const StyledDis = styled.h3`
color: white;
Expand Down
101 changes: 101 additions & 0 deletions src/components/FaqTable/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
import React from 'react'
import Link from 'next/link'
import styled from 'styled-components'
import {
NAME_FOR_SPECIFICATION,
DESCRIPTION_FOR_SPECIFICATION,
SPECIFICATIONS,
} from '@/constants/specifications'
import { ETHERSCAN_MAINNET } from '@/constants/index'
import { Grid, Col, Row } from 'react-styled-flexboxgrid'
import CheckIcon from '@material-ui/icons/Check'
import LaunchIcon from '@material-ui/icons/Launch'
import WarningIcon from '@material-ui/icons/Warning'

import IconButton from '@/components/IconButton'
import Button from '@/components/Button'
import Tooltip from '@/components/Tooltip'
import Box from '@/components/Box'
import Table from '@/components/Table'
import TableBody from '@/components/TableBody'
import TableCell from '@/components/TableCell'
import TableRow from '@/components/TableRow'
import LitContainer from '@/components/LitContainer'
import Spacer from '@/components/Spacer'

const FaqTable: React.FC = () => {
const headers = [
{
name: 'Contract Specifications',
},
{
name: 'Description',
},
]
return (
<>
<StyledTitle>Smart Contract Specification</StyledTitle>
<Spacer />
<LitContainer>
<StyledTableBody>
<TableRow isHead>
{headers.map((header, index) => {
return <TableCell key={header.name}>{header.name}</TableCell>
})}
</TableRow>
<StyledDiv />
<Spacer size="sm" />
{SPECIFICATIONS.map((specification, i) => {
return (
<>
<TableRow key={i} isHead>
<TableCell>
<StyledSub>{specification.name}</StyledSub>
</TableCell>
<TableCell>
<StyledSub>{specification.description}</StyledSub>
</TableCell>
</TableRow>
<Spacer size="sm" />
</>
)
})}
</StyledTableBody>
<Spacer />
<Spacer />
</LitContainer>
</>
)
}

const StyledDiv = styled.div`
border: 1px solid ${(props) => props.theme.color.grey[600]};
`

const StyledTableBody = styled(TableBody)`
width: 50em;
`
const StyledLink = styled.a`
color: white;
text-decoration: none;
width: 30%;
`
const StyledSub = styled.h4`
color: white;
`
const StyledCol = styled(Col)`
margin: 0.5em;
overflow: visible;
`
const StyledARef = styled.a`
color: ${(props) => props.theme.color.grey[400]};
text-decoration: none;
&:hover {
color: ${(props) => props.theme.color.white};
}
`
const StyledTitle = styled.h2`
color: white;
font-weight: bold;
`
export default FaqTable
11 changes: 9 additions & 2 deletions src/components/Market/FilterBar/FilterBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Label from '@/components/Label'
import ToggleButton from '@/components/ToggleButton'
import Spacer from '@/components/Spacer'
import formatExpiry from '@/utils/formatExpiry'
import { ACTIVE_EXPIRIES } from '@/constants/index'

export interface FilterBarProps {
active: boolean
Expand All @@ -17,7 +18,6 @@ export interface FilterBarProps {

const FilterBar: React.FC<FilterBarProps> = (props) => {
const { active, setCallActive, expiry, setExpiry } = props
const { utc } = formatExpiry(expiry)

const handleToggleClick = useCallback(() => {
setCallActive(!active)
Expand Down Expand Up @@ -45,7 +45,14 @@ const FilterBar: React.FC<FilterBarProps> = (props) => {
<Spacer size="lg" />
<StyledSelectWrapper>
<StyledSelect value={expiry} onChange={handleFilter}>
<StyledOption>Expiring {utc}</StyledOption>
{ACTIVE_EXPIRIES.map((expiryValue, i) => {
return (
<StyledOption key={i} value={expiryValue}>
{expiryValue >= Date.now() / 1000 ? `Expiring` : 'Expired'}{' '}
{formatExpiry(expiryValue).utc}
</StyledOption>
)
})}
</StyledSelect>
</StyledSelectWrapper>
</StyledFilterBarInner>
Expand Down
8 changes: 1 addition & 7 deletions src/components/Market/OptionsTable/OptionsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,7 @@ const OptionsTable: React.FC<OptionsTableProps> = (props) => {
) : (
<ScrollBody>
{options[type].map((option) => {
if (
optionExp != option.entity.expiryValue ||
(chainId === 1
? +option.entity.strikePrice !== 700
: !+option.entity.strikePrice)
)
return null
if (optionExp != option.entity.expiryValue) return null
const allGreeks: Greeks = calculateAllGreeks(option)
const tableColumns: TableColumns = formatTableColumns(option)
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,13 @@ const OptionsTableRow: React.FC<OptionsTableRowProps> = ({
>
<TableCell>
<span>
{numeral(strike).format('0.00a')} <Units>DAI</Units>
{numeral(strike).format('0.00')} <Units>DAI</Units>
</span>
</TableCell>
<TableCell>
{!isZero(parseEther(premium)) ? (
<span>
{numeral(breakeven).format('0.00a')} <Units>DAI</Units>
{numeral(breakeven).format('0.00')} <Units>DAI</Units>
</span>
) : (
<>{`-`}</>
Expand Down
17 changes: 9 additions & 8 deletions src/components/Market/OrderCard/components/Swap/Swap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -271,14 +271,9 @@ const Swap: React.FC = () => {
return formatEtherBalance(entity.proportionalShort(sizeWei))
}, [item, parsedAmount])

const isAboveGuardCap = useCallback(() => {
const inputValue = parsedAmount
return inputValue ? inputValue.gt(guardCap) && chainId === 1 : false
}, [parsedAmount, guardCap])

const isBelowSlippage = useCallback(() => {
return impact !== 'NaN'
? parseFloat(impact) < parseFloat(slippage) * 100
? Math.abs(parseFloat(impact)) < parseFloat(slippage) * 100
: true
}, [impact, slippage])

Expand Down Expand Up @@ -562,7 +557,12 @@ const Swap: React.FC = () => {
)}
{approved[0] && approved[1] ? (
<Button
disabled={!parsedAmount?.gt(0) || error || !hasLiquidity}
disabled={
!parsedAmount?.gt(0) ||
error ||
!hasLiquidity ||
!isBelowSlippage()
}
full
size="sm"
onClick={handleSubmitClick}
Expand Down Expand Up @@ -592,7 +592,8 @@ const Swap: React.FC = () => {
!approved[0] ||
!parsedAmount?.gt(0) ||
error ||
!hasLiquidity
!hasLiquidity ||
!isBelowSlippage()
}
full
size="sm"
Expand Down
4 changes: 3 additions & 1 deletion src/constants/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const ADDRESS_FOR_MARKET: { [key: string]: string } = {
}

export const ACTIVE_FOR_MARKET: { [key: string]: boolean } = {
yfi: false,
yfi: true,
weth: true,
sushi: false,
comp: false,
Expand Down Expand Up @@ -177,6 +177,8 @@ export const DEFAULT_ALLOWANCE = parseEther('10000000')

export const WEI_ADJ = 1000000000000000000

export const ACTIVE_EXPIRIES = [1610107199, 1611907200, 1619769600]

export enum Operation {
MINT,
EXERCISE,
Expand Down
47 changes: 47 additions & 0 deletions src/constants/specifications.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
export interface SpecificationMetaData {
description: string
name: string
id: string
}

export const NAME_FOR_SPECIFICATION: { [key: string]: string } = {
deployer: 'Deployed By',
assets: 'Assets',
strikes: 'Strikes',
expiration: 'Expirations',
exercise: `Exercise Style`,
settlement: `Settlement Value`,
mulitplier: 'Mulitplier',
margin: 'Margin/Collateral',
fees: 'Fees',
voting: 'Voting',
votingPower: 'Voting Power',
}

export const DESCRIPTION_FOR_SPECIFICATION: { [key: string]: string } = {
deployer:
'Anyone can use the Primitive Protocol to deploy option smart contracts.',
assets: 'Underlying / Dai, Dai / Underlying',
strikes: 'Strikes will often be out-of-the-money on deployment.',
expiration: 'Fridays at 8:00:00 UTC.',
exercise: `American options with manual
exercising and physical settlement. Options must be manually exercised, which requires action on behalf of the user before expiry.`,
settlement: 'The underlying tokens',
mulitplier: `There is a 1 multiplier for calls, and a 1 / strikePrice multiplier for puts. `,
margin: `100%. For each 1 call option, 1 underlying token must be provided as collateral. For each 1 put option, 1 Dai must be provided as collateral.`,
fees: `No fees are taken from the Primitive protocol. There is a 0.30% fee per swap for using Uniswap.`,
voting: `New market proposals are submitted on Wednesdays before a series expires on Friday.`,
votingPower: `Voting power is determined by the balance of LP tokens in the series which expires on the closest Friday.`,
}

export const SPECIFICATIONS: SpecificationMetaData[] = Object.keys(
NAME_FOR_SPECIFICATION
).map(
(key): SpecificationMetaData => {
return {
name: NAME_FOR_SPECIFICATION[key],
description: DESCRIPTION_FOR_SPECIFICATION[key],
id: key,
}
}
)
Loading

1 comment on commit 2c4ea1c

@vercel
Copy link

@vercel vercel bot commented on 2c4ea1c Jan 11, 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.