Skip to content

Commit d341495

Browse files
committed
fixes
1 parent 4a320f9 commit d341495

26 files changed

+745
-553
lines changed

.npmrc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
@cowprotocol:registry=https://npm.pkg.github.com
2-
always-auth=true
3-
# registry=https://registry.npmjs.org/
4-
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}
1+
# @cowprotocol:registry=https://npm.pkg.github.com
2+
# always-auth=true
3+
# # registry=https://registry.npmjs.org/
4+
# //npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@
3636
"@aave/react": "0.6.1",
3737
"@amplitude/analytics-browser": "^2.13.0",
3838
"@bgd-labs/aave-address-book": "^4.31.0",
39-
"@cowprotocol/sdk-app-data": "4.1.3-pr-614-5b1d24e9.0",
40-
"@cowprotocol/cow-sdk": "7.0.10-pr-614-5b1d24e9.0",
41-
"@cowprotocol/sdk-flash-loans": "0.0.1-pr-614-5b1d24e9.0",
42-
"@cowprotocol/sdk-viem-adapter": "0.1.2-pr-614-5b1d24e9.0",
39+
"@cowprotocol/sdk-app-data": "4.1.4",
40+
"@cowprotocol/cow-sdk": "7.0.11",
41+
"@cowprotocol/sdk-flash-loans": "1.1.0",
42+
"@cowprotocol/sdk-viem-adapter": "0.1.3",
4343
"@emotion/cache": "11.10.3",
4444
"@emotion/react": "11.10.4",
4545
"@emotion/server": "latest",

