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

Staging #512

Merged
merged 5 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions src/components/Modals/Slippage/Slippage.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ storiesOf('newUi/swap', module)
handleClose={() => {}}
anchorEl={null}
defaultSlippage={'1'}
initialSlippage='2'
/>
</div>
))
4 changes: 3 additions & 1 deletion src/components/Modals/Slippage/Slippage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ interface Props {
handleClose: () => void
anchorEl: HTMLButtonElement | null
defaultSlippage: string
initialSlippage: string
infoText?: string
headerText?: string
}
Expand All @@ -18,11 +19,12 @@ const Slippage: React.FC<Props> = ({
handleClose,
anchorEl,
defaultSlippage,
initialSlippage,
infoText,
headerText
}) => {
const classes = useStyles()
const [slippTolerance, setSlippTolerance] = React.useState<string>('1')
const [slippTolerance, setSlippTolerance] = React.useState<string>(initialSlippage)
const inputRef = React.useRef<HTMLInputElement>(null)

const allowOnlyDigitsAndTrimUnnecessaryZeros: React.ChangeEventHandler<
Expand Down
4 changes: 4 additions & 0 deletions src/components/NewPosition/NewPosition.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,8 @@ storiesOf('position/newPosition', module)
onHideUnknownTokensChange={() => {}}
reloadHandler={() => {}}
currentFeeIndex={feeIndex}
onSlippageChange={() => {}}
initialSlippage={'1'}
/>
</div>
)
Expand Down Expand Up @@ -219,6 +221,8 @@ storiesOf('position/newPosition', module)
onHideUnknownTokensChange={() => {}}
reloadHandler={() => {}}
currentFeeIndex={feeIndex}
onSlippageChange={() => {}}
initialSlippage={'1'}
/>
</div>
)
Expand Down
10 changes: 8 additions & 2 deletions src/components/NewPosition/NewPosition.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ export interface INewPosition {
max: number
}
currentFeeIndex: number
onSlippageChange: (slippage: string) => void
initialSlippage: string
}

