Skip to content

Commit

Permalink
fix: limit slippage (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
nick134-bit authored Nov 11, 2023
1 parent cf03ba3 commit 0edfcff
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion components/Pages/Trade/Liquidity/DepositForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ const DepositForm = ({
name="token2"
control={control}
token={tokenB}
isDisabled={true}
isDisabled={isInputDisabled || !tokenB?.tokenSymbol}
mobile={mobile}
onChange={(value) => {
setReverse(true)
Expand Down
2 changes: 2 additions & 0 deletions components/Pages/Trade/Liquidity/hooks/createLPMsg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const createLpMsg = ({
return {
provide_liquidity: {
assets: [asset1, asset2],
slippage_tolerance: '0.005',
},
}
}
Expand All @@ -32,6 +33,7 @@ const createLpMsg = ({
assets: [asset1, asset2],
pair_address: pairAddress,
unbonding_duration: bondingDays * minUnbondingDuration,
slippage_tolerance: '0.005',
},
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export const useTransaction = ({
const [buttonLabel, setButtonLabel] = useState<unknown | null>(null)
const queryClient = useQueryClient()


const { data: fee } = useQuery<unknown, unknown, any | null>(
['fee', tokenAAmount, tokenBAmount, debouncedMsgs, error],
async () => {
Expand Down Expand Up @@ -87,6 +88,11 @@ export const useTransaction = ({
setTxStep(TxStep.Idle)
setError('Try increasing slippage')
throw new Error('Try increasing slippage')
} else if ((/Slippage tolerance exceeded/u).test(error.toString())) {
console.error(error)
setTxStep(TxStep.Idle)
setError('Slippage too high')
throw new Error('Retry again later')
} else {
setTxStep(TxStep.Idle)
setError(error?.message)
Expand Down
2 changes: 1 addition & 1 deletion public/mainnet/phoenix-1/pools_list.json
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@
"lpOrder": ["ampROAR", "ROAR"],
"assetOrder": ["ampROAR", "ROAR"],
"displayName": "ampROAR-ROAR",
"displayLogo1": "/logos/ampROAR.png.png",
"displayLogo1": "/logos/ampROAR.png",
"displayLogo2": "/logos/lion.png",
"pool_assets": [
{
Expand Down

0 comments on commit 0edfcff

Please sign in to comment.