Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(twap): add recipient to summary in cancel modal #2904

Merged
merged 1 commit into from
Jul 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ const CancellationSummary = styled.span`
margin: 0;
border-radius: 6px;
background: ${({ theme }) => theme.grey1};
line-height: 1.6;
`

const OrderTypeDetails = styled.div`
Expand Down
18 changes: 16 additions & 2 deletions src/legacy/state/orders/updaters/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { EnrichedOrder, OrderKind } from '@cowprotocol/cow-sdk'
import { Order, OrderFulfillmentData, OrderStatus } from 'legacy/state/orders/actions'
import { classifyOrder, OrderTransitionStatus } from 'legacy/state/orders/utils'
import { stringToCurrency } from 'legacy/state/swap/extension'
import { shortenAddress } from 'legacy/utils'

import { getOrder, OrderID } from 'api/gnosisProtocol'
import { formatTokenAmount } from 'utils/amountFormat'
Expand All @@ -25,8 +26,17 @@ export function computeOrderSummary({
// if we can find the order from the API
// and our specific order exists in our state, let's use that
if (orderFromApi) {
const { buyToken, sellToken, sellAmount, feeAmount, buyAmount, executedBuyAmount, executedSellAmount } =
orderFromApi
const {
buyToken,
sellToken,
sellAmount,
feeAmount,
buyAmount,
executedBuyAmount,
executedSellAmount,
owner,
receiver,
} = orderFromApi

if (orderFromStore) {
const { inputToken, outputToken, status, kind } = orderFromStore
Expand All @@ -49,6 +59,10 @@ export function computeOrderSummary({
// We only have the API order info, let's at least use that
summary = `Swap ${sellToken} for ${buyToken}`
}

if (owner && receiver && receiver !== owner) {
summary += ` to ${shortenAddress(receiver)}`
nenadV91 marked this conversation as resolved.
Show resolved Hide resolved
}
} else {
console.log(`[state:orders:updater] computeFulfilledSummary::API data not yet in sync with blockchain`)
}
Expand Down
3 changes: 2 additions & 1 deletion src/modules/twap/utils/emulateTwapAsOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const statusMap: Record<TwapOrderStatus, OrderStatus> = {

export function emulateTwapAsOrder(item: TwapOrderItem): EnrichedOrder {
const { safeAddress, id, status, executionInfo } = item
const { sellToken, buyToken, partSellAmount, minPartLimit, n, t, appData } = item.order
const { sellToken, buyToken, partSellAmount, minPartLimit, n, t, appData, receiver } = item.order
const numOfParts = BigInt(n)
const sellAmountValue = BigInt(partSellAmount) * numOfParts
const buyAmount = BigInt(minPartLimit) * numOfParts
Expand Down Expand Up @@ -47,5 +47,6 @@ export function emulateTwapAsOrder(item: TwapOrderItem): EnrichedOrder {
executedBuyAmount,
executedFeeAmount,
invalidated: status === TwapOrderStatus.Cancelling,
receiver,
}
}
Loading