Skip to content

Commit

Permalink
Merge pull request #27 from OriginProtocol/feat/implement-swap-routes
Browse files Browse the repository at this point in the history
Feat/implement swap routes
  • Loading branch information
toniocodo authored Sep 7, 2023
2 parents b5e6b41 + 51672e4 commit 0badb97
Show file tree
Hide file tree
Showing 270 changed files with 53,218 additions and 5,228 deletions.
4 changes: 3 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
VITE_SUBSQUID_URL="https://squid.subsquid.io/origin-squid/v/v4/graphql"
# VITE_CUSTOM_RPC="https://rpc.tenderly.co/fork/751e79c6-6420-4ea9-ac13-1f6b20f318bc"
# VITE_CUSTOM_RPC="http://127.0.0.1:8545"
VITE_WALLET_CONNECT_PROJECT_ID=
VITE_INFURA_ID=
VITE_ALCHEMY_ID=
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ yarn-error.log
testem.log
/typings

# generated
*-generated.ts

# System Files
.DS_Store
Thumbs.db
Expand Down
30 changes: 20 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
# Origin Defi

## Start any the app
## Setup environment

To start the development server run `nx serve ousd` or `nx serve oeth`. Open your browser and navigate to http://localhost:4200/. Happy coding!
Duplicate `.env` file to `.env.local` and fill the variables with your secrets, they will take precedence over the defaults.

## Start the app

To start the development server run `pnpm nx serve oeth` or `pnpm nx serve ousd`. Open your browser and navigate to http://localhost:4200/. Happy coding!

## Apps

| Status | Name | Nx project | Port | Public hosts |
|:------:|:-----|:-----------|:-----|:-------------|
| 🚧 | OETH | `oeth` | 4200 | [fleek]() |
| 🚧 | OUSD | `ousd` | 4201 | [fleek]() |

## Storybook

There is a shared storybook aggregator that can run all the stories across all the libraries, run
`pnpm storybook`. If you want to run storybook for one individual library (eg: ousd) simply run `pnpm nx storybook defi-ousd` (basically the command is `pnpm nx storybook name-of-the-lib`).
There is a shared storybook aggregator that can run all the stories across all the libraries, run `pnpm storybook`. If you want to run storybook for one individual library (eg: ousd) simply run `pnpm nx storybook defi-ousd` (basically the command is `pnpm nx storybook name-of-the-lib`).

## Translations

Expand All @@ -17,20 +27,20 @@ Basic translation setup was added to the repo. It might require some changes dep

To execute tasks with Nx use the following syntax:

```
nx <target> <project> <...options>
```bash
pnpm nx <target> <project> <...options>
```

You can also run multiple targets:

```
nx run-many -t <target1> <target2>
```bash
pnpm nx run-many -t <target1> <target2>
```

..or add `-p` to filter specific projects

