|
|
|
@ -218,15 +218,17 @@ export const POST = async ({ locals, request }) => {
|
|
|
|
qty = position.result.list[0].size
|
|
|
|
qty = position.result.list[0].size
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
const stacking_config =
|
|
|
|
form.data.type
|
|
|
|
await db.query.stacking_config.findFirst()
|
|
|
|
const current_stack = await db.query.current_stack.findFirst()
|
|
|
|
|
|
|
|
|
|
|
|
if (!stacking_config) {
|
|
|
|
if (!current_stack) {
|
|
|
|
return new Response()
|
|
|
|
return new Response()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
qty = (
|
|
|
|
qty = (
|
|
|
|
Number(form.data.qty) * Number(form.data.leverage || '1')
|
|
|
|
Number(form.data.qty) *
|
|
|
|
|
|
|
|
Number(form.data.leverage || '1') *
|
|
|
|
|
|
|
|
(1 + current_stack.stack / 100)
|
|
|
|
).toString()
|
|
|
|
).toString()
|
|
|
|
takeProfit = form.data.takeProfit
|
|
|
|
takeProfit = form.data.takeProfit
|
|
|
|
stopLoss = form.data.stopLoss
|
|
|
|
stopLoss = form.data.stopLoss
|
|
|
|
@ -302,6 +304,11 @@ export const POST = async ({ locals, request }) => {
|
|
|
|
stack: stack.stack + config.stackRate,
|
|
|
|
stack: stack.stack + config.stackRate,
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.where(eq(current_stack.id, stack.id))
|
|
|
|
.where(eq(current_stack.id, stack.id))
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
await db.insert(current_stack).values({
|
|
|
|
|
|
|
|
id: nanoid(),
|
|
|
|
|
|
|
|
stack: 0,
|
|
|
|
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|