Skip to content

feat: add geo-block#5625

Open
therealemjy wants to merge 3 commits into
mainfrom
feat/geo-blocker
Open

feat: add geo-block#5625
therealemjy wants to merge 3 commits into
mainfrom
feat/geo-blocker

Conversation

@therealemjy

@therealemjy therealemjy commented Jun 10, 2026

Copy link
Copy Markdown
Member

Jira ticket(s)

VPD-1352

Changes

  • add geo-block
  • list NVDAB, TSLAB and SPCB on testnet

@therealemjy therealemjy requested a review from cuzz-venus June 10, 2026 13:04
@vercel

vercel Bot commented Jun 10, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dapp-preview Ready Ready Preview Jun 17, 2026 1:55pm
dapp-testnet Ready Ready Preview Jun 17, 2026 1:55pm
venus.io Ready Ready Preview Jun 17, 2026 1:55pm

Request Review

@changeset-bot

changeset-bot Bot commented Jun 10, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 22f9955

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@venusprotocol/evm Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@greptile-apps

greptile-apps Bot commented Jun 10, 2026

Copy link
Copy Markdown

Greptile Summary

This PR implements geo-blocking by fetching the user's IP location from freeipapi.com and applying restrictedCountries/gatedCountries flags — sourced from the Venus API's token metadata — to pool assets. Restricted assets show a "not available" notice in the lending/trade/swap UI while gated assets trigger a one-time per-chain acknowledgement modal before access is granted; existing positions can always be closed regardless of restriction status.

  • New query layer: useGetIpLocation fetches IP location once per session (staleTime/gcTime = Infinity); useGetPools is split into useGetPoolsQuery (raw fetch) + a thin wrapper that applies applyCountryCodeToPools via useMemo after both queries settle.
  • New UI gates: GatedAssetAcknowledgementModal (non-dismissible via Escape/backdrop, accept/reject only) is wired into MarketTable, Market, Trade, and TokenListWrapper; AssetAccessor renders a warning notice for restricted assets while still permitting withdraw/repay on existing positions.

Confidence Score: 5/5

Safe to merge; the geo-blocking logic is well-scoped and IP-location failures degrade gracefully (no restriction applied) without surfacing errors to pool consumers.

The implementation correctly handles all edge cases examined: response.ok is checked before JSON parsing, the IP location error is logged but not propagated as a query error, existing positions are allowed through restrictions for withdraw/repay, and the modal is truly non-dismissible via keyboard/backdrop. The only note is that the acknowledgement modal's legal copy is bStocks-specific and would need updating if other gated assets are added.

apps/evm/src/containers/GatedAssetAcknowledgementModal/index.tsx — the hardcoded bStocks URL and description are the only area that would need revisiting when additional gated assets are onboarded.

Important Files Changed

Filename Overview
apps/evm/src/clients/api/queries/useGetIpLocation/getIpLocation/index.ts New utility that fetches IP location from freeipapi.com; correctly checks response.ok before parsing JSON body
apps/evm/src/clients/api/queries/useGetPools/index.ts Refactored: now orchestrates useGetPoolsQuery + useGetIpLocation, applying country-code filtering via useMemo; IP errors are logged but not surfaced as query errors
apps/evm/src/clients/api/queries/useGetPools/applyCountryCodeToPools/index.ts New helper that applies restrictedCountries/gatedCountries from API token metadata to pool assets based on the user's country code
apps/evm/src/containers/GatedAssetAcknowledgementModal/index.tsx New modal for gated asset acknowledgement; controls its own visibility via doNotShowGatedAssetModal chain setting; contains hardcoded bStocks-specific URL and description text
apps/evm/src/containers/AssetAccessor/index.tsx Correctly shows a warning notice for restricted assets; allows withdraw/repay through restriction when user has an existing position
apps/evm/src/containers/TokenListWrapper/index.tsx New container wrapping token selection UI; intercepts gated token selection to show acknowledgement modal before proceeding; uses pending-token pattern with a stable ref
apps/evm/src/containers/MarketTable/index.tsx Shows GatedAssetAcknowledgementModal instead of the operation modal when a gated asset is selected and the user hasn't yet acknowledged
apps/evm/src/components/Modal/index.tsx Makes handleClose optional; hides the close button when handleClose is undefined, enabling non-dismissible modals

Reviews (7): Last reviewed commit: "feat: expand geo blocker" | Re-trigger Greptile

Comment thread apps/evm/src/clients/api/queries/useGetPools/getPools/formatOutput/index.ts Outdated
Comment thread apps/evm/src/clients/api/queries/useGetPools/getPools/index.ts Outdated
@github-actions

github-actions Bot commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Coverage Report for ./apps/evm

