ordershapes

This commit is contained in:
tim
2024-09-15 00:59:47 -04:00
parent 80e03f648b
commit 09ef4c5f43
10 changed files with 295 additions and 92 deletions

View File

@@ -159,11 +159,22 @@ export function parseOrderStatus(chainId, status) {
return result
}
function parseTrancheStatus(obj) {
let [filledIn, filledOut, activationTime, startTime, endTime,] = obj
function parseFill(obj) {
let [tx, time, filledIn, filledOut, fee] = obj
filledIn = BigInt(filledIn)
filledOut = BigInt(filledOut)
return {filledIn, filledOut, activationTime, startTime, endTime}
fee = BigInt(fee)
return {tx, time, filledIn, filledOut, fee}
}
function parseTrancheStatus(obj) {
let [filledIn, filledOut, activationTime, startTime, endTime, rawFills,] = obj
filledIn = BigInt(filledIn)
filledOut = BigInt(filledOut)
const fills = []
for (const fill of rawFills)
fills.push(parseFill(fill))
return {filledIn, filledOut, activationTime, startTime, endTime, fills}
}
export function parseOrder(order) {
@@ -210,14 +221,16 @@ export function parseTranche(tranche) {
minLine,
maxLine,
] = tranche
minLine = {intercept: minLine.intercept, slope: minLine.slope }
maxLine = {intercept: maxLine.intercept, slope: maxLine.slope }
const [minB,minS] = minLine
minLine = {intercept: minB, slope: minS }
const [maxB,maxS] = maxLine
maxLine = {intercept: maxB, slope: maxS }
const result = {
fraction, startTimeIsRelative, endTimeIsRelative, minIsBarrier, maxIsBarrier, marketOrder,
minIsRatio, maxIsRatio, rateLimitFraction, rateLimitPeriod,
startTime, endTime, minLine, maxLine,
}
console.log('parseTranche', tranche, result)
// console.log('parseTranche', tranche, result)
return result
}

View File

@@ -384,7 +384,7 @@ function pendOrderAsTransaction(pend) {
const [orderFee, gasFee] = await placementFee(pend.vault, pend.order)
pend.fee = orderFee + gasFee
}
console.log('placing order', pend.id, pend.order)
console.log('placing order', pend.id, pend.fee, pend.order)
const tx = await contract.placeDexorder(pend.order, {value:pend.fee})
pend.tx = tx
pend.state = PendingOrderState.Sent