@silentswap/react 0.0.75 → 0.0.76

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.
@@ -181,12 +181,23 @@ export function useQuoteCalculation({ address, evmAddress, wallet, depositorAddr
181
181
  groupPks = await facilitatorGroupForQuote.exportPublicKeys(destinations.length, PublicKeyArgGroups.GENERIC);
182
182
  }
183
183
  const usdcAmountBN = BigNumber(usdcAmountOut);
184
+ let remainingUsdc = usdcAmountBN;
184
185
  // Calculate split USDC amounts for each destination (matches Svelte Form.svelte lines 2550-2561)
185
186
  // The value in the quote request should be USDC micro units, NOT the currencyOut.amount from egress quotes
186
187
  // Egress quotes are used for retention rates and destination amounts, but NOT for quote request values
187
188
  const splitUsdcAmounts = destinations.map((dest, idx) => {
188
189
  const splitAmount = idx === 0 ? splits[0] : splits[idx] - splits[idx - 1];
189
- return usdcAmountBN.times(splitAmount).toFixed(0);
190
+ // Match Svelte's logic to prevent rounding error where sum > total
191
+ let amountStr = usdcAmountBN.times(splitAmount).toFixed(0);
192
+ const amountBN = BigNumber(amountStr);
193
+ if (remainingUsdc.lt(amountBN)) {
194
+ amountStr = remainingUsdc.toFixed(0);
195
+ remainingUsdc = BigNumber(0);
196
+ }
197
+ else {
198
+ remainingUsdc = remainingUsdc.minus(amountBN);
199
+ }
200
+ return amountStr;
190
201
  });
191
202
  const outputs = destinations.map((dest, idx) => {
192
203
  const isDestSolana = isSolanaAsset(dest.asset);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@silentswap/react",
3
3
  "type": "module",
4
- "version": "0.0.75",
4
+ "version": "0.0.76",
5
5
  "license": "MIT",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
@@ -24,8 +24,8 @@
24
24
  "dependencies": {
25
25
  "@bigmi/core": "^0.6.5",
26
26
  "@ensdomains/ensjs": "^4.2.0",
27
- "@silentswap/sdk": "0.0.75",
28
- "@silentswap/ui-kit": "0.0.75",
27
+ "@silentswap/sdk": "0.0.76",
28
+ "@silentswap/ui-kit": "0.0.76",
29
29
  "@solana/codecs-strings": "^5.1.0",
30
30
  "@solana/kit": "^5.1.0",
31
31
  "@solana/rpc": "^5.1.0",