Skip to content
48 changes: 32 additions & 16 deletions public/configs/v1/env.json
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,8 @@
"stakingAPR": "https://apybara-proxy-web-testnet.infrastructure-34d.workers.dev/v0/protocols/dydx",
"faucet": "https://faucet.v4dev.dydx.exchange",
"affiliates": "https://dydx.stg.fuul.xyz",
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com"
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com",
"pnlImageApi": "https://image-generator.dydx.trade/generate-trade-card-web"
},
"stakingValidators": [],
"featureFlags": {
Expand Down Expand Up @@ -504,7 +505,8 @@
"neutronValidator": "https://neutron-testnet-rpc.polkachu.com/",
"geoV2": "https://geo-whitelist-web-mainnet-preview.infrastructure-34d.workers.dev/",
"geo": "https://api.dydx.exchange/v4/geo",
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com"
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com",
"pnlImageApi": "https://image-generator.dydx.trade/generate-trade-card-web"
},
"stakingValidators": [],
"featureFlags": {
Expand Down Expand Up @@ -549,7 +551,8 @@
"stakingAPR": "https://apybara-proxy-web-testnet.infrastructure-34d.workers.dev/v0/protocols/dydx",
"faucet": "http://dev3-faucet-lb-public-1644791410.us-east-2.elb.amazonaws.com",
"affiliates": "https://dydx.stg.fuul.xyz",
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com"
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com",
"pnlImageApi": "https://image-generator.dydx.trade/generate-trade-card-web"
},
"stakingValidators": [],
"featureFlags": {
Expand Down Expand Up @@ -594,7 +597,8 @@
"stakingAPR": "https://apybara-proxy-web-testnet.infrastructure-34d.workers.dev/v0/protocols/dydx",
"faucet": "https://faucet.v4dev4.dydx.exchange",
"affiliates": "https://dydx.stg.fuul.xyz",
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com"
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com",
"pnlImageApi": "https://image-generator.dydx.trade/generate-trade-card-web"
},
"stakingValidators": [],
"featureFlags": {
Expand Down Expand Up @@ -636,7 +640,8 @@
"neutronValidator": "https://neutron-testnet-rpc.polkachu.com/",
"geoV2": "https://geo-whitelist-web-mainnet-preview.infrastructure-34d.workers.dev/",
"geo": "https://api.dydx.exchange/v4/geo",
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com"
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com",
"pnlImageApi": "https://image-generator.dydx.trade/generate-trade-card-web"
},
"stakingValidators": [],
"featureFlags": {
Expand Down Expand Up @@ -680,7 +685,8 @@
"neutronValidator": "https://neutron-testnet-rpc.polkachu.com/",
"geo": "https://api.dydx.exchange/v4/geo",
"geoV2": "https://geo-whitelist-web-mainnet-preview.infrastructure-34d.workers.dev/",
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com"
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com",
"pnlImageApi": "https://image-generator.dydx.trade/generate-trade-card-web"
},
"stakingValidators": [],
"featureFlags": {
Expand Down Expand Up @@ -724,7 +730,8 @@
"neutronValidator": "https://neutron-testnet-rpc.polkachu.com/",
"geoV2": "https://geo-whitelist-web-mainnet-preview.infrastructure-34d.workers.dev/",
"geo": "https://api.dydx.exchange/v4/geo",
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com"
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com",
"pnlImageApi": "https://image-generator.dydx.trade/generate-trade-card-web"
},
"apps": {
"ios": {
Expand Down Expand Up @@ -780,7 +787,8 @@
"neutronValidator": "https://neutron-testnet-rpc.polkachu.com/",
"geoV2": "https://geo-whitelist-web-mainnet-preview.infrastructure-34d.workers.dev/",
"geo": "https://api.dydx.exchange/v4/geo",
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com"
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com",
"pnlImageApi": "https://image-generator.dydx.trade/generate-trade-card-web"
},
"stakingValidators": [],
"featureFlags": {
Expand Down Expand Up @@ -826,7 +834,8 @@
"stakingAPR": "https://apybara-proxy-web-testnet.infrastructure-34d.workers.dev/v0/protocols/dydx",
"faucet": "https://faucet.v4testnet.dydx.exchange",
"affiliates": "https://dydx.stg.fuul.xyz",
"spotApi": "https://dydx-solana-api-staging-e2fb353831a4.herokuapp.com"
"spotApi": "https://dydx-solana-api-staging-e2fb353831a4.herokuapp.com",
"pnlImageApi": "https://image-generator.dydx.trade/generate-trade-card-web"
},
"stakingValidators": [
"dydxvaloper1vvc9vl6z9pu0vt2y79d0ln8zp6qmpmrhxx99h4",
Expand Down Expand Up @@ -874,7 +883,8 @@
"stakingAPR": "https://apybara-proxy-web-testnet.infrastructure-34d.workers.dev/v0/protocols/dydx",
"faucet": "https://faucet.v4testnet.dydx.exchange",
"affiliates": "https://dydx.stg.fuul.xyz",
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com"
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com",
"pnlImageApi": "https://image-generator.dydx.trade/generate-trade-card-web"
},
"stakingValidators": [],
"featureFlags": {
Expand Down Expand Up @@ -919,7 +929,8 @@
"stakingAPR": "https://apybara-proxy-web-testnet.infrastructure-34d.workers.dev/v0/protocols/dydx",
"faucet": "https://faucet.v4testnet.dydx.exchange",
"affiliates": "https://dydx.stg.fuul.xyz",
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com"
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com",
"pnlImageApi": "https://image-generator.dydx.trade/generate-trade-card-web"
},
"stakingValidators": [],
"featureFlags": {
Expand Down Expand Up @@ -964,7 +975,8 @@
"stakingAPR": "https://apybara-proxy-web-testnet.infrastructure-34d.workers.dev/v0/protocols/dydx",
"faucet": "https://faucet.v4testnet.dydx.exchange",
"affiliates": "https://dydx.stg.fuul.xyz",
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com"
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com",
"pnlImageApi": "https://image-generator.dydx.trade/generate-trade-card-web"
},
"stakingValidators": [],
"featureFlags": {
Expand Down Expand Up @@ -1009,7 +1021,8 @@
"stakingAPR": "https://apybara-proxy-web-testnet.infrastructure-34d.workers.dev/v0/protocols/dydx",
"faucet": "https://faucet.v4testnet.dydx.exchange",
"affiliates": "https://dydx.stg.fuul.xyz",
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com"
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com",
"pnlImageApi": "https://image-generator.dydx.trade/generate-trade-card-web"
},
"stakingValidators": [],
"featureFlags": {
Expand Down Expand Up @@ -1054,7 +1067,8 @@
"stakingAPR": "https://apybara-proxy-web-testnet.infrastructure-34d.workers.dev/v0/protocols/dydx",
"faucet": "https://faucet.v4testnet.dydx.exchange",
"affiliates": "https://dydx.stg.fuul.xyz",
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com"
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com",
"pnlImageApi": "https://image-generator.dydx.trade/generate-trade-card-web"
},
"stakingValidators": [],
"featureFlags": {
Expand Down Expand Up @@ -1099,7 +1113,8 @@
"stakingAPR": "https://apybara-proxy-web-testnet.infrastructure-34d.workers.dev/v0/protocols/dydx",
"faucet": "https://faucet.v4testnet.dydx.exchange",
"affiliates": "https://dydx.stg.fuul.xyz",
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com"
"spotApi": "https://dydx-solana-api-prod-89bf4c933ba0.herokuapp.com",
"pnlImageApi": "https://image-generator.dydx.trade/generate-trade-card-web"
},
"stakingValidators": [],
"featureFlags": {
Expand Down Expand Up @@ -1144,7 +1159,8 @@
"geoV2": "[geo v2 endpoint for mainnet]",
"stakingAPR": "[staking APR endpoint for mainnet]",
"affiliates": "[affiliates endpoint for mainnet]",
"spotApi": "[spot api endpoint for mainnet]"
"spotApi": "[spot api endpoint for mainnet]",
"pnlImageApi": "[pnl image api endpoint for mainnet]"
},
"stakingValidators": [],
"featureFlags": {
Expand Down
4 changes: 2 additions & 2 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ import { SkipProvider } from './hooks/transfers/skipClient';
import { useAnalytics } from './hooks/useAnalytics';
import { useBreakpoints } from './hooks/useBreakpoints';
import { useCommandMenu } from './hooks/useCommandMenu';
import { useComplianceState } from './hooks/useComplianceState';
import { useInitializePage } from './hooks/useInitializePage';
import { useLocalStorage } from './hooks/useLocalStorage';
import { usePerpetualsComplianceState } from './hooks/usePerpetualsComplianceState';
import { useReferralCode } from './hooks/useReferralCode';
import { useShouldShowFooter } from './hooks/useShouldShowFooter';
import { useSimpleUiEnabled } from './hooks/useSimpleUiEnabled';
Expand Down Expand Up @@ -109,7 +109,7 @@ const Content = () => {
const isShowingFooter = useShouldShowFooter();
const abDefaultToMarkets = useCustomFlagValue(CustomFlags.abDefaultToMarkets);
const isSimpleUi = useSimpleUiEnabled();
const { showComplianceBanner } = usePerpetualsComplianceState();
const { showComplianceBanner } = useComplianceState();
const isSimpleUiUserMenuOpen = useAppSelector(getIsUserMenuOpen);

// Track current path in Redux for conditional polling
Expand Down
11 changes: 10 additions & 1 deletion src/bonsai/calculators/compliance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ export function calculateCompliance({
geo: geoBase,
localAddressScreenV2,
sourceAddressScreenV2,
solanaAddressScreen,
}: ComplianceState): Compliance {
const geo = {
currentlyGeoBlocked: geoBase.data?.whitelisted
isPerpetualsGeoBlocked: geoBase.data?.whitelisted
? false
: geoHeaders.data?.status === 'restricted',
currentCountry: geoHeaders.data?.country,
Expand All @@ -23,6 +24,14 @@ export function calculateCompliance({
};
}

if (solanaAddressScreen.data?.status === ComplianceStatus.BLOCKED) {
return {
geo,
status: ComplianceStatus.BLOCKED,
updatedAt: solanaAddressScreen.data.updatedAt,
};
}

if (localAddressScreenV2.data?.errors != null) {
return {
geo,
Expand Down
12 changes: 9 additions & 3 deletions src/bonsai/lifecycles/cancelTriggerOrdersLifecycle.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// eslint-disable-next-line import/no-internal-modules
import { selectRawParentSubaccountData } from '@/bonsai/selectors/base';

import { timeUnits } from '@/constants/time';
import { WalletNetworkType } from '@/constants/wallets';

Expand Down Expand Up @@ -25,7 +28,7 @@ export function setUpCancelOrphanedTriggerOrdersLifecycle(store: RootStore) {
const selector = createAppSelector(
[selectTxAuthorizedCloseOnlyAccount, selectOrphanedTriggerOrders],
(txAuthorizedAccount, orphanedTriggerOrders) => {
if (!txAuthorizedAccount || orphanedTriggerOrders == null) {
if (!txAuthorizedAccount || orphanedTriggerOrders?.ordersToCancel == null) {
return undefined;
}

Expand All @@ -35,7 +38,8 @@ export function setUpCancelOrphanedTriggerOrdersLifecycle(store: RootStore) {
localDydxWallet,
sourceAccount,
parentSubaccountInfo,
ordersToCancel: orphanedTriggerOrders,
ordersToCancel: orphanedTriggerOrders.ordersToCancel,
groupedPositions: orphanedTriggerOrders.groupedPositions,
};
}
);
Expand All @@ -51,7 +55,7 @@ export function setUpCancelOrphanedTriggerOrdersLifecycle(store: RootStore) {

runFn(async () => {
try {
const { ordersToCancel: ordersToCancelRaw } = data;
const { ordersToCancel: ordersToCancelRaw, groupedPositions } = data;
const ordersToCancel = ordersToCancelRaw.filter((o) => !cancelingOrderIds.has(o.id));

// context: Cosmos wallets do not support our lifecycle methods and are instead handled within useNotificationTypes
Expand All @@ -67,6 +71,8 @@ export function setUpCancelOrphanedTriggerOrdersLifecycle(store: RootStore) {
`Cancelling ${ordersToCancel.length} trigger orders`,
{
ordersToCancel,
groupedPositions,
bonsaiParentSubaccountData: selectRawParentSubaccountData(store.getState()),
}
);

Expand Down
35 changes: 33 additions & 2 deletions src/bonsai/rest/compliance.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
import { timeUnits } from '@/constants/time';

import { type RootStore } from '@/state/_store';
import { getUserSourceWalletAddress, getUserWalletAddress } from '@/state/accountInfoSelectors';
import {
getUserSolanaWalletAddress,
getUserSourceWalletAddress,
getUserWalletAddress,
} from '@/state/accountInfoSelectors';
import { getSelectedDydxChainId, getSelectedNetwork } from '@/state/appSelectors';
import { createAppSelector } from '@/state/appTypes';
import { setLocalAddressScreenV2Raw, setSourceAddressScreenV2Raw } from '@/state/raw';
import {
setLocalAddressScreenV2Raw,
setSolanaAddressScreenRaw,
setSourceAddressScreenV2Raw,
} from '@/state/raw';
import { getHdKeyNonce } from '@/state/walletSelectors';

import { loadableIdle } from '../lib/loadable';
Expand Down Expand Up @@ -103,3 +111,26 @@ export function setUpIndexerLocalAddressScreenV2Query(store: RootStore) {
store.dispatch(setLocalAddressScreenV2Raw(loadableIdle()));
};
}

export function setUpIndexerSolanaAddressScreenQuery(store: RootStore) {
const cleanupEffect = createIndexerQueryStoreEffect(store, {
name: 'solanaAddressScreen',
selector: getUserSolanaWalletAddress,
getQueryKey: (address) => ['screenSolanaWallet', address],
getQueryFn: (indexerClient, address) => {
if (address == null) {
return null;
}
return () => indexerClient.utility.complianceScreen(address);
},
onResult: (screen) => {
store.dispatch(setSolanaAddressScreenRaw(queryResultToLoadable(screen)));
},
onNoQuery: () => store.dispatch(setSolanaAddressScreenRaw(loadableIdle())),
...pollingOptions,
});
return () => {
cleanupEffect();
store.dispatch(setSolanaAddressScreenRaw(loadableIdle()));
};
}
2 changes: 1 addition & 1 deletion src/bonsai/rest/fills.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
selector: selectParentSubaccountInfo,
getQueryKey: (data) => ['account', 'fills', data.wallet, data.subaccount],
getQueryFn: (indexerClient, data) => {
if (!isTruthy(data.wallet) || data.subaccount == null || data.isGeoRestricted) {
if (!isTruthy(data.wallet) || data.subaccount == null || data.isPerpsGeoRestricted) {

Check warning on line 22 in src/bonsai/rest/fills.ts

View workflow job for this annotation

GitHub Actions / lint

Unnecessary conditional, the types have no overlap
return null;
}
return () =>
Expand Down
2 changes: 1 addition & 1 deletion src/bonsai/rest/lib/nobleTransactionStoreEffect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
ComplianceStatus.CLOSE_ONLY,
ComplianceStatus.FIRST_STRIKE_CLOSE_ONLY,
].includes(complianceData.status) &&
!(complianceData.geo.currentlyGeoBlocked && enableGeoCheck);
!(complianceData.geo.isPerpetualsGeoBlocked && enableGeoCheck);

if (!parentSubaccountInfo.wallet || !isAccountRestrictionFree || localWalletNonce == null) {
return undefined;
Expand All @@ -71,7 +71,7 @@
});
const isCorrectWallet = localNobleWallet?.address === nobleAddress;

if (!isCorrectWallet || localNobleWallet == null) return undefined;

Check warning on line 74 in src/bonsai/rest/lib/nobleTransactionStoreEffect.ts

View workflow job for this annotation

GitHub Actions / lint

Unnecessary conditional, the types have no overlap

return {
localNobleWallet,
Expand Down
2 changes: 1 addition & 1 deletion src/bonsai/rest/orders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
selector: selectParentSubaccountInfo,
getQueryKey: (data) => ['account', 'orders', data.wallet, data.subaccount],
getQueryFn: (indexerClient, data) => {
if (!isTruthy(data.wallet) || data.subaccount == null || data.isGeoRestricted) {
if (!isTruthy(data.wallet) || data.subaccount == null || data.isPerpsGeoRestricted) {

Check warning on line 24 in src/bonsai/rest/orders.ts

View workflow job for this annotation

GitHub Actions / lint

Unnecessary conditional, the types have no overlap
return null;
}
return () =>
Expand All @@ -42,7 +42,7 @@
store.dispatch(
setAccountOrdersRaw(
mapLoadableData(queryResultToLoadable(orders), (data) =>
keyBy(isParentSubaccountOrders(data), (o) => o.id ?? '')

Check warning on line 45 in src/bonsai/rest/orders.ts

View workflow job for this annotation

GitHub Actions / lint

Unnecessary conditional, expected left-hand side of `??` operator to be possibly null or undefined
)
)
);
Expand Down
2 changes: 1 addition & 1 deletion src/bonsai/rest/transfers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
selector: selectParentSubaccountInfo,
getQueryKey: (data) => ['account', 'transfers', data],
getQueryFn: (indexerClient, data) => {
if (!isTruthy(data.wallet) || data.subaccount == null || data.isGeoRestricted) {
if (!isTruthy(data.wallet) || data.subaccount == null || data.isPerpsGeoRestricted) {

Check warning on line 24 in src/bonsai/rest/transfers.ts

View workflow job for this annotation

GitHub Actions / lint

Unnecessary conditional, the types have no overlap
return null;
}
return async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/bonsai/selectors/accountTransaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const selectTxAuthorizedAccount = createAppSelector(
ComplianceStatus.CLOSE_ONLY,
ComplianceStatus.FIRST_STRIKE_CLOSE_ONLY,
].includes(complianceData.status) &&
!(complianceData.geo.currentlyGeoBlocked && geoCheckEnabled);
!(complianceData.geo.isPerpetualsGeoBlocked && geoCheckEnabled);

if (!parentSubaccountInfo.wallet || !isAccountRestrictionFree || localWalletNonce == null) {
return undefined;
Expand Down
2 changes: 2 additions & 0 deletions src/bonsai/selectors/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ export const selectRawLocalAddressScreenV2 = (state: RootState) =>
state.raw.compliance.localAddressScreenV2;
export const selectRawSourceAddressScreenV2 = (state: RootState) =>
state.raw.compliance.sourceAddressScreenV2;
export const selectRawSolanaAddressScreen = (state: RootState) =>
state.raw.compliance.solanaAddressScreen;
export const selectRawGeo = (state: RootState) => state.raw.compliance.geo;
export const selectRawGeoHeaders = (state: RootState) => state.raw.compliance.geoHeaders;
export const selectRawRewardParams = (state: RootState) => state.raw.rewards.data.data;
Expand Down
Loading
Loading