@silentswap/react 0.0.75 → 0.0.77
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.
|
@@ -12,6 +12,7 @@ import { BigNumber } from 'bignumber.js';
|
|
|
12
12
|
* - Quote request construction and fetching
|
|
13
13
|
* - Destination amount updates
|
|
14
14
|
*/
|
|
15
|
+
// TODO: Simplify this hook by removing the useCallback and useState and just returning the calculateQuote function.
|
|
15
16
|
export function useQuoteCalculation({ address, evmAddress, wallet, depositorAddress, getQuote, getPrice, setDestinations, proId, }) {
|
|
16
17
|
const [loadingAmounts, setLoadingAmounts] = useState(false);
|
|
17
18
|
const [depositAmountUsdc, setDepositAmountUsdc] = useState(0);
|
|
@@ -181,12 +182,22 @@ export function useQuoteCalculation({ address, evmAddress, wallet, depositorAddr
|
|
|
181
182
|
groupPks = await facilitatorGroupForQuote.exportPublicKeys(destinations.length, PublicKeyArgGroups.GENERIC);
|
|
182
183
|
}
|
|
183
184
|
const usdcAmountBN = BigNumber(usdcAmountOut);
|
|
185
|
+
let remainingUsdc = usdcAmountBN;
|
|
184
186
|
// Calculate split USDC amounts for each destination (matches Svelte Form.svelte lines 2550-2561)
|
|
185
187
|
// The value in the quote request should be USDC micro units, NOT the currencyOut.amount from egress quotes
|
|
186
188
|
// Egress quotes are used for retention rates and destination amounts, but NOT for quote request values
|
|
187
189
|
const splitUsdcAmounts = destinations.map((dest, idx) => {
|
|
188
190
|
const splitAmount = idx === 0 ? splits[0] : splits[idx] - splits[idx - 1];
|
|
189
|
-
|
|
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.
|
|
4
|
+
"version": "0.0.77",
|
|
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.
|
|
28
|
-
"@silentswap/ui-kit": "0.0.
|
|
27
|
+
"@silentswap/sdk": "0.0.77",
|
|
28
|
+
"@silentswap/ui-kit": "0.0.77",
|
|
29
29
|
"@solana/codecs-strings": "^5.1.0",
|
|
30
30
|
"@solana/kit": "^5.1.0",
|
|
31
31
|
"@solana/rpc": "^5.1.0",
|