all twap tranches work!
This commit is contained in:
@@ -255,8 +255,8 @@ async function placeOrder() {
|
|||||||
// build tranches
|
// build tranches
|
||||||
const n = tranches.value // num tranches
|
const n = tranches.value // num tranches
|
||||||
const ts = []
|
const ts = []
|
||||||
let duration = timeUnitIndex === 0 ? interval.value * 60 : // minutes
|
let duration = timeUnitIndex.value === 0 ? interval.value * 60 : // minutes
|
||||||
timeUnitIndex === 1 ? interval.value * 60 * 60 : // hours
|
timeUnitIndex.value === 1 ? interval.value * 60 * 60 : // hours
|
||||||
interval.value * 24 * 60 * 60; // days
|
interval.value * 24 * 60 * 60; // days
|
||||||
let window
|
let window
|
||||||
if (!intervalIsTotal.value) {
|
if (!intervalIsTotal.value) {
|
||||||
@@ -269,9 +269,11 @@ async function placeOrder() {
|
|||||||
const ceil = oneHundredPercent % BigInt(n) ? 1n : 0n
|
const ceil = oneHundredPercent % BigInt(n) ? 1n : 0n
|
||||||
const amtPerTranche = oneHundredPercent / BigInt(n) + ceil
|
const amtPerTranche = oneHundredPercent / BigInt(n) + ceil
|
||||||
duration -= 15 // subtract 15 seconds so the last tranche completes before the deadline
|
duration -= 15 // subtract 15 seconds so the last tranche completes before the deadline
|
||||||
|
console.log('duration', duration)
|
||||||
for (let i = 0; i < n; i++) {
|
for (let i = 0; i < n; i++) {
|
||||||
const start = Math.floor(i * (duration / n))
|
const start = Math.floor(i * (duration / (n-1)))
|
||||||
const end = start + window
|
const end = start + window
|
||||||
|
console.log('tranche window', start, end, (end-start)/60)
|
||||||
const cs = [newTimeConstraint(TimeMode.SinceOrderStart, start, TimeMode.SinceOrderStart, end)]
|
const cs = [newTimeConstraint(TimeMode.SinceOrderStart, start, TimeMode.SinceOrderStart, end)]
|
||||||
ts.push([amtPerTranche, cs])
|
ts.push([amtPerTranche, cs])
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user