Skip to content

Commit 5d66bd4

Browse files
committed
feat(predict): remove CLOB v1 support and migrate to pUSD
1 parent dfa3014 commit 5d66bd4

41 files changed

Lines changed: 1001 additions & 17522 deletions

Some content is hidden

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

app/components/UI/Predict/controllers/PredictController.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5721,7 +5721,6 @@ describe('PredictController', () => {
57215721
const mockAccountState = {
57225722
address: '0xProxyAddress' as `0x${string}`,
57235723
isDeployed: true,
5724-
hasAllowances: true,
57255724
balance: 100.5,
57265725
};
57275726

app/components/UI/Predict/controllers/PredictController.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ import { GEO_BLOCKED_COUNTRIES } from '../constants/geoblock';
5757
import { PREDICT_BALANCE_PLACEHOLDER_ADDRESS } from '../constants/transactions';
5858
import { PolymarketProvider } from '../providers/polymarket/PolymarketProvider';
5959
import {
60-
MATIC_CONTRACTS,
60+
MATIC_CONTRACTS_V2,
6161
POLYMARKET_PROVIDER_ID,
6262
} from '../providers/polymarket/constants';
6363
import { Signer } from '../providers/types';
@@ -1402,7 +1402,7 @@ export class PredictController extends BaseController<
14021402
disableHook: true,
14031403
disableSequential: true,
14041404
// Temporarily breaking abstraction, can instead be abstracted via provider.
1405-
gasFeeToken: MATIC_CONTRACTS.collateral as Hex,
1405+
gasFeeToken: MATIC_CONTRACTS_V2.collateral as Hex,
14061406
transactions,
14071407
});
14081408

@@ -2456,7 +2456,7 @@ export class PredictController extends BaseController<
24562456
disableSequential: true,
24572457
requireApproval: true,
24582458
// Temporarily breaking abstraction, can instead be abstracted via provider.
2459-
gasFeeToken: MATIC_CONTRACTS.collateral as Hex,
2459+
gasFeeToken: MATIC_CONTRACTS_V2.collateral as Hex,
24602460
transactions: [transaction],
24612461
});
24622462

app/components/UI/Predict/hooks/usePredictAccountState.test.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ describe('usePredictAccountState', () => {
6363
const mockAccountState = {
6464
address: '0x1234567890abcdef1234567890abcdef12345678',
6565
isDeployed: true,
66-
hasAllowances: true,
6766
};
6867

6968
beforeEach(() => {
@@ -117,7 +116,6 @@ describe('usePredictAccountState', () => {
117116
expect(mockGetAccountState).toHaveBeenCalledWith({});
118117
expect(result.current.data?.address).toEqual(mockAccountState.address);
119118
expect(result.current.data?.isDeployed).toBe(true);
120-
expect(result.current.data?.hasAllowances).toBe(true);
121119
expect(result.current.error).toBeNull();
122120
});
123121

@@ -215,24 +213,6 @@ describe('usePredictAccountState', () => {
215213
expect(result.current.data?.isDeployed).toBe(false);
216214
});
217215

218-
it('returns hasAllowances as false when account lacks allowances', async () => {
219-
const { Wrapper } = createWrapper();
220-
mockGetAccountState.mockResolvedValue({
221-
...mockAccountState,
222-
hasAllowances: false,
223-
});
224-
225-
const { result } = renderHook(() => usePredictAccountState(), {
226-
wrapper: Wrapper,
227-
});
228-
229-
await waitFor(() => {
230-
expect(result.current.data).toBeDefined();
231-
});
232-
233-
expect(result.current.data?.hasAllowances).toBe(false);
234-
});
235-
236216
it('has undefined data when query is disabled', () => {
237217
const { Wrapper } = createWrapper();
238218
const { result } = renderHook(

app/components/UI/Predict/hooks/usePredictAccountState.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ interface UsePredictAccountStateOptions {
1515
}
1616

1717
/**
18-
* Fetches the Predict account state (address, deployment status, allowances).
18+
* Fetches the Predict account state (address and deployment status).
1919
*/
2020
export function usePredictAccountState(
2121
options: UsePredictAccountStateOptions = {},

app/components/UI/Predict/hooks/usePredictBalanceTokenFilter.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ describe('usePredictBalanceTokenFilter', () => {
7878
mockPredictBalance = 100;
7979
mockTransactionMeta = null;
8080
mockHasTransactionType.mockReturnValue(false);
81-
mockUseSelector.mockReturnValue({ image: 'usdce-token-image' });
81+
mockUseSelector.mockReturnValue({ image: 'pusd-token-image' });
8282
});
8383

8484
it('returns original tokens when transaction type does not match and forceEnabled is false', () => {
@@ -178,17 +178,17 @@ describe('usePredictBalanceTokenFilter', () => {
178178
expect(filteredTokens[0].chainId).toBe(PREDICT_BALANCE_CHAIN_ID);
179179
});
180180

181-
it('sets symbol to USDC.e on the Predict balance token', () => {
181+
it('sets symbol to pUSD on the Predict balance token', () => {
182182
mockHasTransactionType.mockReturnValue(true);
183183
const tokens = [createMockToken()];
184184

185185
const { result } = renderHook(() => usePredictBalanceTokenFilter());
186186
const filteredTokens = result.current(tokens);
187187

188-
expect(filteredTokens[0].symbol).toBe('USDC.e');
188+
expect(filteredTokens[0].symbol).toBe('pUSD');
189189
});
190190

191-
it('uses empty string for image when usdceToken is null', () => {
191+
it('uses empty string for image when pusdToken is null', () => {
192192
mockHasTransactionType.mockReturnValue(true);
193193
mockUseSelector.mockReturnValue(null);
194194
const tokens = [createMockToken()];

app/components/UI/Predict/hooks/usePredictBalanceTokenFilter.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { RootState } from '../../../../reducers';
55
import { selectSingleTokenByAddressAndChainId } from '../../../../selectors/tokensController';
66
import { getNetworkImageSource } from '../../../../util/networks';
77
import useFiatFormatter from '../../SimulationDetails/FiatDisplay/useFiatFormatter';
8-
import { POLYGON_USDCE } from '../../../Views/confirmations/constants/predict';
8+
import { POLYGON_PUSD } from '../../../Views/confirmations/constants/predict';
99
import { TransactionType } from '@metamask/transaction-controller';
1010
import { useTransactionMetadataRequest } from '../../../Views/confirmations/hooks/transactions/useTransactionMetadataRequest';
1111
import { AssetType } from '../../../Views/confirmations/types/token';
@@ -24,10 +24,10 @@ export function usePredictBalanceTokenFilter(
2424
const { isPredictBalanceSelected } = usePredictPaymentToken();
2525
const { data: predictBalance = 0 } = usePredictBalance();
2626
const formatFiat = useFiatFormatter({ currency: 'usd' });
27-
const usdceToken = useSelector((state: RootState) =>
27+
const pusdToken = useSelector((state: RootState) =>
2828
selectSingleTokenByAddressAndChainId(
2929
state,
30-
POLYGON_USDCE.address,
30+
POLYGON_PUSD.address,
3131
PREDICT_BALANCE_CHAIN_ID,
3232
),
3333
);
@@ -51,11 +51,11 @@ export function usePredictBalanceTokenFilter(
5151
chainId: PREDICT_BALANCE_CHAIN_ID,
5252
tokenId: PREDICT_BALANCE_PLACEHOLDER_ADDRESS,
5353
name: 'Predict balance',
54-
symbol: 'USDC.e',
54+
symbol: POLYGON_PUSD.symbol,
5555
balance: balanceStr,
5656
balanceInSelectedCurrency: balanceFormatted,
57-
image: usdceToken?.image ?? '',
58-
logo: usdceToken?.image ?? '',
57+
image: pusdToken?.image ?? '',
58+
logo: pusdToken?.image ?? '',
5959
networkBadgeSource: getNetworkImageSource({
6060
chainId: PREDICT_BALANCE_CHAIN_ID,
6161
}),
@@ -81,7 +81,7 @@ export function usePredictBalanceTokenFilter(
8181
isPredictBalanceSelected,
8282
predictBalance,
8383
formatFiat,
84-
usdceToken,
84+
pusdToken,
8585
],
8686
);
8787
}

app/components/UI/Predict/hooks/usePredictRewards.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Logger from '../../../../util/Logger';
77
import { getFormattedAddressFromInternalAccount } from '../../../../core/Multichain/utils';
88
import {
99
POLYGON_MAINNET_CAIP_CHAIN_ID,
10-
POLYGON_USDC_CAIP_ASSET_ID,
10+
POLYGON_PUSD_CAIP_ASSET_ID,
1111
} from '../providers/polymarket/constants';
1212

1313
jest.mock('react-redux', () => ({
@@ -47,8 +47,8 @@ jest.mock('../constants/errors', () => ({
4747

4848
jest.mock('../providers/polymarket/constants', () => ({
4949
POLYGON_MAINNET_CAIP_CHAIN_ID: 'eip155:137',
50-
POLYGON_USDC_CAIP_ASSET_ID:
51-
'eip155:137/erc20:0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174',
50+
POLYGON_PUSD_CAIP_ASSET_ID:
51+
'eip155:137/erc20:0xC011a7E12a19f7B1f670d46F03B03f3342E82DFB',
5252
COLLATERAL_TOKEN_DECIMALS: 6,
5353
}));
5454

@@ -185,7 +185,7 @@ describe('usePredictRewards', () => {
185185
activityContext: {
186186
predictContext: {
187187
feeAsset: {
188-
id: POLYGON_USDC_CAIP_ASSET_ID,
188+
id: POLYGON_PUSD_CAIP_ASSET_ID,
189189
amount: expect.any(String),
190190
},
191191
},

app/components/UI/Predict/hooks/usePredictRewards.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { selectSelectedInternalAccountByScope } from '../../../../selectors/mult
1717
import { getFormattedAddressFromInternalAccount } from '../../../../core/Multichain/utils';
1818
import {
1919
POLYGON_MAINNET_CAIP_CHAIN_ID,
20-
POLYGON_USDC_CAIP_ASSET_ID,
20+
POLYGON_PUSD_CAIP_ASSET_ID,
2121
COLLATERAL_TOKEN_DECIMALS,
2222
} from '../providers/polymarket/constants';
2323
import { parseUnits } from 'ethers/lib/utils';
@@ -186,9 +186,9 @@ export const usePredictRewards = (
186186
}
187187

188188
// Prepare fee asset
189-
// Convert USD amount to atomic units (6 decimals for USDC)
189+
// Convert USD amount to atomic units (6 decimals for pUSD)
190190
const feeAsset: EstimateAssetDto = {
191-
id: POLYGON_USDC_CAIP_ASSET_ID,
191+
id: POLYGON_PUSD_CAIP_ASSET_ID,
192192
amount: parseUnits(
193193
totalFeeAmountUsd.toString(),
194194
COLLATERAL_TOKEN_DECIMALS,

0 commit comments

Comments
 (0)