Skip to content
This repository has been archived by the owner on Jun 24, 2022. It is now read-only.

Orders panel execution price #1309

Merged
merged 5 commits into from
Aug 25, 2021
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
2 changes: 1 addition & 1 deletion src/custom/components/AccountDetails/Transaction/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ function ActivitySummary(params: {
const sellAmt = CurrencyAmount.fromRawAmount(inputToken, sellAmount.toString())
const feeAmt = CurrencyAmount.fromRawAmount(inputToken, feeAmount.toString())
const outputAmount = CurrencyAmount.fromRawAmount(outputToken, buyAmount.toString())
const buyTokenDecimals = order?.inputToken?.decimals ?? DEFAULT_PRECISION
const sellTokenDecimals = order?.inputToken?.decimals ?? DEFAULT_PRECISION
const buyTokenDecimals = order?.outputToken?.decimals ?? DEFAULT_PRECISION

const limitPrice = formatSmart(
getLimitPrice({
Expand Down
3 changes: 2 additions & 1 deletion src/custom/state/orders/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ export interface BaseOrder extends Omit<OrderCreation, 'signingScheme'> {
summary: string // for dapp use only, readable by user
isCancelling?: boolean // intermediate state while the order has been cancelled but order is still pending
isUnfillable?: boolean // whether the order is out of the market, due to price movements since placement
apiAdditionalInfo?: OrderInfoApi
}

/**
Expand All @@ -43,7 +44,6 @@ type OrderInfoApi = Pick<
export interface Order extends BaseOrder {
inputToken: Token // for dapp use only, readable by user
outputToken: Token // for dapp use only, readable by user
apiAdditionalInfo?: OrderInfoApi
}

export interface SerializedOrder extends BaseOrder {
Expand Down Expand Up @@ -80,6 +80,7 @@ export interface OrderFulfillmentData {
fulfillmentTime: string
transactionHash: string
summary?: string
apiAdditionalInfo?: OrderInfoApi
}

export interface FulfillOrdersBatchParams {
Expand Down
4 changes: 3 additions & 1 deletion src/custom/state/orders/reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export default createReducer(initialState, (builder) =>

// if there are any newly fulfilled orders
// update them
ordersData.forEach(({ id, fulfillmentTime, transactionHash }) => {
ordersData.forEach(({ id, fulfillmentTime, transactionHash, apiAdditionalInfo }) => {
const orderObject = pendingOrders[id] || cancelledOrders[id]

if (orderObject) {
Expand All @@ -149,6 +149,8 @@ export default createReducer(initialState, (builder) =>
orderObject.order.fulfilledTransactionHash = transactionHash
orderObject.order.isCancelling = false

orderObject.order.apiAdditionalInfo = apiAdditionalInfo

fulfilledOrders[id] = orderObject
}
})
Expand Down
5 changes: 5 additions & 0 deletions src/custom/state/orders/updaters/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,11 @@ export async function fetchOrderPopupData(orderFromStore: Order, chainId: ChainI
fulfillmentTime: new Date().toISOString(),
transactionHash: '', // there's no need for a txHash as we'll link the notification to the Explorer
summary: _computeFulfilledSummary({ orderFromStore, orderFromApi }),
apiAdditionalInfo: orderFromApi
? {
...orderFromApi,
}
: undefined,
}
break
case 'expired':
Expand Down