SwapOrder.inverted

This commit is contained in:
tim
2024-10-28 13:23:06 -04:00
parent 8a34c55fe0
commit 5e91b0ff43
10 changed files with 64 additions and 48 deletions

View File

@@ -86,7 +86,11 @@ const feeGroups = {} // keyed by ticker without the final fee field. values are
// symbol is keyed by the `ticker` which is defined as 'chain_id|pool_addr' for absolute uniqueness.
export function tickerForOrder(chainId, order) {
return tickerKey(chainId, order.route.exchange, order.tokenIn, order.tokenOut, order.route.fee, true)
let [base, quote] = [order.tokenIn, order.tokenOut]
const inv = base > quote
if (inv !== order.inverted)
[base, quote] = [quote, base]
return tickerKey(chainId, order.route.exchange, base, quote, order.route.fee, false)
}
export function tickerKey(chainId, exchange, tokenAddrA, tokenAddrB, fee, chooseInversion=false ) {