@liberfi.io/react-predict 0.1.38 → 0.1.39
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 +8 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +8 -2
- package/dist/index.mjs.map +1 -1
- package/dist/server.js +8 -2
- package/dist/server.js.map +1 -1
- package/dist/server.mjs +8 -2
- package/dist/server.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1862,6 +1862,10 @@ function decimalPlaces(n, d) {
|
|
|
1862
1862
|
function toMicroUsdc(amount) {
|
|
1863
1863
|
return BigInt(Math.round(amount * 1e6));
|
|
1864
1864
|
}
|
|
1865
|
+
function truncateMicro(raw, maxDecimals) {
|
|
1866
|
+
const factor = BigInt(10 ** (6 - maxDecimals));
|
|
1867
|
+
return raw / factor * factor;
|
|
1868
|
+
}
|
|
1865
1869
|
function normalizeTokenId(tokenId) {
|
|
1866
1870
|
if (tokenId.startsWith("0x") || tokenId.startsWith("0X")) {
|
|
1867
1871
|
return BigInt(tokenId).toString(10);
|
|
@@ -1876,8 +1880,10 @@ function buildOrderMessage(input) {
|
|
|
1876
1880
|
const rawAmount = decimalPlaces(rawSize * rawPrice, rc.amount);
|
|
1877
1881
|
const sizeInMicro = toMicroUsdc(rawSize);
|
|
1878
1882
|
const amountInMicro = toMicroUsdc(rawAmount);
|
|
1879
|
-
const
|
|
1880
|
-
const
|
|
1883
|
+
const usdcMicro = truncateMicro(amountInMicro, 2);
|
|
1884
|
+
const sharesMicro = truncateMicro(sizeInMicro, 4);
|
|
1885
|
+
const makerAmount = side === SIDE.BUY ? usdcMicro.toString() : sharesMicro.toString();
|
|
1886
|
+
const takerAmount = side === SIDE.BUY ? sharesMicro.toString() : usdcMicro.toString();
|
|
1881
1887
|
const maker = input.funderAddress ?? input.signerAddress;
|
|
1882
1888
|
return {
|
|
1883
1889
|
salt: Math.floor(Math.random() * 1e15).toString(),
|