Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"@aave/react": "^0.8.2",
"@amplitude/analytics-browser": "^2.13.0",
"@bgd-labs/aave-address-book": "^4.44.22",
"@cowprotocol/cow-sdk": "7.3.4",
"@cowprotocol/cow-sdk": "7.3.8",
Comment thread
mgrabina marked this conversation as resolved.
"@cowprotocol/sdk-ethers-v5-adapter": "0.3.5",
"@cowprotocol/sdk-flash-loans": "1.7.4",
"@emotion/cache": "11.10.3",
Expand Down
20 changes: 12 additions & 8 deletions src/components/transactions/Swap/helpers/cow/rates.helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -194,17 +194,19 @@ export async function getCowProtocolSellRates({

if (invertedQuoteRoute) {
// Calculate Amounts
// Note: beforeNetworkCosts/afterNetworkCosts were swapped in cow-sdk v7.3.5+
// (sdk-order-book v1.0.0) to fix a naming bug where the semantics were inverted.
const srcSpotAmount =
side === 'sell'
? orderBookQuote.quoteResults.amountsAndCosts.beforeNetworkCosts.buyAmount.toString()
: orderBookQuote.quoteResults.amountsAndCosts.afterNetworkCosts.buyAmount.toString();
? orderBookQuote.quoteResults.amountsAndCosts.afterNetworkCosts.buyAmount.toString()
: orderBookQuote.quoteResults.amountsAndCosts.beforeNetworkCosts.buyAmount.toString();
const srcSpotUSD = BigNumber(destTokenPriceUsd)
.multipliedBy(BigNumber(srcSpotAmount).dividedBy(10 ** destDecimals))
.toString();
const destSpotAmount =
side === 'sell'
? orderBookQuote.quoteResults.amountsAndCosts.afterNetworkCosts.sellAmount.toString()
: orderBookQuote.quoteResults.amountsAndCosts.beforeNetworkCosts.sellAmount.toString();
? orderBookQuote.quoteResults.amountsAndCosts.beforeNetworkCosts.sellAmount.toString()
: orderBookQuote.quoteResults.amountsAndCosts.afterNetworkCosts.sellAmount.toString();
const destSpotUSD = BigNumber(srcTokenPriceUsd)
.multipliedBy(BigNumber(destSpotAmount).dividedBy(10 ** srcDecimals))
.toString();
Expand Down Expand Up @@ -236,17 +238,19 @@ export async function getCowProtocolSellRates({
};
} else {
// Calculate Amounts
// Note: beforeNetworkCosts/afterNetworkCosts were swapped in cow-sdk v7.3.5+
// (sdk-order-book v1.0.0) to fix a naming bug where the semantics were inverted.
const srcSpotAmount =
orderBookQuote.quoteResults.orderToSign.kind === OrderKind.SELL
? orderBookQuote.quoteResults.amountsAndCosts.afterNetworkCosts.sellAmount.toString()
: orderBookQuote.quoteResults.amountsAndCosts.beforeNetworkCosts.sellAmount.toString();
? orderBookQuote.quoteResults.amountsAndCosts.beforeNetworkCosts.sellAmount.toString()
: orderBookQuote.quoteResults.amountsAndCosts.afterNetworkCosts.sellAmount.toString();
Comment thread
mgrabina marked this conversation as resolved.
Outdated
const srcSpotUSD = BigNumber(srcTokenPriceUsd)
.multipliedBy(BigNumber(srcSpotAmount).dividedBy(10 ** srcDecimals))
.toString();
const destSpotAmount =
orderBookQuote.quoteResults.orderToSign.kind === OrderKind.SELL
? orderBookQuote.quoteResults.amountsAndCosts.beforeNetworkCosts.buyAmount.toString()
: orderBookQuote.quoteResults.amountsAndCosts.afterNetworkCosts.buyAmount.toString();
? orderBookQuote.quoteResults.amountsAndCosts.afterNetworkCosts.buyAmount.toString()
: orderBookQuote.quoteResults.amountsAndCosts.beforeNetworkCosts.buyAmount.toString();
const destSpotUSD = BigNumber(destTokenPriceUsd)
.multipliedBy(BigNumber(destSpotAmount).dividedBy(10 ** destDecimals))
.toString();
Expand Down
Loading