applyFills bugfix
This commit is contained in:
@@ -1,16 +1,3 @@
|
|||||||
export function applyFills( orderStatus, filled ) {
|
|
||||||
console.log('apply fills', orderStatus, filled)
|
|
||||||
orderStatus[4] = filled[0][0]
|
|
||||||
orderStatus[5] = filled[0][1]
|
|
||||||
for( const i in filled[1] ) {
|
|
||||||
const {filledIn, filledOut} = filled[1][i]
|
|
||||||
orderStatus[6][i] = filledIn
|
|
||||||
orderStatus[7][i] = filledOut
|
|
||||||
}
|
|
||||||
console.log('applied fills', orderStatus)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
export function encodeIEE754(value) {
|
export function encodeIEE754(value) {
|
||||||
const buffer = new ArrayBuffer(4);
|
const buffer = new ArrayBuffer(4);
|
||||||
const view = new DataView(buffer);
|
const view = new DataView(buffer);
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import {io} from "socket.io-client";
|
|||||||
import {useStore} from "@/store/store.js";
|
import {useStore} from "@/store/store.js";
|
||||||
import {flushOrders, onChainChanged} from "@/blockchain/wallet.js";
|
import {flushOrders, onChainChanged} from "@/blockchain/wallet.js";
|
||||||
import {ethers} from "ethers";
|
import {ethers} from "ethers";
|
||||||
import {applyFills} from "@/blockchain/common.js";
|
|
||||||
import {parseOrderStatus} from "@/blockchain/orderlib.js";
|
import {parseOrderStatus} from "@/blockchain/orderlib.js";
|
||||||
|
|
||||||
export const socket = io(import.meta.env.VITE_WS_URL || undefined, {transports: ["websocket"]})
|
export const socket = io(import.meta.env.VITE_WS_URL || undefined, {transports: ["websocket"]})
|
||||||
@@ -80,11 +79,11 @@ socket.on('os', (chainId, vault, orders) => {
|
|||||||
|
|
||||||
socket.on( 'o', handleOrderStatus)
|
socket.on( 'o', handleOrderStatus)
|
||||||
|
|
||||||
socket.on( 'of', (chainId, vault, orderIndex, fills)=>{
|
socket.on( 'of', (chainId, vault, orderIndex, filled)=>{
|
||||||
const s = useStore()
|
const s = useStore()
|
||||||
if( s.chainId.value !== chainId )
|
if( s.chainId.value !== chainId )
|
||||||
return
|
return
|
||||||
console.log('of', chainId, vault, orderIndex, fills)
|
console.log('of', chainId, vault, orderIndex, filled)
|
||||||
if( !(vault in s.orders) ) {
|
if( !(vault in s.orders) ) {
|
||||||
console.log('warning: got fill on an order in an unknown vault')
|
console.log('warning: got fill on an order in an unknown vault')
|
||||||
return
|
return
|
||||||
@@ -93,7 +92,16 @@ socket.on( 'of', (chainId, vault, orderIndex, fills)=>{
|
|||||||
console.log(`warning: orderIndex ${orderIndex} missing from vault ${vault}`)
|
console.log(`warning: orderIndex ${orderIndex} missing from vault ${vault}`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
const order = s.orders[vault][orderIndex]
|
|
||||||
applyFills(order, fills)
|
const status = s.orders[vault][orderIndex]
|
||||||
s.orders[vault][orderIndex] = order
|
console.log('apply fills', status, filled)
|
||||||
|
status.filledIn = BigInt(filled[0][0])
|
||||||
|
status.filledOut = BigInt(filled[0][1])
|
||||||
|
for( const i in filled[1] ) {
|
||||||
|
const [filledIn, filledOut] = filled[1][i]
|
||||||
|
status.trancheFilledIn[i] = BigInt(filledIn)
|
||||||
|
status.trancheFilledOut[i] = BigInt(filledOut)
|
||||||
|
}
|
||||||
|
s.orders[vault][orderIndex] = status
|
||||||
|
console.log('applied fills', status)
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user