Skip to content

Commit 24fa40f

Browse files
committed
feat: add geo-block
1 parent 5e52e76 commit 24fa40f

108 files changed

Lines changed: 2308 additions & 483 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.changeset/wet-poets-knock.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@venusprotocol/evm": minor
3+
---
4+
5+
add geo-block

apps/evm/src/__mocks__/api/pools.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5729,6 +5729,7 @@
57295729
"name": "USDT",
57305730
"symbol": "USDT",
57315731
"decimals": 6,
5732+
"gatedCountries": ["FR"],
57325733
"createdAt": "2025-07-08T13:47:41.000Z",
57335734
"updatedAt": "2025-07-08T13:47:41.000Z",
57345735
"tokenPrices": [
@@ -5921,6 +5922,7 @@
59215922
"name": "BNB",
59225923
"symbol": "BNB",
59235924
"decimals": 18,
5925+
"restrictedCountries": ["FR"],
59245926
"createdAt": "2025-07-08T13:47:41.000Z",
59255927
"updatedAt": "2025-07-08T13:47:41.000Z",
59265928
"tokenPrices": [

apps/evm/src/__mocks__/models/asset.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ export const assetData: Asset[] = [
8484
extraInfoUrl: 'https://fake.url',
8585
},
8686
],
87+
isGated: false,
88+
isRestricted: false,
8789
},
8890
{
8991
vToken: vUsdc,
@@ -180,6 +182,8 @@ export const assetData: Asset[] = [
180182
],
181183
supplyPointDistributions: [],
182184
borrowPointDistributions: [],
185+
isRestricted: false,
186+
isGated: false,
183187
},
184188
{
185189
vToken: vUsdtCorePool,
@@ -272,6 +276,8 @@ export const assetData: Asset[] = [
272276
extraInfoUrl: 'https://fake.url',
273277
},
274278
],
279+
isGated: true,
280+
isRestricted: false,
275281
},
276282
{
277283
vToken: vBusdCorePool,
@@ -376,5 +382,7 @@ export const assetData: Asset[] = [
376382
},
377383
],
378384
borrowPointDistributions: [],
385+
isGated: false,
386+
isRestricted: true,
379387
},
380388
];

apps/evm/src/__mocks__/models/trade.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,21 @@ import fakeAddress, { altAddress } from './address';
66
import { poolData } from './pools';
77

88
const pool = poolData[0];
9-
const xvsAsset = pool.assets[0];
10-
const usdcAsset = pool.assets[1];
11-
const usdtAsset = pool.assets[2];
12-
const busdAsset = pool.assets[3];
9+
const tradePool = {
10+
...pool,
11+
assets: pool.assets.map(asset =>
12+
asset.vToken.address === pool.assets[3].vToken.address
13+
? {
14+
...asset,
15+
isRestricted: false,
16+
}
17+
: asset,
18+
),
19+
};
20+
const xvsAsset = tradePool.assets[0];
21+
const usdcAsset = tradePool.assets[1];
22+
const usdtAsset = tradePool.assets[2];
23+
const busdAsset = tradePool.assets[3];
1324

