applyFills() fixes

This commit is contained in:
Tim
2024-03-30 14:56:20 -04:00
parent ed524d670e
commit 8191b4a54c

View File

@@ -19,7 +19,7 @@ export function sendVaultOrders( socket, chainId, vault ) {
for( let [orderIndex, status] of recents ) { for( let [orderIndex, status] of recents ) {
if( !(orderIndex in statuses) ) { if( !(orderIndex in statuses) ) {
// only write the database version if there's no open order in the memcache // only write the database version if there's no open order in the memcache
const orderKey = `${vault}|${orderIndex}` const orderKey = `${vault}|${orderIndex.toString().padStart(5,'0')}`
proms.push(fillOrderStatus(chainId, orderKey, status)) proms.push(fillOrderStatus(chainId, orderKey, status))
statuses[orderIndex] = status statuses[orderIndex] = status
} }
@@ -72,13 +72,13 @@ export async function recentOrders( socket, chainId, vault, limit=25 ) {
} }
function applyFills( orderStatus, filled ) { function applyFills( orderStatus, filled ) {
console.log('apply fills', orderStatus, filled) // console.log('apply fills', orderStatus, filled)
orderStatus[5] = filled[0][0] orderStatus[5] = filled[0][0]
orderStatus[6] = filled[0][1] orderStatus[6] = filled[0][1]
for( const i in filled[1] ) { for( const i in filled[1] ) {
const {filledIn, filledOut} = filled[1][i] const [filledIn, filledOut] = filled[1][i]
orderStatus[7][i] = filledIn orderStatus[7][i] = filledIn
orderStatus[8][i] = filledOut orderStatus[8][i] = filledOut
} }
console.log('applied fills', orderStatus) // console.log('applied fills', orderStatus)
} }