fill notifications and chart autoupdate

This commit is contained in:
tim
2024-10-29 16:30:05 -04:00
parent b9ca6ab2cc
commit 5d3d1d6f5a
5 changed files with 67 additions and 6 deletions

View File

@@ -3,6 +3,7 @@ import {useStore} from "@/store/store.js";
import {flushOrders} from "@/blockchain/wallet.js";
import {parseElaboratedOrderStatus} from "@/blockchain/orderlib.js";
import { DataFeed } from "./charts/datafeed";
import {notify, notifyFillEvent} from "@/notify.js";
export const socket = io(import.meta.env.VITE_WS_URL || undefined, {transports: ["websocket"]})
@@ -103,12 +104,19 @@ socket.on( 'of', (chainId, vault, orderIndex, filled)=>{
let filledIn = 0n
let filledOut = 0n
const [activationTime, fills] = filled[i];
ts.fills = []
for (const fill of fills) {
const numOld = ts.fills.length;
for (let i=0; i<fills.length; i++) {
const fill = fills[i]
const [tx, time, fi, fo, fee] = fill
filledIn += fi
filledOut += fo
ts.fills.push({tx, time, filledIn:fi, filledOut:fo, fee, filled:status.order.amountIsInput?fi:fo})
if (i<=numOld) {
// new fill detected
const f = {tx, time, filledIn: fi, filledOut: fo, fee, filled: status.order.amountIsInput ? fi : fo};
console.log('new fill', f)
notifyFillEvent(chainId, status, i, f).catch((e)=>console.log('fill notification error', e))
ts.fills.push(f)
}
}
ts.filledIn = filledIn
ts.filledOut = filledOut