Files
web/src/blockchain/common.js
2023-12-02 21:46:23 -04:00

24 lines
660 B
JavaScript

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) {
const buffer = new ArrayBuffer(2);
new DataView(buffer).setFloat32(0, value, false /* big endian */);
return buffer;
}
export function decodeIEE754(buffer) {
return new DataView(buffer).getFloat32(0, false);
}