@silentswap/sdk 0.0.63 → 0.0.65
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 +2 -2
- package/dist/quote-utils.js +28 -8
- package/package.json +1 -1
- package/src/data/filtered.json +2 -2
package/dist/data/filtered.json
CHANGED
|
@@ -694,9 +694,9 @@
|
|
|
694
694
|
},
|
|
695
695
|
"eip155:1/erc20:0xb72e76ccf005313868db7b48070901a44629da98": {
|
|
696
696
|
"caip19": "eip155:1/erc20:0xb72e76ccf005313868db7b48070901a44629da98",
|
|
697
|
-
"coingeckoId": "squidgrow",
|
|
697
|
+
"coingeckoId": "squidgrow-2",
|
|
698
698
|
"name": "SquidGrow",
|
|
699
|
-
"symbol": "
|
|
699
|
+
"symbol": "SQGROW",
|
|
700
700
|
"decimals": 9,
|
|
701
701
|
"gradient": [
|
|
702
702
|
"000000",
|
package/dist/quote-utils.js
CHANGED
|
@@ -90,29 +90,49 @@ export function calculateDebridgeMetrics(debridgeQuote) {
|
|
|
90
90
|
txCount: 2, // DeBridge typically requires 2 txs
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
+
/**
|
|
94
|
+
* Check if a relay quote response contains executable transaction data
|
|
95
|
+
*/
|
|
96
|
+
function relayHasTransactionData(quote) {
|
|
97
|
+
const steps = quote.steps || [];
|
|
98
|
+
return steps.some((step) => (step.items || []).some((item) => {
|
|
99
|
+
const d = item.data || {};
|
|
100
|
+
// EVM tx (has 'to'), Solana tx (has 'instructions'), or Bitcoin tx (has 'psbt'/'hex'/'data' without 'to')
|
|
101
|
+
return d.to || d.instructions || d.psbt || d.hex;
|
|
102
|
+
}));
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Check if a deBridge quote response contains executable transaction data
|
|
106
|
+
*/
|
|
107
|
+
function debridgeHasTransactionData(quote) {
|
|
108
|
+
return !!(quote.tx && (quote.tx.to || quote.tx.data));
|
|
109
|
+
}
|
|
93
110
|
/**
|
|
94
111
|
* Select the best quote from multiple providers based on retention rate
|
|
95
112
|
*/
|
|
96
113
|
export function selectBestQuote(relayQuote, debridgeQuote, srcAmount) {
|
|
97
|
-
//
|
|
98
|
-
const
|
|
99
|
-
const
|
|
100
|
-
//
|
|
101
|
-
|
|
114
|
+
// Only consider providers that have executable transaction data
|
|
115
|
+
const viableRelay = relayQuote && relayHasTransactionData(relayQuote) ? relayQuote : null;
|
|
116
|
+
const viableDebridge = debridgeQuote && debridgeHasTransactionData(debridgeQuote) ? debridgeQuote : null;
|
|
117
|
+
// Calculate metrics only for viable providers
|
|
118
|
+
const relayMetrics = viableRelay ? calculateRelayMetrics(viableRelay) : null;
|
|
119
|
+
const debridgeMetrics = viableDebridge ? calculateDebridgeMetrics(viableDebridge) : null;
|
|
120
|
+
// Both providers failed or have no executable transactions
|
|
121
|
+
if (!viableRelay && !viableDebridge) {
|
|
102
122
|
throw new Error('All quote providers failed');
|
|
103
123
|
}
|
|
104
124
|
// Determine best provider based on retention rate
|
|
105
125
|
let bestProvider;
|
|
106
126
|
let bestQuote;
|
|
107
127
|
let bestMetrics;
|
|
108
|
-
if (!
|
|
128
|
+
if (!viableRelay || (debridgeMetrics && debridgeMetrics.retention > (relayMetrics?.retention || 0))) {
|
|
109
129
|
bestProvider = 'debridge';
|
|
110
|
-
bestQuote =
|
|
130
|
+
bestQuote = viableDebridge;
|
|
111
131
|
bestMetrics = debridgeMetrics;
|
|
112
132
|
}
|
|
113
133
|
else {
|
|
114
134
|
bestProvider = 'relay';
|
|
115
|
-
bestQuote =
|
|
135
|
+
bestQuote = viableRelay;
|
|
116
136
|
bestMetrics = relayMetrics;
|
|
117
137
|
}
|
|
118
138
|
// Extract output amount
|
package/package.json
CHANGED
package/src/data/filtered.json
CHANGED
|
@@ -694,9 +694,9 @@
|
|
|
694
694
|
},
|
|
695
695
|
"eip155:1/erc20:0xb72e76ccf005313868db7b48070901a44629da98": {
|
|
696
696
|
"caip19": "eip155:1/erc20:0xb72e76ccf005313868db7b48070901a44629da98",
|
|
697
|
-
"coingeckoId": "squidgrow",
|
|
697
|
+
"coingeckoId": "squidgrow-2",
|
|
698
698
|
"name": "SquidGrow",
|
|
699
|
-
"symbol": "
|
|
699
|
+
"symbol": "SQGROW",
|
|
700
700
|
"decimals": 9,
|
|
701
701
|
"gradient": [
|
|
702
702
|
"000000",
|