@silentswap/sdk 0.0.82 → 0.0.84
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 +4 -4
- package/dist/quote-utils.d.ts +1 -1
- package/dist/quote-utils.js +29 -12
- package/package.json +1 -1
- package/src/data/filtered.json +4 -4
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,8 +2353,8 @@
|
|
|
2353
2353
|
"00D49B"
|
|
2354
2354
|
]
|
|
2355
2355
|
},
|
|
2356
|
-
"eip155:137/erc20:
|
|
2357
|
-
"caip19": "eip155:137/erc20:
|
|
2356
|
+
"eip155:137/erc20:0xCfde7c43EDB3c9f71331AAc1003b099CE40c94ea": {
|
|
2357
|
+
"caip19": "eip155:137/erc20:0xCfde7c43EDB3c9f71331AAc1003b099CE40c94ea",
|
|
2358
2358
|
"coingeckoId": "gift",
|
|
2359
2359
|
"name": "GIFT",
|
|
2360
2360
|
"symbol": "GIFT",
|
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;
|
|
@@ -483,19 +494,23 @@ forceProvider) {
|
|
|
483
494
|
if (isSrcBitcoin || isDestBitcoin) {
|
|
484
495
|
return null;
|
|
485
496
|
}
|
|
497
|
+
const isExactOutput = tradeType === 'EXACT_OUTPUT' && dstAmount;
|
|
486
498
|
const debridgeParams = {
|
|
487
499
|
srcChainId: debridgeSrcChainId,
|
|
488
500
|
srcChainTokenIn: srcTokenNorm,
|
|
489
|
-
srcChainTokenInAmount: srcAmount,
|
|
501
|
+
srcChainTokenInAmount: isExactOutput ? 'auto' : srcAmount,
|
|
490
502
|
dstChainId: debridgeDstChainId,
|
|
491
503
|
dstChainTokenOut: dstTokenNorm,
|
|
492
504
|
prependOperatingExpenses: true,
|
|
493
505
|
account: userAddress,
|
|
494
506
|
};
|
|
507
|
+
if (isExactOutput) {
|
|
508
|
+
debridgeParams.dstChainTokenOutAmount = dstAmount;
|
|
509
|
+
}
|
|
495
510
|
// Handle Solana source or destination
|
|
496
511
|
if (isSrcSolana || isDestSolana) {
|
|
497
|
-
// For Solana source or destination
|
|
498
|
-
// 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)
|
|
499
514
|
debridgeParams.enableEstimate = false;
|
|
500
515
|
// Set recipient address (required for Solana source or destination)
|
|
501
516
|
if (!recipientAddress) {
|
|
@@ -538,7 +553,9 @@ forceProvider) {
|
|
|
538
553
|
debridgeParams.dstChainOrderAuthorityAddress = evmRecipient;
|
|
539
554
|
debridgeParams.srcChainRefundAddress = userAddress;
|
|
540
555
|
debridgeParams.senderAddress = userAddress;
|
|
541
|
-
|
|
556
|
+
if (!isExactOutput) {
|
|
557
|
+
debridgeParams.dstChainTokenOutAmount = 'auto';
|
|
558
|
+
}
|
|
542
559
|
debridgeParams.enableEstimate = true;
|
|
543
560
|
// Optional params matching deSwap app for consistent API behavior
|
|
544
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,8 +2353,8 @@
|
|
|
2353
2353
|
"00D49B"
|
|
2354
2354
|
]
|
|
2355
2355
|
},
|
|
2356
|
-
"eip155:137/erc20:
|
|
2357
|
-
"caip19": "eip155:137/erc20:
|
|
2356
|
+
"eip155:137/erc20:0xCfde7c43EDB3c9f71331AAc1003b099CE40c94ea": {
|
|
2357
|
+
"caip19": "eip155:137/erc20:0xCfde7c43EDB3c9f71331AAc1003b099CE40c94ea",
|
|
2358
2358
|
"coingeckoId": "gift",
|
|
2359
2359
|
"name": "GIFT",
|
|
2360
2360
|
"symbol": "GIFT",
|