@silentswap/sdk 0.0.90 → 0.0.91
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/bridge.js +11 -11
- package/package.json +1 -1
package/dist/bridge.js
CHANGED
|
@@ -716,23 +716,23 @@ async function solveDebridgeSingleChainUsdcAmount(chainId, srcToken, srcAmount,
|
|
|
716
716
|
* @param maxImpactPercent - Maximum price impact percentage allowed (default from constants)
|
|
717
717
|
* @returns Promise resolving to solve result with optimal amounts
|
|
718
718
|
*/
|
|
719
|
-
export async function solveOptimalUsdcAmount(srcChainId, srcToken, srcAmount, userAddress, depositCalldata, maxImpactPercent, depositorAddress, evmSignerAddress // Optional EVM address for deposit calldata (required for Solana
|
|
719
|
+
export async function solveOptimalUsdcAmount(srcChainId, srcToken, srcAmount, userAddress, depositCalldata, maxImpactPercent, depositorAddress, evmSignerAddress // Optional EVM address for deposit calldata (required for non-EVM swaps: Solana, Bitcoin)
|
|
720
720
|
) {
|
|
721
|
-
// Check if this is a Solana
|
|
722
|
-
const
|
|
723
|
-
// For
|
|
724
|
-
// userAddress is the
|
|
721
|
+
// Check if this is a non-EVM chain (Solana, Bitcoin, etc.)
|
|
722
|
+
const isNonEvmChain = isNonEvmRelayChainId(srcChainId);
|
|
723
|
+
// For non-EVM chains (Solana, Bitcoin), we need an EVM address for deposit calldata
|
|
724
|
+
// userAddress is the source chain address (Solana/Bitcoin) for relay quote user parameter
|
|
725
725
|
// evmSignerAddress is the EVM address (for deposit calldata and relay quote recipient)
|
|
726
|
-
const evmAddressForCalldata = evmSignerAddress || (!
|
|
726
|
+
const evmAddressForCalldata = evmSignerAddress || (!isNonEvmChain && userAddress.startsWith('0x') ? userAddress : undefined);
|
|
727
727
|
if (!depositCalldata && !evmAddressForCalldata) {
|
|
728
|
-
throw new Error('EVM address required for deposit calldata. Provide evmSignerAddress parameter for
|
|
728
|
+
throw new Error('EVM address required for deposit calldata. Provide evmSignerAddress parameter for non-EVM swaps.');
|
|
729
729
|
}
|
|
730
730
|
// Create phony deposit calldata if not provided
|
|
731
731
|
const calldata = depositCalldata || createPhonyDepositCalldata(evmAddressForCalldata);
|
|
732
|
-
// For
|
|
733
|
-
// userAddress is the
|
|
734
|
-
// evmSignerAddress is the EVM address (for recipient parameter)
|
|
735
|
-
const recipientAddress =
|
|
732
|
+
// For non-EVM chains, we need to pass the EVM address as recipient in relay quotes
|
|
733
|
+
// userAddress is the source chain address (for user parameter)
|
|
734
|
+
// evmSignerAddress is the EVM address (for recipient parameter on the destination EVM chain)
|
|
735
|
+
const recipientAddress = isNonEvmChain && evmSignerAddress ? evmSignerAddress : userAddress;
|
|
736
736
|
// Try both providers in parallel
|
|
737
737
|
const [relayResult, debridgeResult] = await Promise.allSettled([
|
|
738
738
|
solveRelayUsdcAmount(srcChainId, srcToken, srcAmount, userAddress, calldata, maxImpactPercent, depositorAddress, recipientAddress),
|