@xchainjs/xchain-aggregator 2.1.0 → 2.2.0
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/lib/index.esm.js +14 -23
- package/lib/index.js +14 -23
- package/package.json +6 -6
package/lib/index.esm.js
CHANGED
|
@@ -65,6 +65,15 @@ const xAssetToCAsset = (asset) => {
|
|
|
65
65
|
return asset.ticker;
|
|
66
66
|
};
|
|
67
67
|
|
|
68
|
+
const networkToChainflip = (network) => {
|
|
69
|
+
switch (network) {
|
|
70
|
+
case Network.Stagenet:
|
|
71
|
+
return 'perseverance';
|
|
72
|
+
case Network.Mainnet:
|
|
73
|
+
default:
|
|
74
|
+
return 'mainnet';
|
|
75
|
+
}
|
|
76
|
+
};
|
|
68
77
|
/**
|
|
69
78
|
* Chainflip protocol
|
|
70
79
|
*/
|
|
@@ -72,7 +81,7 @@ class ChainflipProtocol {
|
|
|
72
81
|
constructor(configuration) {
|
|
73
82
|
this.name = 'Chainflip';
|
|
74
83
|
this.sdk = new SwapSDK({
|
|
75
|
-
network:
|
|
84
|
+
network: networkToChainflip(configuration === null || configuration === void 0 ? void 0 : configuration.network),
|
|
76
85
|
enabledFeatures: {
|
|
77
86
|
dca: true,
|
|
78
87
|
},
|
|
@@ -155,25 +164,7 @@ class ChainflipProtocol {
|
|
|
155
164
|
// User wants regular quotes - prioritize DCA > REGULAR (ignore boost quotes)
|
|
156
165
|
selectedQuote = quotes.find((quote) => quote.type === 'DCA') || quotes.find((quote) => quote.type === 'REGULAR');
|
|
157
166
|
}
|
|
158
|
-
if (params.destinationAddress &&
|
|
159
|
-
// Use boost quote only if user enabled boost and it's available
|
|
160
|
-
const quoteToUse = params.enableBoost && selectedQuote.boostQuote ? selectedQuote.boostQuote : selectedQuote;
|
|
161
|
-
const resp = yield this.sdk.requestDepositAddressV2({
|
|
162
|
-
quote: quoteToUse,
|
|
163
|
-
destAddress: params.destinationAddress,
|
|
164
|
-
srcAddress: params.fromAddress,
|
|
165
|
-
fillOrKillParams: {
|
|
166
|
-
slippageTolerancePercent: selectedQuote.recommendedSlippageTolerancePercent,
|
|
167
|
-
refundAddress: params.fromAddress,
|
|
168
|
-
retryDurationBlocks: 100,
|
|
169
|
-
},
|
|
170
|
-
affiliateBrokers: this.affiliateBrokers,
|
|
171
|
-
});
|
|
172
|
-
toAddress = resp.depositAddress;
|
|
173
|
-
depositChannelId = resp.depositChannelId;
|
|
174
|
-
}
|
|
175
|
-
else if (params.destinationAddress && (selectedQuote === null || selectedQuote === void 0 ? void 0 : selectedQuote.type) === 'REGULAR' && params.fromAddress) {
|
|
176
|
-
// Use boost quote only if user enabled boost and it's available
|
|
167
|
+
if (params.destinationAddress && selectedQuote && params.fromAddress) {
|
|
177
168
|
const quoteToUse = params.enableBoost && selectedQuote.boostQuote ? selectedQuote.boostQuote : selectedQuote;
|
|
178
169
|
const resp = yield this.sdk.requestDepositAddressV2({
|
|
179
170
|
quote: quoteToUse,
|
|
@@ -6861,7 +6852,7 @@ class MayachainProtocol {
|
|
|
6861
6852
|
expectedAmount: estimatedSwap.expectedAmount,
|
|
6862
6853
|
dustThreshold: estimatedSwap.dustThreshold,
|
|
6863
6854
|
fees: estimatedSwap.fees,
|
|
6864
|
-
totalSwapSeconds: estimatedSwap.inboundConfirmationSeconds || 0 + estimatedSwap.outboundDelaySeconds,
|
|
6855
|
+
totalSwapSeconds: (estimatedSwap.inboundConfirmationSeconds || 0) + estimatedSwap.outboundDelaySeconds,
|
|
6865
6856
|
slipBasisPoints: estimatedSwap.slipBasisPoints,
|
|
6866
6857
|
maxStreamingQuantity: estimatedSwap.maxStreamingQuantity,
|
|
6867
6858
|
canSwap: estimatedSwap.canSwap,
|
|
@@ -9703,7 +9694,7 @@ class ThorchainProtocol {
|
|
|
9703
9694
|
expectedAmount: estimatedSwap.txEstimate.netOutput,
|
|
9704
9695
|
dustThreshold: estimatedSwap.dustThreshold,
|
|
9705
9696
|
fees: estimatedSwap.txEstimate.totalFees,
|
|
9706
|
-
totalSwapSeconds: estimatedSwap.txEstimate.inboundConfirmationSeconds || 0 + estimatedSwap.txEstimate.outboundDelaySeconds,
|
|
9697
|
+
totalSwapSeconds: (estimatedSwap.txEstimate.inboundConfirmationSeconds || 0) + estimatedSwap.txEstimate.outboundDelaySeconds,
|
|
9707
9698
|
slipBasisPoints: estimatedSwap.txEstimate.slipBasisPoints,
|
|
9708
9699
|
maxStreamingQuantity: estimatedSwap.txEstimate.maxStreamingQuantity,
|
|
9709
9700
|
canSwap: estimatedSwap.txEstimate.canSwap,
|
|
@@ -9830,7 +9821,7 @@ class Aggregator {
|
|
|
9830
9821
|
successfulQuotes.push(result.value);
|
|
9831
9822
|
}
|
|
9832
9823
|
});
|
|
9833
|
-
if (
|
|
9824
|
+
if (successfulQuotes.length === 0)
|
|
9834
9825
|
throw Error(`Can not estimate swap from ${assetToString(params.fromAsset)} to ${assetToString(params.destinationAsset)}`);
|
|
9835
9826
|
return successfulQuotes;
|
|
9836
9827
|
});
|
package/lib/index.js
CHANGED
|
@@ -67,6 +67,15 @@ const xAssetToCAsset = (asset) => {
|
|
|
67
67
|
return asset.ticker;
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
+
const networkToChainflip = (network) => {
|
|
71
|
+
switch (network) {
|
|
72
|
+
case xchainClient.Network.Stagenet:
|
|
73
|
+
return 'perseverance';
|
|
74
|
+
case xchainClient.Network.Mainnet:
|
|
75
|
+
default:
|
|
76
|
+
return 'mainnet';
|
|
77
|
+
}
|
|
78
|
+
};
|
|
70
79
|
/**
|
|
71
80
|
* Chainflip protocol
|
|
72
81
|
*/
|
|
@@ -74,7 +83,7 @@ class ChainflipProtocol {
|
|
|
74
83
|
constructor(configuration) {
|
|
75
84
|
this.name = 'Chainflip';
|
|
76
85
|
this.sdk = new swap.SwapSDK({
|
|
77
|
-
network:
|
|
86
|
+
network: networkToChainflip(configuration === null || configuration === void 0 ? void 0 : configuration.network),
|
|
78
87
|
enabledFeatures: {
|
|
79
88
|
dca: true,
|
|
80
89
|
},
|
|
@@ -157,25 +166,7 @@ class ChainflipProtocol {
|
|
|
157
166
|
// User wants regular quotes - prioritize DCA > REGULAR (ignore boost quotes)
|
|
158
167
|
selectedQuote = quotes.find((quote) => quote.type === 'DCA') || quotes.find((quote) => quote.type === 'REGULAR');
|
|
159
168
|
}
|
|
160
|
-
if (params.destinationAddress &&
|
|
161
|
-
// Use boost quote only if user enabled boost and it's available
|
|
162
|
-
const quoteToUse = params.enableBoost && selectedQuote.boostQuote ? selectedQuote.boostQuote : selectedQuote;
|
|
163
|
-
const resp = yield this.sdk.requestDepositAddressV2({
|
|
164
|
-
quote: quoteToUse,
|
|
165
|
-
destAddress: params.destinationAddress,
|
|
166
|
-
srcAddress: params.fromAddress,
|
|
167
|
-
fillOrKillParams: {
|
|
168
|
-
slippageTolerancePercent: selectedQuote.recommendedSlippageTolerancePercent,
|
|
169
|
-
refundAddress: params.fromAddress,
|
|
170
|
-
retryDurationBlocks: 100,
|
|
171
|
-
},
|
|
172
|
-
affiliateBrokers: this.affiliateBrokers,
|
|
173
|
-
});
|
|
174
|
-
toAddress = resp.depositAddress;
|
|
175
|
-
depositChannelId = resp.depositChannelId;
|
|
176
|
-
}
|
|
177
|
-
else if (params.destinationAddress && (selectedQuote === null || selectedQuote === void 0 ? void 0 : selectedQuote.type) === 'REGULAR' && params.fromAddress) {
|
|
178
|
-
// Use boost quote only if user enabled boost and it's available
|
|
169
|
+
if (params.destinationAddress && selectedQuote && params.fromAddress) {
|
|
179
170
|
const quoteToUse = params.enableBoost && selectedQuote.boostQuote ? selectedQuote.boostQuote : selectedQuote;
|
|
180
171
|
const resp = yield this.sdk.requestDepositAddressV2({
|
|
181
172
|
quote: quoteToUse,
|
|
@@ -6863,7 +6854,7 @@ class MayachainProtocol {
|
|
|
6863
6854
|
expectedAmount: estimatedSwap.expectedAmount,
|
|
6864
6855
|
dustThreshold: estimatedSwap.dustThreshold,
|
|
6865
6856
|
fees: estimatedSwap.fees,
|
|
6866
|
-
totalSwapSeconds: estimatedSwap.inboundConfirmationSeconds || 0 + estimatedSwap.outboundDelaySeconds,
|
|
6857
|
+
totalSwapSeconds: (estimatedSwap.inboundConfirmationSeconds || 0) + estimatedSwap.outboundDelaySeconds,
|
|
6867
6858
|
slipBasisPoints: estimatedSwap.slipBasisPoints,
|
|
6868
6859
|
maxStreamingQuantity: estimatedSwap.maxStreamingQuantity,
|
|
6869
6860
|
canSwap: estimatedSwap.canSwap,
|
|
@@ -9705,7 +9696,7 @@ class ThorchainProtocol {
|
|
|
9705
9696
|
expectedAmount: estimatedSwap.txEstimate.netOutput,
|
|
9706
9697
|
dustThreshold: estimatedSwap.dustThreshold,
|
|
9707
9698
|
fees: estimatedSwap.txEstimate.totalFees,
|
|
9708
|
-
totalSwapSeconds: estimatedSwap.txEstimate.inboundConfirmationSeconds || 0 + estimatedSwap.txEstimate.outboundDelaySeconds,
|
|
9699
|
+
totalSwapSeconds: (estimatedSwap.txEstimate.inboundConfirmationSeconds || 0) + estimatedSwap.txEstimate.outboundDelaySeconds,
|
|
9709
9700
|
slipBasisPoints: estimatedSwap.txEstimate.slipBasisPoints,
|
|
9710
9701
|
maxStreamingQuantity: estimatedSwap.txEstimate.maxStreamingQuantity,
|
|
9711
9702
|
canSwap: estimatedSwap.txEstimate.canSwap,
|
|
@@ -9832,7 +9823,7 @@ class Aggregator {
|
|
|
9832
9823
|
successfulQuotes.push(result.value);
|
|
9833
9824
|
}
|
|
9834
9825
|
});
|
|
9835
|
-
if (
|
|
9826
|
+
if (successfulQuotes.length === 0)
|
|
9836
9827
|
throw Error(`Can not estimate swap from ${xchainUtil.assetToString(params.fromAsset)} to ${xchainUtil.assetToString(params.destinationAsset)}`);
|
|
9837
9828
|
return successfulQuotes;
|
|
9838
9829
|
});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xchainjs/xchain-aggregator",
|
|
3
3
|
"description": "Protocol aggregator to make actions in different protocols",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.2.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "lib/index.js",
|
|
7
7
|
"module": "lib/index.esm.js",
|
|
@@ -29,21 +29,21 @@
|
|
|
29
29
|
"directory": "release/package"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@chainflip/sdk": "
|
|
32
|
+
"@chainflip/sdk": "2.0.3",
|
|
33
33
|
"@xchainjs/xchain-client": "2.0.10",
|
|
34
34
|
"@xchainjs/xchain-mayachain": "4.1.1",
|
|
35
|
-
"@xchainjs/xchain-mayachain-amm": "4.1.
|
|
35
|
+
"@xchainjs/xchain-mayachain-amm": "4.1.11",
|
|
36
36
|
"@xchainjs/xchain-mayachain-query": "2.1.6",
|
|
37
37
|
"@xchainjs/xchain-thorchain": "3.0.14",
|
|
38
|
-
"@xchainjs/xchain-thorchain-amm": "3.0.
|
|
38
|
+
"@xchainjs/xchain-thorchain-amm": "3.0.29",
|
|
39
39
|
"@xchainjs/xchain-thorchain-query": "2.0.16",
|
|
40
40
|
"@xchainjs/xchain-util": "2.0.5",
|
|
41
|
-
"@xchainjs/xchain-wallet": "2.0.
|
|
41
|
+
"@xchainjs/xchain-wallet": "2.0.22"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@xchainjs/xchain-avax": "2.0.14",
|
|
45
45
|
"@xchainjs/xchain-base": "1.0.14",
|
|
46
|
-
"@xchainjs/xchain-bitcoin": "2.
|
|
46
|
+
"@xchainjs/xchain-bitcoin": "2.2.0",
|
|
47
47
|
"@xchainjs/xchain-bsc": "2.0.15",
|
|
48
48
|
"@xchainjs/xchain-ethereum": "2.0.15",
|
|
49
49
|
"@xchainjs/xchain-kujira": "2.0.10",
|