export const NewPosition: React.FC<INewPosition> = ({
Expand Down Expand Up @@ -137,7 +139,9 @@ export const NewPosition: React.FC<INewPosition> = ({
hasTicksError,
reloadHandler,
plotVolumeRange,
currentFeeIndex
currentFeeIndex,
onSlippageChange,
initialSlippage
}) => {
const classes = useStyles()

Expand All @@ -153,7 +157,7 @@ export const NewPosition: React.FC<INewPosition> = ({
const [tokenBDeposit, setTokenBDeposit] = useState<string>('')

const [settings, setSettings] = React.useState<boolean>(false)
const [slippTolerance, setSlippTolerance] = React.useState<string>('1')
const [slippTolerance, setSlippTolerance] = React.useState<string>(initialSlippage)
const [anchorEl, setAnchorEl] = React.useState<HTMLButtonElement | null>(null)
const setRangeBlockerInfo = () => {
if (tokenAIndex === null || tokenBIndex === null) {
Expand Down Expand Up @@ -300,6 +304,7 @@ export const NewPosition: React.FC<INewPosition> = ({

const setSlippage = (slippage: string): void => {
setSlippTolerance(slippage)
onSlippageChange(slippage)
}

return (
Expand Down Expand Up @@ -338,6 +343,7 @@ export const NewPosition: React.FC<INewPosition> = ({
handleClose={handleCloseSettings}
anchorEl={anchorEl}
defaultSlippage={'1'}
initialSlippage={initialSlippage}
infoText='Slippage tolerance is a pricing difference between the price at the confirmation time and the actual price of the transaction users are willing to accept when initializing position.'
headerText='Position Transaction Settings'
/>
Expand Down
2 changes: 2 additions & 0 deletions src/components/Swap/Swap.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,8 @@ storiesOf('newUi/swap', module)
]}
initialHideUnknownTokensValue={false}
onHideUnknownTokensChange={() => {}}
onSlippageChange={() => {}}
initialSlippage={'1'}
/>
</div>
))
10 changes: 8 additions & 2 deletions src/components/Swap/Swap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ export interface ISwap {
tokenToPriceData?: CoingeckoPriceData
priceFromLoading?: boolean
priceToLoading?: boolean
onSlippageChange: (slippage: string) => void
initialSlippage: string
}

export const Swap: React.FC<ISwap> = ({
Expand All @@ -115,7 +117,9 @@ export const Swap: React.FC<ISwap> = ({
tokenFromPriceData,
tokenToPriceData,
priceFromLoading,
priceToLoading
priceToLoading,
onSlippageChange,
initialSlippage
}) => {
const classes = useStyles()
enum inputTarget {
Expand All @@ -130,7 +134,7 @@ export const Swap: React.FC<ISwap> = ({
const [amountTo, setAmountTo] = React.useState<string>('')
const [swap, setSwap] = React.useState<boolean | null>(null)
const [rotates, setRotates] = React.useState<number>(0)
const [slippTolerance, setSlippTolerance] = React.useState<string>('1')
const [slippTolerance, setSlippTolerance] = React.useState<string>(initialSlippage)
const [throttle, setThrottle] = React.useState<boolean>(false)
const [settings, setSettings] = React.useState<boolean>(false)
const [detailsOpen, setDetailsOpen] = React.useState<boolean>(false)
Expand Down Expand Up @@ -394,6 +398,7 @@ export const Swap: React.FC<ISwap> = ({
}
const setSlippage = (slippage: string): void => {
setSlippTolerance(slippage)
onSlippageChange(slippage)
}

const handleClickSettings = (event: React.MouseEvent<HTMLButtonElement>) => {
Expand Down Expand Up @@ -453,6 +458,7 @@ export const Swap: React.FC<ISwap> = ({
handleClose={handleCloseSettings}
anchorEl={anchorEl}
defaultSlippage={'1'}
initialSlippage={initialSlippage}
/>
</Grid>
</Grid>
Expand Down
8 changes: 8 additions & 0 deletions src/containers/NewPositionWrapper/NewPositionWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,12 @@ export const NewPositionWrapper = () => {
}
}, [poolsVolumeRanges, poolIndex, isXtoY, xDecimal, yDecimal])

const initialSlippage = localStorage.getItem('INVARIANT_NEW_POSITION_SLIPPAGE') ?? '1'

const onSlippageChange = (slippage: string) => {
localStorage.setItem('INVARIANT_NEW_POSITION_SLIPPAGE', slippage)
}

return (
<NewPosition
tokens={tokens}
Expand Down Expand Up @@ -590,6 +596,8 @@ export const NewPositionWrapper = () => {
}}
plotVolumeRange={currentVolumeRange}
currentFeeIndex={currentUiFeeIndex}
onSlippageChange={onSlippageChange}
initialSlippage={initialSlippage}
/>
)
}
Expand Down
8 changes: 8 additions & 0 deletions src/containers/WrappedSwap/WrappedSwap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ export const WrappedSwap = () => {
}
}, [tokenTo])

const initialSlippage = localStorage.getItem('INVARIANT_SWAP_SLIPPAGE') ?? '1'

const onSlippageChange = (slippage: string) => {
localStorage.setItem('INVARIANT_SWAP_SLIPPAGE', slippage)
}

return (
<Swap
onSwap={(
Expand Down Expand Up @@ -238,6 +244,8 @@ export const WrappedSwap = () => {
tokenToPriceData={tokenToPriceData}
priceFromLoading={priceFromLoading}
priceToLoading={priceToLoading}
onSlippageChange={onSlippageChange}
initialSlippage={initialSlippage}
/>
)
}
Expand Down
14 changes: 7 additions & 7 deletions src/store/consts/static.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ const mainnetBestTiersCreator = () => {
bestTiers.push({
tokenX,
tokenY,
bestTierIndex: 1
bestTierIndex: 3
})
}
}
Expand All @@ -262,22 +262,22 @@ export const bestTiers: Record<NetworkType, BestTier[]> = {
{
tokenX: USDC_DEV.address,
tokenY: WSOL_DEV.address,
bestTierIndex: 1
bestTierIndex: 3
},
{
tokenX: USDC_DEV.address,
tokenY: BTC_DEV.address,
bestTierIndex: 1
bestTierIndex: 3
},
{
tokenX: RENDOGE_DEV.address,
tokenY: BTC_DEV.address,
bestTierIndex: 3
bestTierIndex: 5
},
{
tokenX: USDC_DEV.address,
tokenY: RENDOGE_DEV.address,
bestTierIndex: 3
bestTierIndex: 5
}
],
Testnet: [],
Expand Down Expand Up @@ -352,10 +352,10 @@ export const WSOL_POSITION_INIT_LAMPORTS = new BN(6164600)

export const WSOL_POOL_INIT_LAMPORTS = new BN(106000961)

export const minimumRangesForTiers = [20, 20, 74, 80, 64, 28, 28, 28, 28]
export const minimumRangesForTiers = [20, 20, 20, 20, 74, 80, 64, 28, 28, 28, 28]

export const maxSafeConcentrationsForTiers = [
400.52, 400.52, 41.49, 21.47, 8.13, 5.45, 5.45, 5.45, 5.45
400.52, 400.52, 400.52, 400.52, 41.49, 21.47, 8.13, 5.45, 5.45, 5.45, 5.45
]

export const ALL_FEE_TIERS_DATA = FEE_TIERS.map((tier, index) => ({
Expand Down
Loading