@silentswap/sdk 0.0.81 → 0.0.83
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/data/filtered.json +13 -2
- package/dist/quote-utils.d.ts +1 -1
- package/dist/quote-utils.js +39 -15
- package/package.json +1 -1
- package/src/data/filtered.json +13 -2
package/dist/data/filtered.json
CHANGED
|
@@ -692,8 +692,8 @@
|
|
|
692
692
|
"2B84E3"
|
|
693
693
|
]
|
|
694
694
|
},
|
|
695
|
-
"eip155:1/erc20:
|
|
696
|
-
"caip19": "eip155:1/erc20:
|
|
695
|
+
"eip155:1/erc20:0xb72E76cCf005313868DB7b48070901a44629da98": {
|
|
696
|
+
"caip19": "eip155:1/erc20:0xb72E76cCf005313868DB7b48070901a44629da98",
|
|
697
697
|
"coingeckoId": "squidgrow-2",
|
|
698
698
|
"name": "SquidGrow",
|
|
699
699
|
"symbol": "SQGROW",
|
|
@@ -2353,6 +2353,17 @@
|
|
|
2353
2353
|
"00D49B"
|
|
2354
2354
|
]
|
|
2355
2355
|
},
|
|
2356
|
+
"eip155:137/erc20:0xCfde7c43EDB3c9f71331AAc1003b099CE40c94ea": {
|
|
2357
|
+
"caip19": "eip155:137/erc20:0xCfde7c43EDB3c9f71331AAc1003b099CE40c94ea",
|
|
2358
|
+
"coingeckoId": "gift",
|
|
2359
|
+
"name": "GIFT",
|
|
2360
|
+
"symbol": "GIFT",
|
|
2361
|
+
"decimals": 18,
|
|
2362
|
+
"gradient": [
|
|
2363
|
+
"8B5CF6",
|
|
2364
|
+
"A78BFA"
|
|
2365
|
+
]
|
|
2366
|
+
},
|
|
2356
2367
|
"eip155:10/erc20:0x01bFF41798a0BcF287b996046Ca68b395DbC1071": {
|
|
2357
2368
|
"caip19": "eip155:10/erc20:0x01bFF41798a0BcF287b996046Ca68b395DbC1071",
|
|
2358
2369
|
"coingeckoId": "usdt0",
|
package/dist/quote-utils.d.ts
CHANGED
|
@@ -91,7 +91,7 @@ export type ForceBridgeProvider = 'relay' | 'debridge';
|
|
|
91
91
|
export declare function getBridgeQuote(srcChainId: number, srcToken: string, srcAmount: string, dstChainId: number, dstToken: string, userAddress: `0x${string}` | string, // Can be EVM (0x) or Solana (base58) address
|
|
92
92
|
signal?: AbortSignal, recipientAddress?: string, // Optional recipient address (required for Solana destinations)
|
|
93
93
|
sourceAddress?: string, // Optional source chain address (if different from userAddress)
|
|
94
|
-
forceProvider?: ForceBridgeProvider): Promise<BridgeQuoteResult>;
|
|
94
|
+
forceProvider?: ForceBridgeProvider, tradeType?: 'EXACT_INPUT' | 'EXACT_OUTPUT', dstAmount?: string): Promise<BridgeQuoteResult>;
|
|
95
95
|
/**
|
|
96
96
|
* Convert BridgeQuoteResult to BridgeQuote with transaction data
|
|
97
97
|
* Extracts transactions from the raw response based on provider
|
package/dist/quote-utils.js
CHANGED
|
@@ -196,10 +196,21 @@ export function selectBestQuote(relayQuote, debridgeQuote, srcAmount, relayRejec
|
|
|
196
196
|
bestQuote = viableRelay;
|
|
197
197
|
bestMetrics = relayMetrics;
|
|
198
198
|
}
|
|
199
|
-
// Extract output
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
199
|
+
// Extract output and input amounts from provider response
|
|
200
|
+
// Both relay and debridge always return input/output amounts in their responses,
|
|
201
|
+
// including for EXACT_OUTPUT quotes where inputAmount is the calculated value
|
|
202
|
+
let outputAmount;
|
|
203
|
+
let inputAmount;
|
|
204
|
+
if (bestProvider === 'relay') {
|
|
205
|
+
const relay = bestQuote;
|
|
206
|
+
outputAmount = relay.details.currencyOut.amount;
|
|
207
|
+
inputAmount = relay.details.currencyIn.amount;
|
|
208
|
+
}
|
|
209
|
+
else {
|
|
210
|
+
const debridge = bestQuote;
|
|
211
|
+
outputAmount = debridge.estimation.dstChainTokenOut.amount;
|
|
212
|
+
inputAmount = debridge.estimation.srcChainTokenIn?.amount || srcAmount;
|
|
213
|
+
}
|
|
203
214
|
// Extract first PSBT from relay steps for BTC swaps (convenience; also in rawResponse)
|
|
204
215
|
let psbt;
|
|
205
216
|
if (bestProvider === 'relay') {
|
|
@@ -220,7 +231,7 @@ export function selectBestQuote(relayQuote, debridgeQuote, srcAmount, relayRejec
|
|
|
220
231
|
return {
|
|
221
232
|
provider: bestProvider,
|
|
222
233
|
outputAmount: outputAmount || '0',
|
|
223
|
-
inputAmount: srcAmount,
|
|
234
|
+
inputAmount: inputAmount || srcAmount,
|
|
224
235
|
feeUsd: bestMetrics.feeUsd,
|
|
225
236
|
slippage: bestMetrics.slippage,
|
|
226
237
|
estimatedTime: bestMetrics.time,
|
|
@@ -283,7 +294,7 @@ export function interpolateSamples(samples, usdValue, marginHi = Infinity) {
|
|
|
283
294
|
export async function getBridgeQuote(srcChainId, srcToken, srcAmount, dstChainId, dstToken, userAddress, // Can be EVM (0x) or Solana (base58) address
|
|
284
295
|
signal, recipientAddress, // Optional recipient address (required for Solana destinations)
|
|
285
296
|
sourceAddress, // Optional source chain address (if different from userAddress)
|
|
286
|
-
forceProvider) {
|
|
297
|
+
forceProvider, tradeType = 'EXACT_INPUT', dstAmount) {
|
|
287
298
|
// Normalize token addresses for bridge API (handles both EVM and Solana)
|
|
288
299
|
const srcTokenNorm = normalizeTokenAddressForQuote(srcChainId, srcToken);
|
|
289
300
|
const dstTokenNorm = normalizeTokenAddressForQuote(dstChainId, dstToken);
|
|
@@ -392,8 +403,8 @@ forceProvider) {
|
|
|
392
403
|
destinationChainId: relayDstChainId,
|
|
393
404
|
originCurrency: srcTokenNorm,
|
|
394
405
|
destinationCurrency: dstTokenNorm,
|
|
395
|
-
amount: srcAmount,
|
|
396
|
-
tradeType
|
|
406
|
+
amount: tradeType === 'EXACT_OUTPUT' && dstAmount ? dstAmount : srcAmount,
|
|
407
|
+
tradeType,
|
|
397
408
|
};
|
|
398
409
|
// Set user address (must match source chain format)
|
|
399
410
|
relayParams.user = relayUserAddress;
|
|
@@ -457,7 +468,12 @@ forceProvider) {
|
|
|
457
468
|
relayParams.recipient = DEAD_ADDRESS;
|
|
458
469
|
}
|
|
459
470
|
}
|
|
460
|
-
|
|
471
|
+
else {
|
|
472
|
+
// EVM to EVM: use custom recipient when provided (e.g. send to another address)
|
|
473
|
+
if (recipientAddress && recipientAddress.startsWith('0x')) {
|
|
474
|
+
relayParams.recipient = recipientAddress;
|
|
475
|
+
}
|
|
476
|
+
}
|
|
461
477
|
const quote = await fetchRelayQuote(relayParams, signal);
|
|
462
478
|
return quote;
|
|
463
479
|
}
|
|
@@ -478,19 +494,23 @@ forceProvider) {
|
|
|
478
494
|
if (isSrcBitcoin || isDestBitcoin) {
|
|
479
495
|
return null;
|
|
480
496
|
}
|
|
497
|
+
const isExactOutput = tradeType === 'EXACT_OUTPUT' && dstAmount;
|
|
481
498
|
const debridgeParams = {
|
|
482
499
|
srcChainId: debridgeSrcChainId,
|
|
483
500
|
srcChainTokenIn: srcTokenNorm,
|
|
484
|
-
srcChainTokenInAmount: srcAmount,
|
|
501
|
+
srcChainTokenInAmount: isExactOutput ? 'auto' : srcAmount,
|
|
485
502
|
dstChainId: debridgeDstChainId,
|
|
486
503
|
dstChainTokenOut: dstTokenNorm,
|
|
487
504
|
prependOperatingExpenses: true,
|
|
488
505
|
account: userAddress,
|
|
489
506
|
};
|
|
507
|
+
if (isExactOutput) {
|
|
508
|
+
debridgeParams.dstChainTokenOutAmount = dstAmount;
|
|
509
|
+
}
|
|
490
510
|
// Handle Solana source or destination
|
|
491
511
|
if (isSrcSolana || isDestSolana) {
|
|
492
|
-
// For Solana source or destination
|
|
493
|
-
// Don't set dstChainTokenOutAmount (omit it for EXACT_INPUT mode)
|
|
512
|
+
// For Solana source or destination
|
|
513
|
+
// Don't set dstChainTokenOutAmount unless EXACT_OUTPUT (omit it for EXACT_INPUT mode)
|
|
494
514
|
debridgeParams.enableEstimate = false;
|
|
495
515
|
// Set recipient address (required for Solana source or destination)
|
|
496
516
|
if (!recipientAddress) {
|
|
@@ -526,12 +546,16 @@ forceProvider) {
|
|
|
526
546
|
else {
|
|
527
547
|
// Both source and destination are EVM
|
|
528
548
|
// API requires dstChainTokenOutRecipient, srcChainOrderAuthorityAddress, dstChainOrderAuthorityAddress for transaction construction
|
|
529
|
-
|
|
549
|
+
// Use recipientAddress when provided (user-set recipient), otherwise fall back to userAddress (send to self)
|
|
550
|
+
const evmRecipient = recipientAddress && recipientAddress.startsWith('0x') ? recipientAddress : userAddress;
|
|
551
|
+
debridgeParams.dstChainTokenOutRecipient = evmRecipient;
|
|
530
552
|
debridgeParams.srcChainOrderAuthorityAddress = userAddress;
|
|
531
|
-
debridgeParams.dstChainOrderAuthorityAddress =
|
|
553
|
+
debridgeParams.dstChainOrderAuthorityAddress = evmRecipient;
|
|
532
554
|
debridgeParams.srcChainRefundAddress = userAddress;
|
|
533
555
|
debridgeParams.senderAddress = userAddress;
|
|
534
|
-
|
|
556
|
+
if (!isExactOutput) {
|
|
557
|
+
debridgeParams.dstChainTokenOutAmount = 'auto';
|
|
558
|
+
}
|
|
535
559
|
debridgeParams.enableEstimate = true;
|
|
536
560
|
// Optional params matching deSwap app for consistent API behavior
|
|
537
561
|
debridgeParams.additionalTakerRewardBps = 0;
|
package/package.json
CHANGED
package/src/data/filtered.json
CHANGED
|
@@ -692,8 +692,8 @@
|
|
|
692
692
|
"2B84E3"
|
|
693
693
|
]
|
|
694
694
|
},
|
|
695
|
-
"eip155:1/erc20:
|
|
696
|
-
"caip19": "eip155:1/erc20:
|
|
695
|
+
"eip155:1/erc20:0xb72E76cCf005313868DB7b48070901a44629da98": {
|
|
696
|
+
"caip19": "eip155:1/erc20:0xb72E76cCf005313868DB7b48070901a44629da98",
|
|
697
697
|
"coingeckoId": "squidgrow-2",
|
|
698
698
|
"name": "SquidGrow",
|
|
699
699
|
"symbol": "SQGROW",
|
|
@@ -2353,6 +2353,17 @@
|
|
|
2353
2353
|
"00D49B"
|
|
2354
2354
|
]
|
|
2355
2355
|
},
|
|
2356
|
+
"eip155:137/erc20:0xCfde7c43EDB3c9f71331AAc1003b099CE40c94ea": {
|
|
2357
|
+
"caip19": "eip155:137/erc20:0xCfde7c43EDB3c9f71331AAc1003b099CE40c94ea",
|
|
2358
|
+
"coingeckoId": "gift",
|
|
2359
|
+
"name": "GIFT",
|
|
2360
|
+
"symbol": "GIFT",
|
|
2361
|
+
"decimals": 18,
|
|
2362
|
+
"gradient": [
|
|
2363
|
+
"8B5CF6",
|
|
2364
|
+
"A78BFA"
|
|
2365
|
+
]
|
|
2366
|
+
},
|
|
2356
2367
|
"eip155:10/erc20:0x01bFF41798a0BcF287b996046Ca68b395DbC1071": {
|
|
2357
2368
|
"caip19": "eip155:10/erc20:0x01bFF41798a0BcF287b996046Ca68b395DbC1071",
|
|
2358
2369
|
"coingeckoId": "usdt0",
|