Skip to content

Commit

Permalink
feat(EX-2693): expand Thena, Camelotv3, Quickswapv3, Uniswapv2 for ea…
Browse files Browse the repository at this point in the history
…rn (#2606)

* feat: switch to pre release api

* feat: expand CamelotV3, QuickSwapV3 and Thena for earn

* fix: bugs

* chore: switch to bff pre-release API

* chore: switch to pre-release zap earn API in widget

* fix: bug url detail pool

* fix: dex mapping

* feat: add univ2

* fix: price range

* fix: pool explorer layout

* fix: pool explorer layout

* fix: add nft manager contract for earn

* fix: zap out poolType

* chore: hide chart in position detail screen

* chore: update widget version

* fix: uniswapv2 logo and name

* fix: disable univ2

* fix: add max height to zap migration widget preview

* fix: algebra abi

* fix: camelot name

* fix: add LO approval warning message

* fix: add LO approval warning message

* fix: user position pagination

* fix: price to closest tick calculation

* fix: price to closest tick calculation

* fix: reset logic and icon

* chore: prepare to release
  • Loading branch information
tienkane authored Mar 4, 2025
1 parent 5635061 commit eb3ddd0
Show file tree
Hide file tree
Showing 20 changed files with 681 additions and 99 deletions.
2 changes: 1 addition & 1 deletion .env.dev
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ VITE_KYBER_DAO_STATS_API=https://kyberswap-dao-stats.dev.kyberengineering.io
VITE_ENV=development
VITE_OAUTH_CLIENT_ID=a2f76ad4-895f-401a-ba75-952a929d782c

VITE_BFF_API=https://kyberswap-bff.dev.kyberengineering.io/api
VITE_BFF_API=https://bff.kyberswap.com/api
VITE_KYBER_AI_REFERRAL_ID=1
VITE_KYBER_AI_TOPIC_ID=14,17
VITE_PRICE_ALERT_TOPIC_ID=13
Expand Down
2 changes: 1 addition & 1 deletion .env.stg
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ VITE_KYBER_AI_REFERRAL_ID=1
VITE_KYBER_AI_TOPIC_ID=11
VITE_PRICE_ALERT_TOPIC_ID=9
VITE_ELASTIC_POOL_TOPIC_ID=4,5
VITE_BFF_API=https://kyberswap-bff.stg.kyberengineering.io/api
VITE_BFF_API=https://bff.kyberswap.com/api
VITE_BUCKET_NAME=ks-setting-6d114fd1
VITE_WALLETCONNECT_PROJECT_ID=b5b37945209ea323811f1032e84eaeb5

Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@
"@kyberswap/ks-sdk-classic": "^1.0.3",
"@kyberswap/ks-sdk-core": "1.1.9",
"@kyberswap/ks-sdk-elastic": "^1.1.2",
"@kyberswap/liquidity-widgets": "1.1.19",
"@kyberswap/zap-migration-widgets": "1.0.8",
"@kyberswap/liquidity-chart": "1.0.1",
"@kyberswap/liquidity-widgets": "1.1.20",
"@kyberswap/zap-migration-widgets": "1.0.9",
"@kyberswap/liquidity-chart": "1.0.3",
"@kyberswap/oauth2": "1.0.2",
"@lingui/macro": "^4.6.0",
"@lingui/react": "^4.6.0",
Expand Down
27 changes: 15 additions & 12 deletions src/components/swapv2/LimitOrder/LimitOrderForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -420,21 +420,23 @@ const LimitOrderForm = forwardRef<LimitOrderFormHandle, Props>(function LimitOrd
} catch (error) {}
}, [maxAmountInput, onSetInput, parsedActiveOrderMakingAmount, currencyIn])

const enoughAllowance = useMemo(() => {
try {
const allowanceSubtracted = parsedActiveOrderMakingAmount
? currentAllowance?.subtract(parsedActiveOrderMakingAmount)
: undefined
return Boolean(
currencyIn?.isNative ||
(parseInputAmount &&
(allowanceSubtracted?.greaterThan(parseInputAmount) || allowanceSubtracted?.equalTo(parseInputAmount))),
)
} catch (error) {
const missingAllowance = useMemo(() => {
if (currentAllowance?.equalTo(0)) return true
if (currencyIn?.isNative || !parseInputAmount) return false
const allowanceSubtracted = parsedActiveOrderMakingAmount
? currentAllowance?.subtract(parsedActiveOrderMakingAmount)
: undefined
if (
!allowanceSubtracted ||
allowanceSubtracted.greaterThan(parseInputAmount) ||
allowanceSubtracted.equalTo(parseInputAmount)
)
return false
}
return parseInputAmount.subtract(allowanceSubtracted)
}, [currencyIn?.isNative, currentAllowance, parseInputAmount, parsedActiveOrderMakingAmount])

const enoughAllowance = !Boolean(missingAllowance)

const [approval, approveCallback] = useApproveCallback(
parseInputAmount,
limitOrderContract || undefined,
Expand Down Expand Up @@ -703,6 +705,7 @@ const LimitOrderForm = forwardRef<LimitOrderFormHandle, Props>(function LimitOrd
outputAmount,
displayRate,
deltaRate,
missingAllowance,
})

useImperativeHandle(ref, () => ({
Expand Down
17 changes: 16 additions & 1 deletion src/components/swapv2/LimitOrder/useWarningCreateOrder.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Currency } from '@kyberswap/ks-sdk-core'
import { Currency, CurrencyAmount } from '@kyberswap/ks-sdk-core'
import { Trans } from '@lingui/macro'
import { useMemo } from 'react'
import { Text } from 'rebass'
Expand All @@ -11,6 +11,7 @@ import {
WORSE_PRICE_DIFF_THRESHOLD,
} from 'components/swapv2/LimitOrder/const'
import { useActiveWeb3React } from 'hooks'
import { formatDisplayNumber } from 'utils/numbers'

const HightLight = styled.span`
font-weight: 500;
Expand All @@ -22,12 +23,14 @@ export default function useWarningCreateOrder({
displayRate,
deltaRate,
estimateUSD,
missingAllowance,
}: {
currencyIn: Currency | undefined
outputAmount: string
displayRate: string
deltaRate: DeltaRateLimitOrder
estimateUSD: number
missingAllowance: boolean | CurrencyAmount<Currency>
}) {
const { chainId } = useActiveWeb3React()
const warningMessage = useMemo(() => {
Expand Down Expand Up @@ -70,6 +73,17 @@ export default function useWarningCreateOrder({
)
}

if (missingAllowance && typeof missingAllowance !== 'boolean') {
messages.push(
<Text>
<Trans>
Your current allowance is insufficient. Approve an additional{' '}
{formatDisplayNumber(missingAllowance.toExact(), { significantDigits: 6 })} {currencyIn?.symbol} to proceed.
</Trans>
</Text>,
)
}

return messages
}, [
chainId,
Expand All @@ -80,6 +94,7 @@ export default function useWarningCreateOrder({
displayRate,
estimateUSD,
outputAmount,
missingAllowance,
])
return warningMessage
}
Loading

0 comments on commit eb3ddd0

Please sign in to comment.