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

@@ -15,6 +15,7 @@ export const DISTANT_FUTURE = uint32max
// uint256 minFillAmount; // if a tranche has less than this amount available to fill, it is considered completed
// bool amountIsInput;
// bool outputDirectlyToOwner;
// bool inverted;
// uint64 conditionalOrder; // use NO_CONDITIONAL_ORDER for no chaining. conditionalOrder index must be < than this order's index for safety (written first) and conditionalOrder state must be Template
// Tranche[] tranches;
// }
@@ -22,7 +23,7 @@ export const DISTANT_FUTURE = uint32max
// Exchange exchange;
// uint24 fee;
// }
export function newOrder(tokenIn, tokenOut, exchange, fee, amount, amountIsInput, tranches,
export function newOrder(tokenIn, tokenOut, exchange, fee, amount, amountIsInput, inverted, tranches,
minFillAmount=null, outputDirectlyToOwner = false, conditionalOrder = NO_CONDITIONAL_ORDER) {
amountIsInput = !!amountIsInput // force convert to bool
outputDirectlyToOwner = !!outputDirectlyToOwner // force convert to bool
@@ -34,7 +35,7 @@ export function newOrder(tokenIn, tokenOut, exchange, fee, amount, amountIsInput
return {
tokenIn, tokenOut, route:{exchange, fee},
amount, minFillAmount, amountIsInput,
outputDirectlyToOwner, conditionalOrder, tranches
outputDirectlyToOwner, inverted, conditionalOrder, tranches
}
}
@@ -186,6 +187,7 @@ export function parseOrder(order) {
minFillAmount,
amountIsInput,
outputDirectlyToOwner,
inverted,
conditionalOrder,
tranches,
] = order
@@ -194,7 +196,7 @@ export function parseOrder(order) {
minFillAmount = BigInt(minFillAmount)
tranches = tranches.map(parseTranche)
return {
tokenIn, tokenOut, route, amount, minFillAmount, amountIsInput, outputDirectlyToOwner, conditionalOrder, tranches
tokenIn, tokenOut, route, amount, minFillAmount, amountIsInput, outputDirectlyToOwner, inverted, conditionalOrder, tranches
}
}

View File

@@ -265,7 +265,8 @@ export const PendingOrderState = {
Sent: -102, // tx is awaiting blockchain mining
}
const placementFeeSelector = 'placementFee((address,address,(uint8,uint24),uint256,uint256,bool,bool,uint64,(uint16,bool,bool,bool,bool,bool,bool,bool,bool,uint16,uint24,uint32,uint32,(uint32,uint32),(uint32,uint32))[]),(uint8,uint8,uint8,uint8,uint8))'
// single order placement selector
const placementFeeSelector = 'placementFee((address,address,(uint8,uint24),uint256,uint256,bool,bool,bool,uint64,(uint16,bool,bool,bool,bool,bool,bool,bool,bool,uint16,uint24,uint32,uint32,(uint32,uint32),(uint32,uint32))[]),(uint8,uint8,uint8,uint8,uint8))'
export async function placementFee(vault, order, window=300) {
// If the fees are about to change within `window` seconds of now, we send the higher native amount of the two fees.