@liberfi.io/react-predict 0.1.39 → 0.1.41
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -3
- package/dist/index.mjs.map +1 -1
- package/dist/server.js +7 -3
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +7 -3
- package/dist/server.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -1860,7 +1860,11 @@ function decimalPlaces(n, d) {
|
|
|
1860
1860
|
function toMicroUsdc(amount) {
|
|
1861
1861
|
return BigInt(Math.round(amount * 1e6));
|
|
1862
1862
|
}
|
|
1863
|
-
function
|
|
1863
|
+
function ceilMicro(raw, maxDecimals) {
|
|
1864
|
+
const factor = BigInt(10 ** (6 - maxDecimals));
|
|
1865
|
+
return (raw + factor - 1n) / factor * factor;
|
|
1866
|
+
}
|
|
1867
|
+
function floorMicro(raw, maxDecimals) {
|
|
1864
1868
|
const factor = BigInt(10 ** (6 - maxDecimals));
|
|
1865
1869
|
return raw / factor * factor;
|
|
1866
1870
|
}
|
|
@@ -1878,8 +1882,8 @@ function buildOrderMessage(input) {
|
|
|
1878
1882
|
const rawAmount = decimalPlaces(rawSize * rawPrice, rc.amount);
|
|
1879
1883
|
const sizeInMicro = toMicroUsdc(rawSize);
|
|
1880
1884
|
const amountInMicro = toMicroUsdc(rawAmount);
|
|
1881
|
-
const usdcMicro =
|
|
1882
|
-
const sharesMicro =
|
|
1885
|
+
const usdcMicro = side === SIDE.BUY ? ceilMicro(amountInMicro, 2) : floorMicro(amountInMicro, 2);
|
|
1886
|
+
const sharesMicro = floorMicro(sizeInMicro, 4);
|
|
1883
1887
|
const makerAmount = side === SIDE.BUY ? usdcMicro.toString() : sharesMicro.toString();
|
|
1884
1888
|
const takerAmount = side === SIDE.BUY ? sharesMicro.toString() : usdcMicro.toString();
|
|
1885
1889
|
const maker = input.funderAddress ?? input.signerAddress;
|