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

fix: limit slippage #426

Merged
merged 3 commits into from
Nov 11, 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
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
Loading