order placement doesnt crash

This commit is contained in:
Tim Olson
2023-10-14 22:06:43 -04:00
parent b699d76073
commit dc23ecdd20
7 changed files with 52 additions and 20 deletions

View File

@@ -29,12 +29,12 @@ export function newOrder(tokenIn, tokenOut, exchange, fee, amount, amountIsInput
}
// struct Tranche {
// uint64 fraction; // 18-decimal fraction of the order amount which is available to this tranche. must be <= 1
// uint64 fraction;
// Constraint[] constraints;
// }
export function newTranche(amountRatio, constraints) {
return [
BigInt(Math.ceil(amountRatio * 10**18)), // we use ceil to make sure the sum of tranche fractions doesn't round below 1
BigInt(Math.min(65535, Math.ceil(amountRatio * 65535))), // we use ceil to make sure the sum of tranche fractions doesn't round below 1
constraints
]
}