```
nx run-many -t <target1> <target2> -p <proj1> <proj2>
```bash
pnpm nx run-many -t <target1> <target2> -p <proj1> <proj2>
```

Targets can be defined in the `package.json` or `projects.json`. Learn more [in the docs](https://nx.dev/core-features/run-tasks).
2 changes: 1 addition & 1 deletion apps/oeth/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { Container, Stack } from '@mui/material';
import { HistoryView } from '@origin/oeth/history';
import { ApyHeader } from '@origin/oeth/shared';
import { SwapView } from '@origin/oeth/swap';
import { WrapView } from '@origin/oeth/wrap';
import { Route, Routes } from 'react-router-dom';

import { ApyHeader } from './components/ApyHeader';
import { Topnav } from './components/Topnav';

export function App() {
Expand Down
63 changes: 0 additions & 63 deletions apps/oeth/src/clients/wagmi.ts

This file was deleted.

35 changes: 21 additions & 14 deletions apps/oeth/src/components/Topnav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
Link as MuiLink,
Tab,
Tabs,
useMediaQuery,
useTheme,
} from '@mui/material';
import { OpenAccountModalButton } from '@origin/shared/providers';
Expand All @@ -17,6 +18,7 @@ import type { BoxProps } from '@mui/material';

export function Topnav(props: BoxProps) {
const theme = useTheme();
const isSmall = useMediaQuery(theme.breakpoints.down('md'));
const intl = useIntl();
const [value, setValue] = useState(0);

Expand All @@ -25,8 +27,10 @@ export function Topnav(props: BoxProps) {
component="nav"
sx={{
display: 'grid',
borderBlockEnd: { xs: 'none', md: '1px solid' },
borderColor: 'background.paper',
borderBlockEnd: {
xs: 'none',
md: '1px solid var(--mui-palette-background-paper)',
},
gap: { xs: 1, md: 10 },
alignItems: 'center',
backgroundColor: 'divider',
Expand All @@ -42,10 +46,6 @@ export function Topnav(props: BoxProps) {
xs: '1fr 1fr',
md: 'auto 1fr auto',
},
rowGap: {
xs: 1.5,
md: 0,
},
...props?.sx,
}}
>
Expand Down Expand Up @@ -83,6 +83,10 @@ export function Topnav(props: BoxProps) {
xs: 'span 2',
md: 'span 1',
},
marginBlockStart: {
xs: 4,
md: 0,
},
backgroundColor: 'transparent',
minHeight: 0,
overflow: 'visible',
Expand Down Expand Up @@ -146,8 +150,9 @@ export function Topnav(props: BoxProps) {
sx={{
display: 'flex',
justifyContent: 'flex-end',
alignItems: 'stretch',
gap: { xs: 1, md: 2 },
'& > a': {
'& > a, & > *': {
fontSize: {
xs: '0.75rem',
md: '1rem',
Expand All @@ -161,11 +166,8 @@ export function Topnav(props: BoxProps) {
href="https://oeth.on.fleek.co/"
target="_blank"
sx={{
backgroundColor: 'background.paper',
borderRadius: 25,
paddingBlock: 1,
color: 'primary.contrastText',
boxShadow: (theme) => theme.shadows['24'],
paddingBlock: 0.75,
display: 'grid',
placeContent: 'center',
paddingInline: {
Expand All @@ -185,9 +187,12 @@ export function Topnav(props: BoxProps) {
background: (theme) => theme.palette.background.paper,
backgroundImage: 'none',
},
color: 'primary.contrastText',
boxSizing: 'border-box',
lineHeight: '1rem',
}}
>
{theme.breakpoints.down('md')
{isSmall
? intl.formatMessage({ defaultMessage: 'IPFS' })
: intl.formatMessage({ defaultMessage: 'View on IPFS' })}
</MuiLink>
Expand All @@ -198,9 +203,11 @@ export function Topnav(props: BoxProps) {
display: { xs: 'block', md: 'none' },
gridColumn: 'span 2',
gridRowStart: 1,
borderColor: 'background.paper',
borderColor: (theme) => theme.palette.background.paper,
position: 'relative',
bottom: '-4rem',
width: 'calc(100% + 1.5rem)',
bottom: '-3.75rem',
left: '-0.75rem',
}}
/>
</Box>
Expand Down
4 changes: 3 additions & 1 deletion apps/oeth/src/env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

interface ImportMetaEnv {
readonly VITE_WALLET_CONNECT_PROJECT_ID: string;
readonly VITE_INFURA_ID: string;
readonly VITE_ALCHEMY_ID: string;
readonly VITE_SUBSQUID_URL: string;
readonly VITE_CUSTOM_RPC?: string;
}

interface ImportMeta {
Expand Down
14 changes: 13 additions & 1 deletion apps/oeth/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,23 @@ import {
CssBaseline,
Experimental_CssVarsProvider as CssVarsProvider,
} from '@mui/material';
import { chains, queryClient, wagmiConfig } from '@origin/oeth/shared';
import { CurveProvider } from '@origin/shared/providers';
import { theme } from '@origin/shared/theme';
import { composeContexts } from '@origin/shared/utils';
import { darkTheme, RainbowKitProvider } from '@rainbow-me/rainbowkit';
import { QueryClientProvider } from '@tanstack/react-query';
import { setAutoFreeze } from 'immer';
import { IntlProvider } from 'react-intl';
import { BrowserRouter } from 'react-router-dom';
import { WagmiConfig } from 'wagmi';

import { App } from './App';
import { chains, queryClient, wagmiConfig } from './clients';
import { en } from './lang';

// https://github.com/dai-shi/proxy-compare/pull/8
setAutoFreeze(false);

const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement,
);
Expand All @@ -33,6 +38,13 @@ root.render(
[CssVarsProvider, { theme: theme, defaultMode: 'dark' }],
[WagmiConfig, { config: wagmiConfig }],
[RainbowKitProvider, { chains: chains, theme: darkTheme() }],
[
CurveProvider,
{
alchemyApiKey: import.meta.env.VITE_ALCHEMY_ID,
customRpcUrl: import.meta.env.VITE_CUSTOM_RPC,
},
],
],
<>
<CssBaseline />
Expand Down
12 changes: 4 additions & 8 deletions apps/ousd/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@ import {
CssBaseline,
Experimental_CssVarsProvider as CssVarsProvider,
} from '@mui/material';
import { queryClient } from '@origin/shared/data-access';
import { theme } from '@origin/shared/theme';
import { QueryClientProvider } from '@tanstack/react-query';
import { IntlProvider } from 'react-intl';

import { OUSDRoot } from './components';
Expand All @@ -19,12 +17,10 @@ const root = ReactDOM.createRoot(
root.render(
<StrictMode>
<IntlProvider messages={en} locale="en" defaultLocale="en">
<QueryClientProvider client={queryClient}>
<CssVarsProvider theme={theme} defaultMode="dark">
<CssBaseline />
<OUSDRoot />
</CssVarsProvider>
</QueryClientProvider>
<CssVarsProvider theme={theme} defaultMode="dark">
<CssBaseline />
<OUSDRoot />
</CssVarsProvider>
</IntlProvider>
</StrictMode>,
);
6 changes: 3 additions & 3 deletions apps/ousd/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
/// <reference types="vitest" />
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
import viteTsConfigPaths from 'vite-tsconfig-paths';

export default defineConfig({
cacheDir: '../../node_modules/.vite/ousd',

server: {
port: 4200,
port: 4201,
host: 'localhost',
},

preview: {
port: 4300,
port: 4301,
host: 'localhost',
},

Expand Down
8 changes: 5 additions & 3 deletions libs/defi/oeth/src/components/Swap/GasPopover.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ import {
} from '@mui/material';
import { useIntl } from 'react-intl';

import type { Theme } from '@mui/material';
import type { SxProps } from '@mui/material';

const defaultPriceTolerance = 0.01;

const gridStyles = {
display: 'grid',
gridTemplateColumns: (theme: Theme) => `1.5fr 1fr`,
gridTemplateColumns: `1.5fr 1fr`,
gap: 1,
justifyContent: 'space-between',
alignItems: 'center',
Expand All @@ -32,9 +32,10 @@ const gridStyles = {
interface Props {
gasPrice: number;
onPriceToleranceChange: (value: number) => void;
sx?: SxProps;
}

export function GasPopover({ gasPrice, onPriceToleranceChange }: Props) {
export function GasPopover({ gasPrice, onPriceToleranceChange, sx }: Props) {
const theme = useTheme();
const intl = useIntl();
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement | null>(null);
Expand All @@ -48,6 +49,7 @@ export function GasPopover({ gasPrice, onPriceToleranceChange }: Props) {
<IconButton
onClick={(e) => setAnchorEl(e.currentTarget)}
data-testid="gas-popover-button"
sx={{ ...sx }}
>
<img src="/images/settings-icon.svg" />
</IconButton>
Expand Down
Loading

0 comments on commit 0badb97

Please sign in to comment.