Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

autoswap frontend #481

Open
wants to merge 94 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 79 commits
Commits
Show all changes
94 commits
Select commit Hold shift + click to select a range
cc2339b
Implement sagas
Sniezka1927 Feb 3, 2025
61f87c3
autoswap frontend
matepal00 Feb 3, 2025
102088a
different simulation
matepal00 Feb 3, 2025
588fac6
bump
matepal00 Feb 3, 2025
306b35e
options modal
matepal00 Feb 4, 2025
90a88bb
change simulate function
matepal00 Feb 4, 2025
3eabdb2
fix modal
matepal00 Feb 4, 2025
d88dd34
lookup table addresses and fixed
matepal00 Feb 4, 2025
320553a
Merge remote-tracking branch 'origin/autoswap-frontend' into create-a…
matepal00 Feb 4, 2025
491a426
selectors and sagas refirement
matepal00 Feb 4, 2025
e344575
Merge pull request #482 from invariant-labs/create-and-swap-position-…
matepal00 Feb 4, 2025
c55655c
simulation configuration
matepal00 Feb 4, 2025
6a9fbef
Align settings modal popover
Sniezka1927 Feb 5, 2025
f9d6020
Add check for settings button
Sniezka1927 Feb 5, 2025
60dfbe7
Price impact warning on autoswap
Sniezka1927 Feb 5, 2025
ff1184a
fix modal
matepal00 Feb 5, 2025
ee717d5
Merge pull request #489 from invariant-labs/align-autoswap-settings-m…
matepal00 Feb 5, 2025
057ce83
bump
matepal00 Feb 5, 2025
d9d1e31
connect sagas
matepal00 Feb 5, 2025
e6c08f8
Merge pull request #492 from invariant-labs/connect-sagas
matepal00 Feb 5, 2025
bb65847
Split deposit options
Sniezka1927 Feb 5, 2025
1cdc606
modal state and fixes
matepal00 Feb 5, 2025
a0c814d
bump
matepal00 Feb 6, 2025
642f32e
align with base
matepal00 Feb 6, 2025
6ecd200
Merge pull request #493 from invariant-labs/split-deposit-options
matepal00 Feb 6, 2025
9e3d18e
bump
matepal00 Feb 6, 2025
23f0ae7
check values
matepal00 Feb 6, 2025
4a1376c
modal adjustmet
matepal00 Feb 6, 2025
e486628
Merge branch 'autoswap-frontend' of github.com:invariant-labs/webapp-…
Sniezka1927 Feb 6, 2025
47119a1
Add error styles to price impact
Sniezka1927 Feb 6, 2025
83a5131
refactor code
matepal00 Feb 6, 2025
011d721
bump
matepal00 Feb 6, 2025
f523a54
bump
matepal00 Feb 6, 2025
c75c772
bump
matepal00 Feb 6, 2025
14dd337
align with dev
matepal00 Feb 6, 2025
ab433ca
Merge branch 'autoswap-frontend' into price-impact-warning-on-autoswap
matepal00 Feb 6, 2025
7360ae2
price impact refactor
matepal00 Feb 6, 2025
988098d
Merge pull request #491 from invariant-labs/price-impact-warning-on-a…
matepal00 Feb 6, 2025
0c583ee
transaction cache and fixes
matepal00 Feb 6, 2025
4c67c38
Merge pull request #498 from invariant-labs/price-impact-warning-on-a…
matepal00 Feb 7, 2025
5801d3f
bump package
matepal00 Feb 7, 2025
4135714
bump package
matepal00 Feb 7, 2025
4b17127
final adjustment
matepal00 Feb 7, 2025
fe2f046
price impact fix
matepal00 Feb 7, 2025
34f5771
bump sdk and code refactor
matepal00 Feb 7, 2025
525d4bc
bump
matepal00 Feb 10, 2025
a35ebc2
Show second token value on single checkbox selected
Sniezka1927 Feb 10, 2025
60430ca
Merge pull request #500 from invariant-labs/show-second-token-amount-…
matepal00 Feb 10, 2025
18e845a
fix swap and create position
matepal00 Feb 10, 2025
4133935
both inputs support, code refactor
matepal00 Feb 10, 2025
a1b4146
bump sdk and fixes / corrects
matepal00 Feb 10, 2025
fd214e9
Show amount of assets transferred from wallet in deposit inputs
Sniezka1927 Feb 10, 2025
286a688
error handling and decimal fix
matepal00 Feb 10, 2025
91a8685
error changes
matepal00 Feb 11, 2025
4645079
Use auto as default when possible
Sniezka1927 Feb 11, 2025
39c9c6f
error adjustment
matepal00 Feb 11, 2025
029e225
code refactor in autoswap and code fixes
matepal00 Feb 11, 2025
749b54d
Merge pull request #509 from invariant-labs/autoswap-refactor-fixes
matepal00 Feb 11, 2025
b51d9fd
style correct
matepal00 Feb 11, 2025
fec7483
added error
matepal00 Feb 11, 2025
82689d8
variable refactor
matepal00 Feb 11, 2025
f1ae894
saga refactor
matepal00 Feb 11, 2025
c907e9c
code refactor and optimization
matepal00 Feb 11, 2025
237a04a
change loading state
matepal00 Feb 11, 2025
caa8088
no price from pool check
matepal00 Feb 12, 2025
c241516
requested changes
matepal00 Feb 12, 2025
8803c6e
correct both inputs on
matepal00 Feb 12, 2025
b1b937c
style adjustment part 1
matepal00 Feb 12, 2025
3f3f2d9
bump
matepal00 Feb 12, 2025
72c8e96
deposit options header
matepal00 Feb 13, 2025
d0b749d
checkbox styles
matepal00 Feb 13, 2025
1e39ad5
input width animation
matepal00 Feb 13, 2025
98f4eed
bump
matepal00 Feb 13, 2025
abfa127
consolelog
matepal00 Feb 13, 2025
496898a
price impact change
matepal00 Feb 13, 2025
0d241a3
Merge branch 'dev' of github.com:invariant-labs/webapp-eclipse into a…
wojciech-cichocki Feb 14, 2025
1c1e597
requested changes
matepal00 Feb 14, 2025
2a15ca7
update error handling with setting simulation to null when error
matepal00 Feb 14, 2025
19a3878
requested changes
matepal00 Feb 16, 2025
3389a93
req changes
matepal00 Feb 17, 2025
7cc7682
Merge remote-tracking branch 'origin/dev' into autoswap-frontend
matepal00 Feb 20, 2025
0644644
add pool
matepal00 Feb 20, 2025
e665258
bump
matepal00 Feb 20, 2025
7d706e9
bump2
matepal00 Feb 20, 2025
7b9e647
conole log
matepal00 Feb 20, 2025
f4d4b59
bump v3
matepal00 Feb 20, 2025
04a36b3
query ticks and tickmap optimalization
matepal00 Feb 21, 2025
4d0032f
bump
matepal00 Feb 25, 2025
38647cd
bump package
matepal00 Feb 25, 2025
1cfd6eb
min weth
matepal00 Feb 25, 2025
3303bda
Merge remote-tracking branch 'origin/dev' into autoswap-frontend
matepal00 Feb 25, 2025
ad01bb4
ticks query refactor
matepal00 Feb 25, 2025
56f7cb6
bump limit
matepal00 Feb 25, 2025
b4bd32e
console log
matepal00 Feb 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5,935 changes: 4,176 additions & 1,759 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@emotion/styled": "^11.11.5",
"@invariant-labs/locker-eclipse-sdk": "^0.0.20",
"@invariant-labs/points-sdk": "^0.0.3",
"@invariant-labs/sdk-eclipse": "^0.0.63",
"@invariant-labs/sdk-eclipse": "^0.0.84",
"@irys/web-upload": "^0.0.14",
"@irys/web-upload-solana": "^0.1.7",
"@metaplex-foundation/js": "^0.20.1",
Expand Down Expand Up @@ -61,6 +61,7 @@
"remeda": "^1.61.0",
"slick-carousel": "^1.8.1",
"tss-react": "^4.9.6",
"tweetnacl": "^1.0.3",
"typed-redux-saga": "^1.5.0",
"vite-plugin-top-level-await": "^1.4.1",
"vite-plugin-wasm": "^3.3.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ export const DepositAmountInput: React.FC<IProps> = ({
<Typography className={classes.noCurrencyText}>-</Typography>
)}
</Grid>