1425
export const apiTradePositions: ApiTradePosition[] = [
1526
{
@@ -109,7 +120,7 @@ export const apiTradePositions: ApiTradePosition[] = [
109120

110121
export const tradePositions: TradePosition[] = [
111122
formatToTradePosition({
112-
pool,
123+
pool: tradePool,
113124
chainId: busdAsset.vToken.underlyingToken.chainId,
114125
positionAccountAddress: fakeAddress,
115126
dsaVTokenAddress: xvsAsset.vToken.address,
@@ -128,7 +139,7 @@ export const tradePositions: TradePosition[] = [
128139
unrealizedPnlPercentage: 0,
129140
})!,
130141
formatToTradePosition({
131-
pool,
142+
pool: tradePool,
132143
chainId: busdAsset.vToken.underlyingToken.chainId,
133144
positionAccountAddress: altAddress,
134145
dsaVTokenAddress: usdcAsset.vToken.address,
@@ -147,7 +158,7 @@ export const tradePositions: TradePosition[] = [
147158
unrealizedPnlPercentage: 1.2,
148159
})!,
149160
formatToTradePosition({
150-
pool,
161+
pool: tradePool,
151162
chainId: usdtAsset.vToken.underlyingToken.chainId,
152163
positionAccountAddress: altAddress,
153164
dsaVTokenAddress: usdcAsset.vToken.address,

apps/evm/src/clients/api/__mocks__/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,17 @@ export const useGetXvsVaultUserPendingWithdrawalsFromBeforeUpgrade = vi.fn(() =>
233233
}),
234234
);
235235

236+
export const getIpLocation = vi.fn(async () => ({
237+
countryCode: 'US',
238+
}));
239+
export const useGetIpLocation = vi.fn((options?: Partial<QueryObserverOptions>) =>
240+
useQuery({
241+
queryKey: [FunctionKey.GET_IP_LOCATION],
242+
queryFn: getIpLocation,
243+
...options,
244+
}),
245+
);
246+
236247
export const useGetPools = vi.fn(() => ({
237248
isLoading: false,
238249
data: {

apps/evm/src/clients/api/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export * from './queries/getVenusVaiVaultDailyRate/useGetVenusVaiVaultDailyRate'
8686
export * from './queries/useGetAsset';
8787

8888
export * from './queries/useGetPools';
89+
export * from './queries/useGetIpLocation';
8990

9091
export * from './queries/useGetPool';
9192

apps/evm/src/clients/api/queries/getPendingRewards/getApiTokenPrice/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
1-
import type { ChainId } from 'types';
1+
import type { ApiTokenPrice, ChainId } from 'types';
22
import { restService } from 'utilities';
33
import type { Address } from 'viem';
4-
import type { ApiTokenPrice } from '../../useGetPools/getPools/getApiPools';
54

65
export interface GetApiTokenPriceInput {
76
tokenAddresses: string[];

apps/evm/src/clients/api/queries/getRawTradePositions/__tests__/index.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ import { logError } from 'libs/errors';
1010
import { ChainId } from 'types';
1111
import { formatToTradePosition, restService } from 'utilities';
1212
import { type GetRawTradePositionsInput, getRawTradePositions } from '..';
13-
import { getPools } from '../../useGetPools/getPools';
13+
import { getPools } from '../../useGetPools/useGetPoolsQuery/getPools';
1414

1515
vi.mock('utilities/restService');
16-
vi.mock('../../useGetPools/getPools', () => ({
16+
vi.mock('../../useGetPools/useGetPoolsQuery/getPools', () => ({
1717
getPools: vi.fn(),
1818
}));
1919
vi.mock('libs/errors', async () => {

apps/evm/src/clients/api/queries/getRawTradePositions/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
formatToTradePosition,
99
restService,
1010
} from 'utilities';
11-
import { getPools } from '../useGetPools/getPools';
11+
import { getPools } from '../useGetPools/useGetPoolsQuery/getPools';
1212
import type {
1313
GetApiTradePositionsOutput,
1414
GetRawTradePositionsInput,

apps/evm/src/clients/api/queries/getSimulatedPool/__tests__/__snapshots__/index.spec.ts.snap

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,9 @@ exports[`getSimulatedPool > recalculates Prime APYs when a Prime market is mutat
4242
"isBorrowable": true,
4343
"isBorrowableByUser": true,
4444
"isCollateralOfUser": true,
45+
"isGated": false,
4546
"isProtectionModeEnabled": false,
47+
"isRestricted": false,
4648
"liquidationPenaltyPercentage": 4,
4749
"liquidationThresholdPercentage": 50,
4850
"liquidityCents": "8036465875",
@@ -168,7 +170,9 @@ exports[`getSimulatedPool > recalculates Prime APYs when a Prime market is mutat
168170
"isBorrowable": false,
169171
"isBorrowableByUser": false,
170172
"isCollateralOfUser": false,
173+
"isGated": false,
171174
"isProtectionModeEnabled": false,
175+
"isRestricted": false,
172176
"liquidationPenaltyPercentage": 4,
173177
"liquidationThresholdPercentage": 80,
174178
"liquidityCents": "1702951959",
@@ -310,7 +314,9 @@ exports[`getSimulatedPool > recalculates Prime APYs when a Prime market is mutat
310314
"isBorrowable": true,
311315
"isBorrowableByUser": true,
312316
"isCollateralOfUser": true,
317+
"isGated": true,
313318
"isProtectionModeEnabled": false,
319+
"isRestricted": false,
314320
"liquidationPenaltyPercentage": 4,
315321
"liquidationThresholdPercentage": 80,
316322
"liquidityCents": "5534102886",
@@ -444,7 +450,9 @@ exports[`getSimulatedPool > recalculates Prime APYs when a Prime market is mutat
444450
"isBorrowable": true,
445451
"isBorrowableByUser": true,
446452
"isCollateralOfUser": false,
453+
"isGated": false,
447454
"isProtectionModeEnabled": false,
455+
"isRestricted": true,
448456
"liquidationPenaltyPercentage": 4,
449457
"liquidationThresholdPercentage": 80,
450458
"liquidityCents": "3654492935",
@@ -794,7 +802,9 @@ exports[`getSimulatedPool > returns simulated pool with updated asset balances w
794802
"isBorrowable": true,
795803
"isBorrowableByUser": true,
796804
"isCollateralOfUser": true,
805+
"isGated": false,
797806
"isProtectionModeEnabled": false,
807+
"isRestricted": false,
798808
"liquidationPenaltyPercentage": 4,
799809
"liquidationThresholdPercentage": 50,
800810
"liquidityCents": "8036465875",
@@ -920,7 +930,9 @@ exports[`getSimulatedPool > returns simulated pool with updated asset balances w
920930
"isBorrowable": false,
921931
"isBorrowableByUser": false,
922932
"isCollateralOfUser": false,
933+
"isGated": false,
923934
"isProtectionModeEnabled": false,
935+
"isRestricted": false,
924936
"liquidationPenaltyPercentage": 4,
925937
"liquidationThresholdPercentage": 80,
926938
"liquidityCents": "1702951959",
@@ -1062,7 +1074,9 @@ exports[`getSimulatedPool > returns simulated pool with updated asset balances w
10621074
"isBorrowable": true,
10631075
"isBorrowableByUser": true,
10641076
"isCollateralOfUser": true,
1077+
"isGated": true,
10651078
"isProtectionModeEnabled": false,
1079+
"isRestricted": false,
10661080
"liquidationPenaltyPercentage": 4,
10671081
"liquidationThresholdPercentage": 80,
10681082
"liquidityCents": "5534102886",
@@ -1196,7 +1210,9 @@ exports[`getSimulatedPool > returns simulated pool with updated asset balances w
11961210
"isBorrowable": true,
11971211
"isBorrowableByUser": true,
11981212
"isCollateralOfUser": false,
1213+
"isGated": false,
11991214
"isProtectionModeEnabled": false,
1215+
"isRestricted": true,
12001216
"liquidationPenaltyPercentage": 4,
12011217
"liquidationThresholdPercentage": 80,
12021218
"liquidityCents": "3654492935",
@@ -1546,7 +1562,9 @@ exports[`getSimulatedPool > returns simulated pool with updated asset balances w
15461562
"isBorrowable": true,
15471563
"isBorrowableByUser": true,
15481564
"isCollateralOfUser": true,
1565+
"isGated": false,
15491566
"isProtectionModeEnabled": false,
1567+
"isRestricted": false,
15501568
"liquidationPenaltyPercentage": 4,
15511569
"liquidationThresholdPercentage": 50,
15521570
"liquidityCents": "8036465875",
@@ -1672,7 +1690,9 @@ exports[`getSimulatedPool > returns simulated pool with updated asset balances w
16721690
"isBorrowable": false,
16731691
"isBorrowableByUser": false,
16741692
"isCollateralOfUser": true,
1693+
"isGated": false,
16751694
"isProtectionModeEnabled": false,
1695+
"isRestricted": false,
16761696
"liquidationPenaltyPercentage": 4,
16771697
"liquidationThresholdPercentage": 80,
16781698
"liquidityCents": "1702951959",
@@ -1814,7 +1834,9 @@ exports[`getSimulatedPool > returns simulated pool with updated asset balances w
18141834
"isBorrowable": true,
18151835
"isBorrowableByUser": true,
18161836
"isCollateralOfUser": true,
1837+
"isGated": true,
18171838
"isProtectionModeEnabled": false,
1839+
"isRestricted": false,
18181840
"liquidationPenaltyPercentage": 4,
18191841
"liquidationThresholdPercentage": 80,
18201842
"liquidityCents": "5534102886",
@@ -1948,7 +1970,9 @@ exports[`getSimulatedPool > returns simulated pool with updated asset balances w
19481970
"isBorrowable": true,
19491971
"isBorrowableByUser": true,
19501972
"isCollateralOfUser": false,
1973+
"isGated": false,
19511974
"isProtectionModeEnabled": false,
1975+
"isRestricted": true,
19521976
"liquidationPenaltyPercentage": 4,
19531977
"liquidationThresholdPercentage": 80,
19541978
"liquidityCents": "3654492935",
@@ -2310,7 +2334,9 @@ exports[`getSimulatedPool > updates simulated VAI borrow balances when VAI mutat
23102334
"isBorrowable": true,
23112335
"isBorrowableByUser": true,
23122336
"isCollateralOfUser": true,
2337+
"isGated": false,
23132338
"isProtectionModeEnabled": false,
2339+
"isRestricted": false,
23142340
"liquidationPenaltyPercentage": 4,
23152341
"liquidationThresholdPercentage": 50,
23162342
"liquidityCents": "8036465875",
@@ -2436,7 +2462,9 @@ exports[`getSimulatedPool > updates simulated VAI borrow balances when VAI mutat
24362462
"isBorrowable": false,
24372463
"isBorrowableByUser": false,
24382464
"isCollateralOfUser": false,
2465+
"isGated": false,
24392466
"isProtectionModeEnabled": false,
2467+
"isRestricted": false,
24402468
"liquidationPenaltyPercentage": 4,
24412469
"liquidationThresholdPercentage": 80,
24422470
"liquidityCents": "1702951959",
@@ -2578,7 +2606,9 @@ exports[`getSimulatedPool > updates simulated VAI borrow balances when VAI mutat
25782606
"isBorrowable": true,
25792607
"isBorrowableByUser": true,
25802608
"isCollateralOfUser": true,
2609+
"isGated": true,
25812610
"isProtectionModeEnabled": false,
2611+
"isRestricted": false,
25822612
"liquidationPenaltyPercentage": 4,
25832613
"liquidationThresholdPercentage": 80,
25842614
"liquidityCents": "5534102886",
@@ -2712,7 +2742,9 @@ exports[`getSimulatedPool > updates simulated VAI borrow balances when VAI mutat
27122742
"isBorrowable": true,
27132743
"isBorrowableByUser": true,
27142744
"isCollateralOfUser": false,
2745+
"isGated": false,
27152746
"isProtectionModeEnabled": false,
2747+
"isRestricted": true,
27162748
"liquidationPenaltyPercentage": 4,
27172749
"liquidationThresholdPercentage": 80,
27182750
"liquidityCents": "3654492935",

0 commit comments

Comments
 (0)