Skip to content

Commit 752f37a

Browse files
committed
misc fixes
1 parent 6871e49 commit 752f37a

File tree

8 files changed

+25
-6
lines changed

8 files changed

+25
-6
lines changed

src/components/transactions/Swap/constants/cow.constants.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { OrderClass, SupportedChainId } from '@cowprotocol/cow-sdk';
1+
import { CowEnv, OrderClass, SupportedChainId } from '@cowprotocol/cow-sdk';
22

33
import { getAssetGroup } from '../helpers/shared/assetCorrelation.helpers';
44
import { OrderType, SwapType } from '../types';
@@ -65,6 +65,12 @@ export const isChainIdSupportedByCoWProtocol = (chainId: number): chainId is Sup
6565
export const COW_EVM_RECIPIENT = '0xC542C2F197c4939154017c802B0583C596438380';
6666
// export const COW_LENS_RECIPIENT = '0xce4eB8a1f6Bd0e0B9282102DC056B11E9D83b7CA';
6767
export const COW_PROTOCOL_ETH_FLOW_ADDRESS = '0xbA3cB449bD2B4ADddBc894D8697F5170800EAdeC';
68+
export const COW_PROTOCOL_ETH_FLOW_ADDRESS_STAGING = '0x04501b9b1D52e67f6862d157E00D13419D2D6E95';
69+
70+
export const COW_PROTOCOL_ETH_FLOW_ADDRESS_BY_ENV = (env: CowEnv) => {
71+
return env === 'staging' ? COW_PROTOCOL_ETH_FLOW_ADDRESS_STAGING : COW_PROTOCOL_ETH_FLOW_ADDRESS;
72+
};
73+
6874
export const COW_CREATE_ORDER_ABI =
6975
'function createOrder((address,address,uint256,uint256,bytes32,uint256,uint32,bool,int64)) returns (bytes32)';
7076

src/components/transactions/Swap/helpers/cow/orders.helpers.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ import { SignedParams } from '../../actions/approval/useSwapTokenApproval';
2323
import {
2424
COW_APP_DATA,
2525
COW_CREATE_ORDER_ABI,
26-
COW_PROTOCOL_ETH_FLOW_ADDRESS,
26+
COW_PROTOCOL_ETH_FLOW_ADDRESS_BY_ENV,
2727
isChainIdSupportedByCoWProtocol,
2828
} from '../../constants/cow.constants';
2929
import { OrderType, SwapType } from '../../types';
@@ -112,6 +112,7 @@ export const getPreSignTransaction = async ({
112112
sellTokenDecimals: tokenSrcDecimals,
113113
buyTokenDecimals: tokenDestDecimals,
114114
owner: user as `0x${string}`,
115+
env: COW_ENV,
115116
},
116117
{
117118
appData: COW_APP_DATA(
@@ -209,6 +210,7 @@ export const sendOrder = async ({
209210
sellTokenDecimals: tokenSrcDecimals,
210211
buyTokenDecimals: tokenDestDecimals,
211212
owner: user as `0x${string}`,
213+
env: COW_ENV,
212214
},
213215
{
214216
appData,
@@ -377,7 +379,7 @@ export const populateEthFlowTx = async (
377379
]);
378380

379381
return {
380-
to: COW_PROTOCOL_ETH_FLOW_ADDRESS,
382+
to: COW_PROTOCOL_ETH_FLOW_ADDRESS_BY_ENV(COW_ENV),
381383
value,
382384
data,
383385
};

src/components/transactions/Swap/hooks/useSlippageSelector.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export const useSlippageSelector = ({
3535
}
3636
} else if (state.orderType === OrderType.MARKET) {
3737
// Restore to suggested slippage if available, otherwise last known market slippage, else default 0.10%
38-
const target = lastMarketSlippageRef.current || state.autoSlippage;
38+
const target = lastMarketSlippageRef.current || state.autoSlippage || '0.10';
3939
if (state.slippage !== target) {
4040
setState({ slippage: target });
4141
}

src/components/transactions/Swap/hooks/useSwapQuote.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ export const useSwapQuote = ({
195195
setState({
196196
provider,
197197
swapRate: undefined, // Clear the old swap rate to force new quote
198+
autoSlippage: '', // Clear suggested slippage until a new quote arrives
198199
quoteRefreshPaused: false, // Ensure quotes can be fetched
199200
});
200201
}

src/components/transactions/Swap/inputs/MarketOrderInputs.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ export const MarketOrderInputs = ({
8989
warnings: [],
9090
quoteRefreshPaused: true,
9191
quoteLastUpdatedAt: undefined,
92+
autoSlippage: '',
9293
})
9394
}
9495
usdValue={state.inputAmountUSD.toString() || '0'}

src/components/transactions/Swap/inputs/SwapInputs.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ export const SwapInputs = ({
206206
swapRate: undefined,
207207
actionsLoading: false,
208208
slippage: '0.1',
209+
autoSlippage: '',
209210
actionsBlocked: false,
210211
error: undefined,
211212
warnings: [],
@@ -266,6 +267,7 @@ export const SwapInputs = ({
266267
quoteRefreshPaused: false,
267268
quoteTimerPausedAt: undefined,
268269
quoteTimerPausedAccumMs: undefined,
270+
autoSlippage: '',
269271
error: undefined,
270272
warnings: [],
271273
actionsBlocked: false,
@@ -284,6 +286,7 @@ export const SwapInputs = ({
284286
quoteRefreshPaused: false,
285287
quoteTimerPausedAt: undefined,
286288
quoteTimerPausedAccumMs: undefined,
289+
autoSlippage: '',
287290
error: undefined,
288291
warnings: [],
289292
actionsBlocked: false,
@@ -316,6 +319,7 @@ export const SwapInputs = ({
316319
quoteRefreshPaused: false,
317320
quoteTimerPausedAt: undefined,
318321
quoteTimerPausedAccumMs: undefined,
322+
autoSlippage: '',
319323
error: undefined,
320324
warnings: [],
321325
actionsBlocked: false,
@@ -334,6 +338,7 @@ export const SwapInputs = ({
334338
quoteRefreshPaused: false,
335339
quoteTimerPausedAt: undefined,
336340
quoteTimerPausedAccumMs: undefined,
341+
autoSlippage: '',
337342
error: undefined,
338343
warnings: [],
339344
actionsBlocked: false,

src/components/transactions/Swap/inputs/primitives/SwapAssetInput.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,11 @@ export const SwitchAssetInput = ({
358358
open={openModal}
359359
setOpen={setOpenModal}
360360
contentMaxWidth={420}
361-
contentHeight={pickerHeight}
361+
minContentHeight={600}
362+
contentHeight={Math.max(
363+
pickerHeight ?? 0,
364+
mergedPopular.length && filteredAssets.length > 3 ? 600 : 0
365+
)}
362366
>
363367
<Box sx={{ display: 'flex', flexDirection: 'column', height: '100%' }}>
364368
<Typography variant="main16" sx={{ fontSize: 18, fontWeight: 600, mb: 3 }}>

src/components/transactions/Swap/types/state.types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ export const swapDefaultState: SwapState = {
250250
quoteTimerPausedAccumMs: 0,
251251
quoteRefreshPaused: false,
252252
slippage: '0.10',
253-
autoSlippage: '0.10',
253+
autoSlippage: '',
254254
gasLimit: '0',
255255
useFlashloan: undefined,
256256
slippageValidation: undefined,

0 commit comments

Comments
 (0)