@shapeshiftoss/swapper 11.5.3 → 11.5.5
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.
|
@@ -119,12 +119,15 @@ class ThorchainSwapper {
|
|
|
119
119
|
});
|
|
120
120
|
const { chainNamespace } = (0, caip_1.fromAssetId)(trade.sellAsset.assetId);
|
|
121
121
|
if (chainNamespace === caip_1.CHAIN_NAMESPACE.Evm) {
|
|
122
|
-
const
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
122
|
+
const evmAdapter = adapter;
|
|
123
|
+
const txToSign = trade.txData;
|
|
124
|
+
if (wallet.supportsBroadcast()) {
|
|
125
|
+
const tradeId = await evmAdapter.signAndBroadcastTransaction({ txToSign, wallet });
|
|
126
|
+
return { tradeId };
|
|
127
|
+
}
|
|
128
|
+
const signedTx = await evmAdapter.signTransaction({ txToSign, wallet });
|
|
129
|
+
const tradeId = await adapter.broadcastTransaction(signedTx);
|
|
130
|
+
return { tradeId };
|
|
128
131
|
}
|
|
129
132
|
else if (chainNamespace === caip_1.CHAIN_NAMESPACE.Utxo) {
|
|
130
133
|
const signedTx = await adapter.signTransaction({
|
|
@@ -28,6 +28,17 @@ const getPriceRatio = async (deps, input) => {
|
|
|
28
28
|
const { data: responseData } = await thorService_1.thorService.get(`${deps.daemonUrl}/lcd/thorchain/pools`);
|
|
29
29
|
const buyPool = responseData.find((response) => response.asset === buyPoolId);
|
|
30
30
|
const sellPool = responseData.find((response) => response.asset === sellPoolId);
|
|
31
|
+
/**
|
|
32
|
+
* there is no rune pool, rune *is* the pool, special logic case buying RUNE
|
|
33
|
+
*/
|
|
34
|
+
if ((0, isRune_1.isRune)(buyAssetId) && sellPool) {
|
|
35
|
+
const sellAssetBalance = (0, bignumber_1.bnOrZero)(sellPool.balance_asset);
|
|
36
|
+
const runeBalance = (0, bignumber_1.bnOrZero)(sellPool.balance_rune);
|
|
37
|
+
// guard against division by zero
|
|
38
|
+
if (sellAssetBalance.eq(0))
|
|
39
|
+
throw new api_1.SwapError(`[getPriceRatio] zero sell asset balance sellAssetId ${sellAssetId} buyAssetId ${buyAssetId}`);
|
|
40
|
+
return (0, bignumber_1.bn)(runeBalance).dividedBy(sellAssetBalance).toString();
|
|
41
|
+
}
|
|
31
42
|
if (!buyPool || !sellPool) {
|
|
32
43
|
throw new api_1.SwapError(`[getPriceRatio]: pools not found`, {
|
|
33
44
|
code: api_1.SwapErrorTypes.RESPONSE_ERROR,
|
package/package.json
CHANGED