Skip to content

Commit

Permalink
chore(mfi-v2-ui): merge
Browse files Browse the repository at this point in the history
  • Loading branch information
losman0s committed Sep 28, 2023
2 parents ac432e5 + 84031b5 commit d72631a
Show file tree
Hide file tree
Showing 78 changed files with 2,678 additions and 799 deletions.
3 changes: 3 additions & 0 deletions apps/marginfi-v2-ui/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,6 @@ next-env.d.ts

# turbo
.turbo

# Sentry Auth Token
.sentryclirc
57 changes: 47 additions & 10 deletions apps/marginfi-v2-ui/next.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true',
})
const withBundleAnalyzer = require("@next/bundle-analyzer")({
enabled: process.env.ANALYZE === "true",
});

module.exports = withBundleAnalyzer({
/**
Expand All @@ -11,14 +11,10 @@ module.exports = withBundleAnalyzer({
publicRuntimeConfig: {
NODE_ENV: process.env.NODE_ENV,
},
transpilePackages: [
"@mrgnlabs/marginfi-client-v2",
"@mrgnlabs/mrgn-common",
"@mrgnlabs/lip-client",
],
transpilePackages: ["@mrgnlabs/marginfi-client-v2", "@mrgnlabs/mrgn-common", "@mrgnlabs/lip-client"],
reactStrictMode: true,
webpack: (config) => {
config.resolve.fallback = { fs: false, path: false, net: false, tls: false, "child_process": false, request: false };
config.resolve.fallback = { fs: false, path: false, net: false, tls: false, child_process: false, request: false };
return config;
},
images: {
Expand Down Expand Up @@ -53,6 +49,12 @@ module.exports = withBundleAnalyzer({
port: "",
pathname: "/token-metadata/**",
},
{
protocol: "https",
hostname: "storage.googleapis.com",
port: "",
pathname: "/static-marginfi/**",
},
{
protocol: "https",
hostname: "arweave.net",
Expand All @@ -64,7 +66,42 @@ module.exports = withBundleAnalyzer({
hostname: "shdw-drive.genesysgo.net",
port: "",
pathname: "/6tcnBSybPG7piEDShBcrVtYJDPSvGrDbVvXmXKpzBvWP/**",
}
},
],
},
});

const { withSentryConfig } = require("@sentry/nextjs");

module.exports = withSentryConfig(
module.exports,
{
// For all available options, see:
// https://github.com/getsentry/sentry-webpack-plugin#options

// Suppresses source map uploading logs during build
silent: true,

org: "mrgn-labs",
project: "marginfi-v2-ui",
},
{
// For all available options, see:
// https://docs.sentry.io/platforms/javascript/guides/nextjs/manual-setup/

// Upload a larger set of source maps for prettier stack traces (increases build time)
widenClientFileUpload: true,

// Transpiles SDK to be compatible with IE11 (increases bundle size)
transpileClientSDK: true,

// Routes browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers (increases server load)
tunnelRoute: "/monitoring",

// Hides source maps from generated client bundles
hideSourceMaps: true,

// Automatically tree-shake Sentry logger statements to reduce bundle size
disableLogger: true,
}
);
9 changes: 9 additions & 0 deletions apps/marginfi-v2-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@
"lint-fix": "yarn lint --fix"
},
"dependencies": {
"@bonfida/spl-name-service": "^1.1.1",
"@coral-xyz/borsh": "^0.28.0",
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@jup-ag/api": "^6.0.6",
"@jup-ag/react-hook": "^6.0.0-beta.2",
"@mrgnlabs/lip-client": "*",
"@mrgnlabs/marginfi-client-v2": "*",
"@mrgnlabs/marginfi-v2-ui-state": "*",
Expand All @@ -22,7 +25,10 @@
"@mui/material": "^5.11.2",
"@next/bundle-analyzer": "^13.4.19",
"@next/font": "13.1.1",
"@sentry/nextjs": "^7.68.0",
"@socialgouv/matomo-next": "^1.4.0",
"@solana/spl-stake-pool": "^0.6.5",
"@solana/spl-token-registry": "^0.2.4574",
"@solana/wallet-adapter-base": "^0.9.20",
"@solana/wallet-adapter-react": "^0.15.28",
"@solana/wallet-adapter-react-ui": "^0.9.27",
Expand All @@ -34,6 +40,8 @@
"bs58": "^5.0.0",
"firebase": "^9.22.1",
"firebase-admin": "^11.9.0",
"jsbi": "^4.3.0",
"lodash.debounce": "^4.0.8",
"next": "13.4.19",
"react": "18.2.0",
"react-dom": "18.2.0",
Expand All @@ -52,6 +60,7 @@
"devDependencies": {
"@mrgnlabs/eslint-config-custom": "*",
"@mrgnlabs/tsconfig": "*",
"@types/lodash.debounce": "^4.0.7",
"@types/node": "18.11.18",
"@types/numeral": "^2.0.2",
"@types/react": "18.0.26",
Expand Down
Binary file added apps/marginfi-v2-ui/public/blze.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions apps/marginfi-v2-ui/sentry.client.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// This file configures the initialization of Sentry on the client.
// The config you add here will be used whenever a users loads a page in their browser.
// https://docs.sentry.io/platforms/javascript/guides/nextjs/

import * as Sentry from "@sentry/nextjs";
7 changes: 7 additions & 0 deletions apps/marginfi-v2-ui/sentry.edge.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as Sentry from "@sentry/nextjs";

Sentry.init({
dsn: process.env.SENTRY_DSN,
tracesSampleRate: 1,
debug: false,
});
7 changes: 7 additions & 0 deletions apps/marginfi-v2-ui/sentry.server.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import * as Sentry from "@sentry/nextjs";

Sentry.init({
dsn: process.env.SENTRY_DSN,
tracesSampleRate: 1,
debug: false,
});
13 changes: 13 additions & 0 deletions apps/marginfi-v2-ui/src/components/Spinner.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
export const Spinner = () => ( <svg
className="animate-spin ml-1 mr-3 h-5 w-5 text-white"
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
>
<circle width="opacity-10" cx="12" cy="12" r="10" stroke="#aaa" strokeWidth="4"></circle>
<path
width="opacity-100"
fill="#DCE85D"
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
></path>
</svg>)
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
import { styled, Switch, SwitchProps } from "@mui/material";
import { Dispatch, SetStateAction } from "react";

interface LstDepositToggleProps extends SwitchProps {
checked: boolean;
setChecked: Dispatch<SetStateAction<boolean>>;
}

const LstDepositToggle = styled(({ checked, setChecked, ...switchProps }: LstDepositToggleProps) => {
const handleChange = () => {
setChecked((prev) => !prev);
};

return (
<Switch
{...switchProps}
focusVisibleClassName=".Mui-focusVisible"
disableRipple
checked={!checked}
onChange={handleChange}
disabled={false}
/>
);
})(({ disabled }) => ({
width: "100%",
height: "100%",
...(disabled ? { cursor: "not-allowed" } : {}),
padding: 0,
backgroundColor: "rgba(0,0,0,1)", // @todo currently transparency is at 1 to hide the center thing that i can't make disappear
borderRadius: 5,
display: "flex",
justifyContent: "center",
alignItems: "center",
fontFamily: "Aeonik Pro",
fontWeight: 400,
"&:before": {
content: '"Tokens"',
width: "50%",
height: "100%",
display: "flex",
justifyContent: "center",
alignItems: "center",
zIndex: 10,
pointerEvents: "none",
},
"&:after": {
content: '"Native Stake"',
width: "50%",
height: "100%",
display: "flex",
justifyContent: "center",
alignItems: "center",
zIndex: 10,
pointerEvents: "none",
},
"& .MuiSwitch-switchBase": {
padding: "0.25rem",
width: "50%",
height: "100%",
display: "flex",
justifyContent: "center",
transitionDuration: "300ms",
transform: "translateX(0%)",
"& + .MuiSwitch-track": {
opacity: 0,
width: 0,
height: "100%",
},
"&.Mui-disabled + .MuiSwitch-track": {
opacity: 0.5,
},
"&.Mui-checked": {
transform: "translateX(100%)",
},
},
"&:hover .MuiSwitch-thumb": {
backgroundColor: "#394147",
},
"& .MuiSwitch-thumb": {
boxSizing: "border-box",
width: "100%",
height: "100%",
backgroundColor: "#2F373D",
borderRadius: 4,
},
}));

export { LstDepositToggle };
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React, { FC, ReactNode } from "react";

// Put this in common folder in the future when all is merged

interface PrimaryButtonProps {
children?: ReactNode;
loading?: boolean;
disabled?: boolean;
onClick?: () => void;
}

export const PrimaryButton: FC<PrimaryButtonProps> = ({ children, disabled, loading, onClick }) => (
<a onClick={disabled ? undefined : onClick}>
<div
className={`w-full h-full flex flex-row justify-center items-center capitalize rounded-[3px] font-aeonik font-normal z-10 ${
loading
? "wavy-gradient-bg text-black"
: disabled
? "bg-[#808080] text-black"
: "bg-[#e3e3e3] text-black cursor-pointer"
}
`}
>
{children}
</div>
</a>
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from "react";

export const RefreshIcon: React.FC<React.SVGAttributes<SVGElement>> = ({ width = "12", height = "12" }) => {
return (
<svg width={width} height={height} viewBox="0 0 12 12" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<g clipPath="url(#clip0_841_4053)">
<path
d="M11.6466 4.23513V0.706082L10.4111 1.94156C9.3173 0.741165 7.72912 0 6 0C2.6827 0 0 2.6827 0 6C0 9.3173 2.68203 12 6 12C7.69405 12 9.21142 11.2939 10.3059 10.165L9.31797 9.14128C8.50601 10.0234 7.30561 10.5879 6 10.5879C3.45892 10.5879 1.41216 8.5411 1.41216 6.00002C1.41216 3.45894 3.45892 1.41218 6 1.41218C7.34135 1.41218 8.57615 2.01238 9.42317 2.92954L8.11757 4.23515L11.6466 4.23513Z"
fill="currentColor"
/>
</g>
<defs>
<clipPath id="clip0_841_4053">
<rect width={width} height={height} fill="white" />
</clipPath>
</defs>
</svg>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from "react";

export const SettingsIcon: React.FC<React.SVGAttributes<SVGElement>> = ({ width = "12", height = "12" }) => {
return (
<svg width={width} height={height} viewBox="0 0 12 10" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
<path
fillRule="evenodd"
clipRule="evenodd"
d="M4.67559 1.39922C4.18425 1.39922 3.78594 1.79753 3.78594 2.28887C3.78594 2.78022 4.18425 3.17853 4.67559 3.17853C5.16694 3.17853 5.56525 2.78022 5.56525 2.28887C5.56525 1.79753 5.16694 1.39922 4.67559 1.39922ZM1.19961 2.88867H2.67329C2.93107 3.75043 3.72998 4.37853 4.67559 4.37853C5.62121 4.37853 6.42012 3.75043 6.67789 2.88867H10.7996C11.131 2.88867 11.3996 2.62004 11.3996 2.28867C11.3996 1.9573 11.131 1.68867 10.7996 1.68867H6.67777C6.41987 0.827121 5.62106 0.199219 4.67559 0.199219C3.73013 0.199219 2.93132 0.827121 2.67342 1.68867H1.19961C0.868239 1.68867 0.599609 1.9573 0.599609 2.28867C0.599609 2.62004 0.868239 2.88867 1.19961 2.88867ZM0.599609 7.58555C0.599609 7.25418 0.868239 6.98555 1.19961 6.98555H5.98367C6.24157 6.124 7.04038 5.49609 7.98585 5.49609C8.93131 5.49609 9.73012 6.124 9.98802 6.98555H10.7995C11.1309 6.98555 11.3995 7.25418 11.3995 7.58555C11.3995 7.91692 11.1309 8.18555 10.7995 8.18555H9.98814C9.73037 9.04731 8.93146 9.6754 7.98585 9.6754C7.04023 9.6754 6.24132 9.04731 5.98355 8.18555H1.19961C0.868239 8.18555 0.599609 7.91692 0.599609 7.58555ZM7.09619 7.58575C7.09619 7.09441 7.4945 6.69609 7.98585 6.69609C8.47719 6.69609 8.8755 7.09441 8.8755 7.58575C8.8755 8.07709 8.47719 8.4754 7.98585 8.4754C7.4945 8.4754 7.09619 8.07709 7.09619 7.58575Z"
fill="currentColor"
fillOpacity="0.5"
/>
</svg>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
import { Typography, Modal } from "@mui/material";
import { Dispatch, FC, SetStateAction, useState } from "react";
import { Close } from "@mui/icons-material";
import { PrimaryButton } from "./PrimaryButton";
import { SupportedSlippagePercent } from "~/store/lstStore";

interface SettingsModalProps {
isOpen: boolean;
handleClose: () => void;
setSelectedSlippagePercent: (slippage: SupportedSlippagePercent) => void;
selectedSlippagePercent: SupportedSlippagePercent;
}

const SLIPPAGE_PRESET: SupportedSlippagePercent[] = [0.1, 0.5, 1.0, 5.0];

export const SettingsModal: FC<SettingsModalProps> = ({
isOpen,
handleClose,
selectedSlippagePercent: selectedSlippage,
setSelectedSlippagePercent: setSelectedSlippage,
}) => {
const [localSlippage, setLocalSlippage] = useState<SupportedSlippagePercent>(selectedSlippage);

const onSaveSettings = () => {
setSelectedSlippage(localSlippage);
handleClose();
};

return (
<Modal
open={isOpen}
onClose={handleClose}
aria-labelledby="parent-modal-title"
aria-describedby="parent-modal-description"
className="border-none"
>
<div className="mx-auto mt-48 rounded-xl bg-[#1C2023] w-[400px] max-w-[90%] p-4">
<div className="flex flex-row justify-between mb-3">
<Typography className="font-aeonik font-[700] text-2xl inline">Swap Settings</Typography>
<div className="cursor-pointer" onClick={handleClose}>
<Close />
</div>
</div>
<Typography className="font-aeonik font-[500] text-xl">Slippage Settings</Typography>
<div className="flex flex-row items-center mt-2.5 rounded-xl overflow-hidden text-sm mb-10">
{SLIPPAGE_PRESET.map((slippage, idx) => {
const displayText = Number(slippage) + "%";
const isHighlighted = localSlippage === slippage;
return (
<a
key={idx}
className={`relative cursor-pointer flex-1 text-secondary py-3 ${
isHighlighted ? "bg-[#303437]" : "bg-[#1B1B1E]"
}`}
onClick={() => {
setLocalSlippage(slippage);
}}
>
<div className="h-full w-full leading-none flex justify-center items-center">
<Typography className={`text-secondary mt-[2px]`}>{displayText}</Typography>
</div>
</a>
);
})}
</div>
<div className="h-[36px]">
<PrimaryButton onClick={() => onSaveSettings()}>Save</PrimaryButton>
</div>
</div>
</Modal>
);
};
Loading

0 comments on commit d72631a

Please sign in to comment.