@xchainjs/xchain-aggregator 0.2.6 → 1.0.1
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 -6
- package/lib/index.esm.js.map +1 -1
- package/lib/index.js +13 -5
- package/lib/index.js.map +1 -1
- package/lib/protocols/chainflip/chainflipProtocol.d.ts +2 -2
- package/lib/protocols/chainflip/types.d.ts +2 -0
- package/lib/protocols/chainflip/utils.d.ts +3 -3
- package/lib/protocols/mayachain/mayachainProtocol.d.ts +2 -2
- package/lib/protocols/mayachain/types.d.ts +2 -0
- package/lib/protocols/thorchain/thorchainProtocol.d.ts +2 -2
- package/lib/types.d.ts +10 -10
- package/package.json +16 -16
package/lib/index.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CachedValue, isSynthAsset, CryptoAmount, baseAmount, eqAsset, assetFromStringEx, assetToString } from '@xchainjs/xchain-util';
|
|
1
|
+
import { CachedValue, isSynthAsset, isTradeAsset, CryptoAmount, baseAmount, eqAsset, assetFromStringEx, assetToString } from '@xchainjs/xchain-util';
|
|
2
2
|
import { AssetCacao, MAYAChain } from '@xchainjs/xchain-mayachain';
|
|
3
3
|
import { MayachainAMM } from '@xchainjs/xchain-mayachain-amm';
|
|
4
4
|
import { MayachainQuery } from '@xchainjs/xchain-mayachain-query';
|
|
@@ -25430,7 +25430,7 @@ class ChainflipProtocol {
|
|
|
25430
25430
|
*/
|
|
25431
25431
|
isAssetSupported(asset) {
|
|
25432
25432
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25433
|
-
if (isSynthAsset(asset))
|
|
25433
|
+
if (isSynthAsset(asset) || isTradeAsset(asset))
|
|
25434
25434
|
return false;
|
|
25435
25435
|
try {
|
|
25436
25436
|
yield this.getAssetData(asset);
|
|
@@ -25567,6 +25567,12 @@ class ChainflipProtocol {
|
|
|
25567
25567
|
*/
|
|
25568
25568
|
getAssetData(asset) {
|
|
25569
25569
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25570
|
+
if (isSynthAsset(asset)) {
|
|
25571
|
+
throw Error('Synth asset not supported in Chainflip protocol');
|
|
25572
|
+
}
|
|
25573
|
+
if (isTradeAsset(asset)) {
|
|
25574
|
+
throw Error('Trade asset not supported in Chainflip protocol');
|
|
25575
|
+
}
|
|
25570
25576
|
const chainAssets = yield this.assetsData.getValue();
|
|
25571
25577
|
const assetData = chainAssets.find((chainAsset) => {
|
|
25572
25578
|
var _a;
|
|
@@ -25595,7 +25601,9 @@ class MayachainProtocol {
|
|
|
25595
25601
|
*/
|
|
25596
25602
|
isAssetSupported(asset) {
|
|
25597
25603
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25598
|
-
if (
|
|
25604
|
+
if (isTradeAsset(asset))
|
|
25605
|
+
return false;
|
|
25606
|
+
if (eqAsset(asset, AssetCacao) || isSynthAsset(asset))
|
|
25599
25607
|
return true;
|
|
25600
25608
|
const pools = yield this.mayachainQuery.getPools();
|
|
25601
25609
|
return (pools.findIndex((pool) => pool.status === 'available' && eqAsset(asset, assetFromStringEx(pool.asset))) !== -1);
|
|
@@ -25620,7 +25628,7 @@ class MayachainProtocol {
|
|
|
25620
25628
|
estimateSwap(params) {
|
|
25621
25629
|
var _a, _b;
|
|
25622
25630
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25623
|
-
const estimatedSwap = yield this.mayachainAmm.estimateSwap(Object.assign(Object.assign({}, params), { affiliateBps: (_a = this.configuration) === null || _a === void 0 ? void 0 : _a.affiliateBps, affiliateAddress: (_b = this.configuration) === null || _b === void 0 ? void 0 : _b.affiliateAddress }));
|
|
25631
|
+
const estimatedSwap = yield this.mayachainAmm.estimateSwap(Object.assign(Object.assign({}, params), { fromAsset: params.fromAsset, destinationAsset: params.destinationAsset, amount: params.amount, affiliateBps: (_a = this.configuration) === null || _a === void 0 ? void 0 : _a.affiliateBps, affiliateAddress: (_b = this.configuration) === null || _b === void 0 ? void 0 : _b.affiliateAddress }));
|
|
25624
25632
|
return {
|
|
25625
25633
|
protocol: this.name,
|
|
25626
25634
|
toAddress: estimatedSwap.toAddress,
|
|
@@ -25644,7 +25652,7 @@ class MayachainProtocol {
|
|
|
25644
25652
|
doSwap(params) {
|
|
25645
25653
|
var _a, _b;
|
|
25646
25654
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25647
|
-
return this.mayachainAmm.doSwap(Object.assign(Object.assign({}, params), { affiliateBps: (_a = this.configuration) === null || _a === void 0 ? void 0 : _a.affiliateBps, affiliateAddress: (_b = this.configuration) === null || _b === void 0 ? void 0 : _b.affiliateAddress }));
|
|
25655
|
+
return this.mayachainAmm.doSwap(Object.assign(Object.assign({}, params), { fromAsset: params.fromAsset, destinationAsset: params.destinationAsset, amount: params.amount, affiliateBps: (_a = this.configuration) === null || _a === void 0 ? void 0 : _a.affiliateBps, affiliateAddress: (_b = this.configuration) === null || _b === void 0 ? void 0 : _b.affiliateAddress }));
|
|
25648
25656
|
});
|
|
25649
25657
|
}
|
|
25650
25658
|
/**
|
|
@@ -25681,7 +25689,7 @@ class ThorchainProtocol {
|
|
|
25681
25689
|
*/
|
|
25682
25690
|
isAssetSupported(asset) {
|
|
25683
25691
|
return __awaiter(this, void 0, void 0, function* () {
|
|
25684
|
-
if (eqAsset(asset, AssetRuneNative))
|
|
25692
|
+
if (eqAsset(asset, AssetRuneNative) || isTradeAsset(asset) || isSynthAsset(asset))
|
|
25685
25693
|
return true;
|
|
25686
25694
|
const pools = yield this.thorchainQuery.thorchainCache.getPools();
|
|
25687
25695
|
return (Object.values(pools).findIndex((pool) => pool.isAvailable() && assetToString(asset) === pool.assetString) !== -1);
|