-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
78 changed files
with
2,678 additions
and
799 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,3 +39,6 @@ next-env.d.ts | |
|
||
# turbo | ||
.turbo | ||
|
||
# Sentry Auth Token | ||
.sentryclirc |
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,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"; |
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,7 @@ | ||
import * as Sentry from "@sentry/nextjs"; | ||
|
||
Sentry.init({ | ||
dsn: process.env.SENTRY_DSN, | ||
tracesSampleRate: 1, | ||
debug: false, | ||
}); |
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,7 @@ | ||
import * as Sentry from "@sentry/nextjs"; | ||
|
||
Sentry.init({ | ||
dsn: process.env.SENTRY_DSN, | ||
tracesSampleRate: 1, | ||
debug: false, | ||
}); |
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,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>) |
88 changes: 88 additions & 0 deletions
88
apps/marginfi-v2-ui/src/components/Staking/StakingCard/LstDepositToggle.tsx
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,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 }; |
27 changes: 27 additions & 0 deletions
27
apps/marginfi-v2-ui/src/components/Staking/StakingCard/PrimaryButton.tsx
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,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> | ||
); |
19 changes: 19 additions & 0 deletions
19
apps/marginfi-v2-ui/src/components/Staking/StakingCard/RefreshIcon.tsx
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,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> | ||
); | ||
}; |
15 changes: 15 additions & 0 deletions
15
apps/marginfi-v2-ui/src/components/Staking/StakingCard/SettingsIcon.tsx
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,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> | ||
); | ||
}; |
72 changes: 72 additions & 0 deletions
72
apps/marginfi-v2-ui/src/components/Staking/StakingCard/SettingsModal.tsx
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,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> | ||
); | ||
}; |
Oops, something went wrong.