Skip to content

Commit

Permalink
Merge pull request #141 from dhedge/feat/disable-withdrawal-windows-f…
Browse files Browse the repository at this point in the history
…or-migrated-synthetix-vaults

feat: remove withdrawal windows check for deprecated Synthetix vaults
  • Loading branch information
dimlbc authored Dec 9, 2024
2 parents 9cff580 + 270a21e commit ed14f13
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/trading-widget/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dhedge/trading-widget",
"version": "3.2.3",
"version": "3.2.4",
"license": "MIT",
"type": "module",
"main": "index.js",
Expand Down
5 changes: 5 additions & 0 deletions packages/trading-widget/src/core-kit/const/synthetix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ export const DHEDGE_SYNTHETIX_V3_VAULT_ADDRESSES: Address[] = [
'0xe9b5260d99d283ff887859c569baf8ad1bd12aac', // Synthetix ETH Yield Arbitrum
]

export const DEPRECATED_DHEDGE_SYNTHETIX_V3_VAULT_ADDRESSES: Address[] = [
'0xc1e02884af4a283ca25ab63c45360d220d69da52', // Synthetix USDC Yield Base
'0xc3198eb5102fb3335c0e911ef1da4bc07e403dd1', // Synthetix USD Yield Arbitrum
]

// Should include symbols for all vaults from DHEDGE_SYNTHETIX_V3_VAULT_ADDRESSES
export const SYNTHETIX_V3_VAULTS_WITHDRAW_ASSET_SYMBOL_MAP: Record<
string,
Expand Down
6 changes: 6 additions & 0 deletions packages/trading-widget/src/core-kit/utils/synthetix.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
DEPRECATED_DHEDGE_SYNTHETIX_V3_VAULT_ADDRESSES,
DHEDGE_SYNTHETIX_V3_ASSETS_MAP,
DHEDGE_SYNTHETIX_V3_VAULT_ADDRESSES,
} from 'core-kit/const'
Expand All @@ -14,3 +15,8 @@ export const isSynthetixV3Asset = (address: string) =>
Object.values(DHEDGE_SYNTHETIX_V3_ASSETS_MAP).some((asset) =>
isEqualAddress(asset, address),
)

export const isDeprecatedSynthetixV3Vault = (address: string) =>
DEPRECATED_DHEDGE_SYNTHETIX_V3_VAULT_ADDRESSES.some((vault) =>
isEqualAddress(vault, address),
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ import {
import { useSynthetixV3OraclesUpdate } from 'core-kit/hooks/trading'
import { useWithdrawLiquidity } from 'core-kit/hooks/trading/synthetix-v3/use-withdraw-liquidity'
import { useInitWithdrawAllowance } from 'core-kit/hooks/trading/withdraw-v2/init-step'
import { isSynthetixV3Vault } from 'core-kit/utils'
import {
isDeprecatedSynthetixV3Vault,
isSynthetixV3Vault,
} from 'core-kit/utils'

import {
useHighSlippageCheck,
Expand Down Expand Up @@ -46,9 +49,12 @@ export const useValidInitWithdrawButton = () => {
}

const isSynthetixVault = isSynthetixV3Vault(address)
// TODO: remove after these vaults will be fully deprecated
const isDeprecatedSynthetixVault = isDeprecatedSynthetixV3Vault(address)

return {
requiresWithdrawalWindow: isSynthetixVault && !isWithdrawal,
requiresWithdrawalWindow:
isSynthetixVault && !isDeprecatedSynthetixVault && !isWithdrawal,
requiresWithdrawalLiquidity:
isSynthetixVault && !!sendToken.value && liquidity.noLiquidity,
requiresEndOfCooldown: cooldownActive,
Expand Down

0 comments on commit ed14f13

Please sign in to comment.