<Input
className={classes.input}
classes={{ input: classes.innerInput }}
Expand Down
5 changes: 2 additions & 3 deletions src/components/Inputs/DepositAmountInput/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ const caption2styles = {
export const useStyles = makeStyles<{ isSelected: boolean }>()((theme: Theme, { isSelected }) => ({
wrapper: {
position: 'relative',
marginBottom: 16,

[theme.breakpoints.down('md')]: {
minWidth: 0
}
Expand Down Expand Up @@ -228,7 +226,8 @@ export const useStyles = makeStyles<{ isSelected: boolean }>()((theme: Theme, {
width: '100%',
height: '100%',
backgroundColor: 'rgba(11, 12, 13, 0.88)',
filter: 'blur(4px) brightness(0.4)'
filter: 'blur(4px) brightness(0.4)',
borderRadius: 20
},
blockedInfoWrapper: {
position: 'absolute',
Expand Down
207 changes: 207 additions & 0 deletions src/components/Modals/DepositOptionsModal/DepositOption.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,207 @@
import React, { useRef, useState } from 'react'
import useStyles from './style'
import { Box, Button, Divider, Grid, Input, Tooltip, Typography } from '@mui/material'
import classNames from 'classnames'
import icons from '@static/icons'

interface Props {
value: string
valueIndex: number
setValue: (value: string) => void
saveValue: (value: string) => void
options: {
value: string
label: string
message: string
}[]
upperValueTreshHold: string
lowerValueTreshHold: string
label: string
description: string
divider?: boolean
}

const DepositOption: React.FC<Props> = ({
value,
setValue,
saveValue,
valueIndex,
description,
label,
options,
upperValueTreshHold,
lowerValueTreshHold,
divider
}) => {
const { classes } = useStyles()
const inputRef = useRef<HTMLInputElement>(null)
const [temp, setTemp] = useState<string>(valueIndex === -1 ? value : '')
const allowOnlyDigitsAndTrimUnnecessaryZeros: React.ChangeEventHandler<
HTMLInputElement | HTMLTextAreaElement
> = e => {
const value = e.target.value

const regex = /^\d*\.?\d*$/
if (value === '' || regex.test(value)) {
const startValue = value
const caretPosition = e.target.selectionStart

let parsed = value
const zerosRegex = /^0+\d+\.?\d*$/
if (zerosRegex.test(parsed)) {
parsed = parsed.replace(/^0+/, '')
}
const dotRegex = /^\.\d*$/
if (dotRegex.test(parsed)) {
parsed = `0${parsed}`
}

const diff = startValue.length - parsed.length

setTemp(parsed)

if (caretPosition !== null && parsed !== startValue) {
setTimeout(() => {
if (inputRef.current) {
inputRef.current.selectionStart = Math.max(caretPosition - diff, 0)
inputRef.current.selectionEnd = Math.max(caretPosition - diff, 0)
}
}, 0)
}
} else if (!regex.test(value)) {
setTemp('0.00')
}
}

const checkValue: React.ChangeEventHandler<HTMLInputElement | HTMLTextAreaElement> = e => {
const value = e.target.value
if (Number(value) > Number(upperValueTreshHold)) {
setTemp(upperValueTreshHold)
} else if (Number(value) < Number(lowerValueTreshHold) || isNaN(Number(value))) {
setTemp(lowerValueTreshHold)
} else {
const onlyTwoDigits = '^\\d*\\.?\\d{0,2}$'
const regex = new RegExp(onlyTwoDigits, 'g')
if (regex.test(value)) {
setTemp(value)
} else {
setTemp(Number(value).toFixed(2))
}
}
}

return (
<>
{divider && <Divider className={classes.divider} />}
<Typography className={classes.label}>{label}</Typography>
<Grid container gap='9px'>
{options.map((tier, index) => (
<Button
className={classNames(
classes.slippagePercentageButton,
valueIndex === index && classes.slippagePercentageButtonActive
)}
key={tier.value}
onClick={e => {
e.preventDefault()
setValue(Number(options[index].value).toFixed(2))
saveValue(Number(options[index].value).toFixed(2))
}}>
<Box
sx={{
display: 'flex',
Copy link
Collaborator

Choose a reason for hiding this comment

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

we should put styles like that in style files instead of directly inline

flexDirection: 'column',
justifyContent: 'center',
height: '100%',
gap: '2px'
}}>
<Box
sx={{
fontWeight: 700,
fontSize: 14,
marginTop: '-8px'
}}>
{tier.value}%
</Box>
<Tooltip
title={
<Box
style={{
display: 'flex',
alignItems: 'center',
gap: '6px',
flexDirection: 'row',
justifyContent: 'center'
}}>
<Box width={'12px'}>
<img src={icons.goldenInfoCircle} alt='' width={'12px'} height={'12px'} />
</Box>
<span style={{ width: '141px' }}>{tier.message}</span>
</Box>
}
classes={{ tooltip: classes.tooltip }}>
<Typography
style={{
fontWeight: 400,
fontSize: 10,
letterSpacing: '-0.03%',
textTransform: 'none',
marginLeft: '-4px'
}}>
{tier.label}
{tier.message !== '' ? (
<img
src={icons.infoCircle}
alt=''
width='8px'
style={{ marginTop: '0px', marginLeft: '2px' }}
className={classes.grayscaleIcon}
/>
) : null}
</Typography>
</Tooltip>
</Box>
</Button>
))}
</Grid>
<Box marginTop='6px'>
<Input
disableUnderline
placeholder='0.00'
className={classNames(
classes.detailsInfoForm,
valueIndex === -1 && classes.customSlippageActive
)}
type={'text'}
value={temp}
onChange={e => {
allowOnlyDigitsAndTrimUnnecessaryZeros(e)
checkValue(e)
}}
ref={inputRef}
startAdornment='Custom'
endAdornment={
<>
%
<button
className={classes.detailsInfoBtn}
onClick={() => {
setValue(Number(temp).toFixed(2))
saveValue(Number(temp).toFixed(2))
}}>
Save
</button>
</>
}
classes={{
input: classes.innerInput,
inputAdornedEnd: classes.inputAdornedEnd
}}
/>
</Box>
<Typography className={classes.info}>{description}</Typography>
</>
)
}

export default DepositOption
Loading