src/components/transactions/Repay/CollateralRepayActions.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,26 @@ export const CollateralRepayActions = ({
6464
protocolAction: ProtocolAction.repayCollateral,
6565
handleGetTxns: async (signature, deadline) => {
6666
const route = await buildTxFn();
67+
68+
console.log('paraswapRepayWithCollateral', {
69+
repayAllDebt,
70+
repayAmount,
71+
rateMode,
72+
repayWithAmount,
73+
74+
fromAssetData,
75+
poolReserve,
76+
symbol,
77+
isWrongNetwork,
78+
useFlashLoan,
79+
blocked,
80+
swapCallData: route.swapCallData,
81+
augustus: route.augustus,
82+
signature,
83+
deadline,
84+
signedAmount: calculateSignedAmount(repayWithAmount, fromAssetData.decimals),
85+
});
86+
6787
return paraswapRepayWithCollateral({
6888
repayAllDebt,
6989
repayAmount,
@@ -83,6 +103,25 @@ export const CollateralRepayActions = ({
83103
});
84104
},
85105
handleGetApprovalTxns: async () => {
106+
console.log('paraswapRepayWithCollateral', {
107+
repayAllDebt,
108+
repayAmount,
109+
rateMode,
110+
repayWithAmount,
111+
112+
fromAssetData,
113+
poolReserve,
114+
symbol,
115+
isWrongNetwork,
116+
useFlashLoan,
117+
blocked,
118+
swapCallData: '0x',
119+
augustus: API_ETH_MOCK_ADDRESS,
120+
signature: '0x',
121+
deadline: '0',
122+
signedAmount: calculateSignedAmount(repayWithAmount, fromAssetData.decimals),
123+
});
124+
86125
return paraswapRepayWithCollateral({
87126
repayAllDebt,
88127
repayAmount,

src/components/transactions/Repay/CollateralRepayModalContent.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,13 @@ export function CollateralRepayModalContent({
257257
/>
258258
);
259259

260+
console.log('poolReserve', poolReserve.symbol, poolReserve.underlyingAsset);
261+
console.log(
262+
'collateralReserveData',
263+
collateralReserveData.symbol,
264+
collateralReserveData.underlyingAsset
265+
);
266+
260267
return (
261268
<>
262269
<AssetInput

src/components/transactions/Swap/actions/CollateralSwap/CollateralSwapActionsViaCoWAdapters.tsx

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { normalize } from '@aave/math-utils';
2-
import { getOrderToSign, LimitTradeParameters, OrderKind, TradingSdk } from '@cowprotocol/cow-sdk';
3-
import { AaveCollateralSwapSdk, HASH_ZERO } from '@cowprotocol/sdk-flash-loans';
2+
import { getOrderToSign, LimitTradeParameters, OrderKind } from '@cowprotocol/cow-sdk';
3+
import { AaveFlashLoanType, HASH_ZERO } from '@cowprotocol/sdk-flash-loans';
44
import { Trans } from '@lingui/macro';
55
import { Dispatch, useEffect, useState } from 'react';
66
import { TxActionsWrapper } from 'src/components/transactions/TxActionsWrapper';
@@ -12,7 +12,7 @@ import { useShallow } from 'zustand/react/shallow';
1212
import { TrackAnalyticsHandlers } from '../../analytics/useTrackAnalytics';
1313
import { COW_PARTNER_FEE, FLASH_LOAN_FEE_BPS } from '../../constants/cow.constants';
1414
import { APP_CODE_PER_SWAP_TYPE } from '../../constants/shared.constants';
15-
import { getCowAdapter } from '../../helpers/cow';
15+
import { getCowFlashLoanSdk, getCowTradingSdkByChainIdAndAppCode } from '../../helpers/cow';
1616
import { calculateInstanceAddress } from '../../helpers/cow/adapters.helpers';
1717
import { useSwapGasEstimation } from '../../hooks/useSwapGasEstimation';
1818
import { OrderType, SwapParams, SwapState } from '../../types';
@@ -45,7 +45,7 @@ export const CollateralSwapActionsViaCowAdapters = ({
4545
// Pre-compute instance address
4646
useEffect(() => {
4747
if (state.chainId !== 100) return; // TODO: remove this once we have a supported chainId
48-
calculateInstanceAddress(state, user, validTo)
48+
calculateInstanceAddress(state, user, validTo, AaveFlashLoanType.CollateralSwap)
4949
.catch((error) => {
5050
console.error('calculateInstanceAddress error', error);
5151
setTxError(getErrorTextFromError(error, TxAction.MAIN_ACTION, true));
@@ -106,18 +106,13 @@ export const CollateralSwapActionsViaCowAdapters = ({
106106
const sellAmount = normalize(state.inputAmount, -state.sourceToken.decimals);
107107
const buyAmount = normalize(state.minimumReceived, -state.destinationToken.decimals);
108108

109-
const adapter = await getCowAdapter(state.chainId);
110-
const tradingSdk = new TradingSdk(
111-
{
112-
chainId: state.chainId,
113-
appCode: APP_CODE_PER_SWAP_TYPE[state.swapType],
114-
env: 'staging',
115-
signer: adapter.signer,
116-
},
117-
{},
118-
adapter
109+
const tradingSdk = await getCowTradingSdkByChainIdAndAppCode(
110+
state.chainId,
111+
APP_CODE_PER_SWAP_TYPE[state.swapType],
112+
'staging'
119113
);
120-
const flashLoanSdk = new AaveCollateralSwapSdk();
114+
const flashLoanSdk = await getCowFlashLoanSdk(state.chainId);
115+
121116
const collateralPermit = signatureParams
122117
? {
123118
amount: signatureParams?.amount,
@@ -155,6 +150,7 @@ export const CollateralSwapActionsViaCowAdapters = ({
155150
);
156151

157152
const orderPostParams = await flashLoanSdk.getOrderPostingSettings(
153+
AaveFlashLoanType.CollateralSwap,
158154
{
159155
chainId: state.chainId,
160156
validTo,

src/components/transactions/Swap/actions/CollateralSwap/CollateralSwapActionsViaParaswapAdapters.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,10 @@ export const CollateralSwapActionsViaParaswapAdapters = ({
5959
if (!state.swapRate || !isParaswapRates(state.swapRate))
6060
throw new Error('Route required to build transaction');
6161

62+
setMainTxState({
63+
txHash: undefined,
64+
loading: true,
65+
});
6266
const isMaxSelected = state.isMaxSelected;
6367
const optimalRateData = state.swapRate.optimalRateData;
6468

@@ -186,7 +190,8 @@ export const CollateralSwapActionsViaParaswapAdapters = ({
186190
chainId: state.chainId,
187191
}
188192
);
189-
// TODO: fix success
193+
trackingHandlers.trackSwap(); // TODO: check this happening in all actions
194+
params.invalidateAppState(); // TODO: check this happening in all actions
190195
setMainTxState({
191196
txHash: response.hash,
192197
loading: false,

0 commit comments

Comments
 (0)