Status Category Percentage Covered / Total
🔵 Lines 81.58% 47815 / 58609
🔵 Statements 81.58% 47815 / 58609
🔵 Functions 62.38% 660 / 1058
🔵 Branches 73.24% 5487 / 7491
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
apps/evm/src/clients/api/index.ts 100% 100% 100% 100%
apps/evm/src/clients/api/queries/getPendingRewards/getApiTokenPrice/index.ts 92% 0% 100% 92% 2, 41
apps/evm/src/clients/api/queries/getRawTradePositions/index.ts 98.93% 84% 100% 98.93% 1
apps/evm/src/clients/api/queries/useGetIpLocation/index.ts 92.85% 0% 100% 92.85% 1
apps/evm/src/clients/api/queries/useGetIpLocation/getIpLocation/index.ts 85.36% 77.77% 100% 85.36% 1, 40-44
apps/evm/src/clients/api/queries/useGetPools/index.ts 93.75% 70% 100% 93.75% 1, 24
apps/evm/src/clients/api/queries/useGetPools/applyCountryCodeToPools/index.ts 100% 75% 100% 100%
apps/evm/src/clients/api/queries/useGetPools/useGetPoolsQuery/index.ts 92.18% 50% 100% 92.18% 1, 100-103
apps/evm/src/components/index.ts 100% 100% 100% 100%
apps/evm/src/components/Modal/index.tsx 100% 66.66% 100% 100%
apps/evm/src/components/SelectTokenTextField/index.tsx 100% 87.5% 100% 100%
apps/evm/src/constants/functionKey.ts 100% 50% 100% 100%
apps/evm/src/containers/AssetAccessor/index.tsx 98.48% 90% 100% 98.48% 37
apps/evm/src/containers/GatedAssetAcknowledgementModal/index.tsx 100% 75% 100% 100%
apps/evm/src/containers/MarketTable/index.tsx 92.26% 73.68% 57.14% 92.26% 112-120, 216, 251-255
apps/evm/src/containers/TokenListWrapper/index.tsx 91.61% 94.73% 100% 91.61% 158-171
apps/evm/src/containers/VaultCard/VenusVaultModal/WithdrawTab/WithdrawFromVestingVaultForm/RequestWithdrawalForm/index.tsx 97.74% 84% 100% 97.74% 56-57, 71-72
apps/evm/src/hooks/useGetSwapTokenUserBalances/index.ts 96.77% 85.71% 100% 96.77% 3
apps/evm/src/hooks/useGetTradePositions/index.ts 90.62% 52.94% 100% 90.62% 1, 48-49, 56, 60, 64
apps/evm/src/hooks/useUserChainSettings/index.tsx 93.54% 33.33% 100% 93.54% 1, 26
apps/evm/src/pages/Market/index.tsx 100% 66.66% 100% 100%
apps/evm/src/pages/Market/OperationForm/BoostForm/index.tsx 94.38% 91.56% 84.61% 94.38% 149-152, 272-282, 313-322
apps/evm/src/pages/Market/OperationForm/Repay/RepayWithCollateralForm/index.tsx 96.54% 93.54% 90% 96.54% 165-168, 300-310, 379
apps/evm/src/pages/Market/OperationForm/Repay/RepayWithWalletBalanceForm/index.tsx 97.44% 91.08% 87.5% 97.44% 99, 185, 475-485, 498
apps/evm/src/pages/Market/OperationForm/SupplyForm/index.tsx 90.84% 85.71% 77.77% 90.84% 101, 195, 332-347, 358-359, 384-385, 442-452, 467, 506-509
apps/evm/src/pages/Market/OperationForm/useGetOperationFormTokenBalances/index.ts 97.87% 83.33% 100% 97.87% 2
apps/evm/src/pages/Swap/index.tsx 97.47% 84.21% 100% 97.47% 170-172, 365, 410, 417-420
apps/evm/src/pages/Trade/index.tsx 94.4% 90% 66.66% 94.4% 65-73
apps/evm/src/pages/Trade/OperationForm/index.tsx 0% 0% 0% 0% 1-21
apps/evm/src/pages/Trade/PairInfo/index.tsx 95.48% 74.07% 100% 95.48% 108, 156-157, 166-169, 202, 209
apps/evm/src/pages/Trade/PairInfo/TokenSelect/index.tsx 100% 71.42% 100% 100%
apps/evm/src/pages/Trade/PositionForm/index.tsx 100% 93.33% 100% 100%
apps/evm/src/pages/Trade/PositionForm/Form/SelectDsaTokenTextField/index.tsx 100% 71.42% 100% 100%
apps/evm/src/store/index.ts 98.36% 90% 100% 98.36% 1
apps/evm/src/types/index.ts 98.36% 90% 100% 98.36% 9
Generated in workflow #13665 for commit 22f9955 by the Vitest Coverage Report Action

@therealemjy therealemjy removed the request for review from cuzz-venus June 10, 2026 14:54
@therealemjy therealemjy marked this pull request as draft June 10, 2026 14:54
Comment thread apps/evm/src/clients/api/queries/useGetPools/getPools/index.ts Outdated
@therealemjy

Copy link
Copy Markdown
Member Author

@greptile

@therealemjy

Copy link
Copy Markdown
Member Author

@greptile your first assumption is incorrect. The isGated and isRestricted properties of each asset within pools will be true if freeapi.com is unavailable, which is an acceptable drawback.
It is true that assets will be ungated and unrestricted while whiling for freeapi.com to respond, but that's an acceptable drawback too.

@therealemjy

Copy link
Copy Markdown
Member Author

@greptile

@therealemjy therealemjy requested a review from cuzz-venus June 16, 2026 16:05

@cuzz-venus cuzz-venus left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@therealemjy

Copy link
Copy Markdown
Member Author

@greptile

Comment thread apps/evm/src/clients/api/queries/useGetPools/index.ts
@therealemjy

Copy link
Copy Markdown
Member Author

@greptile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants