Skip to content

Commit 373d73b

Browse files
committed
fix(predict): skip allowancesTx when Safe fee auth is used to avoid nonce conflict
Both createSafeFeeAuthorization and getProxyWalletAllowancesTransaction read the same on-chain Safe nonce. If both execute in the same placeOrder call, the relay invalidates one when executing the other. Guard the allowancesTx block with hasSafeFeeAuth to skip it when a Safe fee authorization was already signed. Also remove unused fees param from setupAllowancesTxTest helper.
1 parent 6e73c71 commit 373d73b

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

app/components/UI/Predict/providers/polymarket/PolymarketProvider.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2023,7 +2023,6 @@ describe('PolymarketProvider', () => {
20232023
permit2Enabled?: boolean;
20242024
hasAllowances?: boolean;
20252025
executors?: string[];
2026-
fees?: typeof Side;
20272026
}) {
20282027
const result = setupPlaceOrderTest({
20292028
feeCollection: {

app/components/UI/Predict/providers/polymarket/PolymarketProvider.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1233,15 +1233,21 @@ export class PolymarketProvider implements PredictProvider {
12331233
}
12341234
}
12351235

1236+
let allowancesTx: { to: string; data: string } | undefined;
1237+
let permit2AllowanceReady = false;
1238+
12361239
// When Permit2 is enabled via feature flags, ensure the proxy wallet
12371240
// has the required allowances. If not, generate a signed Safe TX that
12381241
// the relay will submit on-chain before processing the order.
12391242
// This uses the feature flag (not per-order fees) so it works for
12401243
// both BUY orders (with fees) and SELL orders (no fees).
1241-
let allowancesTx: { to: string; data: string } | undefined;
1242-
let permit2AllowanceReady = false;
1244+
//
1245+
// IMPORTANT: Skip when a Safe fee authorization was already signed,
1246+
// because both transactions read the same on-chain Safe nonce and
1247+
// the relay would invalidate one when executing the other.
1248+
const hasSafeFeeAuth = feeAuthorization !== undefined && !permit2FeeReady;
12431249

1244-
if (feeCollection.permit2Enabled) {
1250+
if (feeCollection.permit2Enabled && !hasSafeFeeAuth) {
12451251
try {
12461252
const accountState = await this.getAccountState({
12471253
ownerAddress: signer.address,

0 commit comments

Comments
 (0)