fill notifications and chart autoupdate
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user